@thi.ng/csv 2.3.134 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -1
- package/package.json +8 -8
- package/transforms.d.ts +7 -0
- package/transforms.js +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2025-
|
|
3
|
+
- **Last updated**: 2025-07-12T12:28:22Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -11,6 +11,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
11
11
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
12
12
|
and/or version bumps of transitive dependencies.
|
|
13
13
|
|
|
14
|
+
## [2.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/csv@2.4.0) (2025-07-12)
|
|
15
|
+
|
|
16
|
+
#### 🚀 Features
|
|
17
|
+
|
|
18
|
+
- add `json()` higher-order cell transform ([d8a95dd](https://github.com/thi-ng/umbrella/commit/d8a95dd))
|
|
19
|
+
|
|
14
20
|
### [2.3.87](https://github.com/thi-ng/umbrella/tree/@thi.ng/csv@2.3.87) (2024-06-21)
|
|
15
21
|
|
|
16
22
|
#### ♻️ Refactoring
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/csv",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Customizable, transducer-based CSV parser/object mapper and transformer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@thi.ng/api": "^8.11.
|
|
43
|
-
"@thi.ng/checks": "^3.7.
|
|
44
|
-
"@thi.ng/strings": "^3.9.
|
|
45
|
-
"@thi.ng/transducers": "^9.5.
|
|
42
|
+
"@thi.ng/api": "^8.11.30",
|
|
43
|
+
"@thi.ng/checks": "^3.7.10",
|
|
44
|
+
"@thi.ng/strings": "^3.9.16",
|
|
45
|
+
"@thi.ng/transducers": "^9.5.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"esbuild": "^0.25.
|
|
49
|
-
"typedoc": "^0.28.
|
|
48
|
+
"esbuild": "^0.25.6",
|
|
49
|
+
"typedoc": "^0.28.7",
|
|
50
50
|
"typescript": "^5.8.3"
|
|
51
51
|
},
|
|
52
52
|
"keywords": [
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"thi.ng": {
|
|
88
88
|
"year": 2014
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "4d75e2d11a3d1a3c3769ca00338e32a820c69d2c\n"
|
|
91
91
|
}
|
package/transforms.d.ts
CHANGED
|
@@ -12,6 +12,13 @@ export declare const upper: CellTransform;
|
|
|
12
12
|
* @param x -
|
|
13
13
|
*/
|
|
14
14
|
export declare const lower: CellTransform;
|
|
15
|
+
/**
|
|
16
|
+
* Higher-order cell parse value transform. Attempts to parse given input as
|
|
17
|
+
* JSON and returns it. Returns configured `defaultVal` in case of parse error.
|
|
18
|
+
*
|
|
19
|
+
* @param defaultVal
|
|
20
|
+
*/
|
|
21
|
+
export declare const json: (defaultVal?: any) => CellTransform;
|
|
15
22
|
/**
|
|
16
23
|
* Higher-order cell parse value transform. Attempts to parse cell values as
|
|
17
24
|
* floating point number or returns `defaultVal` if not possible.
|
package/transforms.js
CHANGED
|
@@ -3,6 +3,13 @@ import { maybeParseFloat, maybeParseInt } from "@thi.ng/strings/parse";
|
|
|
3
3
|
import { percent as $percent } from "@thi.ng/strings/percent";
|
|
4
4
|
const upper = (x) => x.toUpperCase();
|
|
5
5
|
const lower = (x) => x.toLowerCase();
|
|
6
|
+
const json = (defaultVal) => (x) => {
|
|
7
|
+
try {
|
|
8
|
+
return JSON.parse(x);
|
|
9
|
+
} catch (e) {
|
|
10
|
+
return defaultVal;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
6
13
|
const float = (defaultVal = 0) => (x) => maybeParseFloat(x, defaultVal);
|
|
7
14
|
const int = (defaultVal = 0) => (x) => maybeParseInt(x, defaultVal, 10);
|
|
8
15
|
const hex = (defaultVal = 0) => (x) => maybeParseInt(x, defaultVal, 16);
|
|
@@ -31,6 +38,7 @@ export {
|
|
|
31
38
|
formatPercent,
|
|
32
39
|
hex,
|
|
33
40
|
int,
|
|
41
|
+
json,
|
|
34
42
|
lower,
|
|
35
43
|
oneOf,
|
|
36
44
|
percent,
|