@thi.ng/csv 2.3.135 → 2.4.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2025-07-10T14:20:23Z
3
+ - **Last updated**: 2025-07-13T21:35:34Z
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/README.md CHANGED
@@ -87,7 +87,7 @@ For Node.js REPL:
87
87
  const csv = await import("@thi.ng/csv");
88
88
  ```
89
89
 
90
- Package sizes (brotli'd, pre-treeshake): ESM: 1.53 KB
90
+ Package sizes (brotli'd, pre-treeshake): ESM: 1.56 KB
91
91
 
92
92
  ## Dependencies
93
93
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/csv",
3
- "version": "2.3.135",
3
+ "version": "2.4.1",
4
4
  "description": "Customizable, transducer-based CSV parser/object mapper and transformer",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -42,7 +42,7 @@
42
42
  "@thi.ng/api": "^8.11.30",
43
43
  "@thi.ng/checks": "^3.7.10",
44
44
  "@thi.ng/strings": "^3.9.16",
45
- "@thi.ng/transducers": "^9.5.1"
45
+ "@thi.ng/transducers": "^9.6.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "esbuild": "^0.25.6",
@@ -87,5 +87,5 @@
87
87
  "thi.ng": {
88
88
  "year": 2014
89
89
  },
90
- "gitHead": "56d8f088389b22192a06e9a395b5eecebf47697a\n"
90
+ "gitHead": "a81765bd79046980463c56a8bd187f9aaa88dd65\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,