@thi.ng/csv 2.5.0 → 2.5.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 +10 -1
- package/api.d.ts +3 -1
- package/package.json +2 -2
- package/parse.js +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2025-08-06T11:
|
|
3
|
+
- **Last updated**: 2025-08-06T11:48:03Z
|
|
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,15 @@ 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.5.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/csv@2.5.1) (2025-08-06)
|
|
15
|
+
|
|
16
|
+
#### ♻️ Refactoring
|
|
17
|
+
|
|
18
|
+
- update default value handling (fn lookup) ([8d373bb](https://github.com/thi-ng/umbrella/commit/8d373bb))
|
|
19
|
+
- allow `ColumnSpec.default` to be functions
|
|
20
|
+
- update `parseCSV()`
|
|
21
|
+
- update tests
|
|
22
|
+
|
|
14
23
|
## [2.5.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/csv@2.5.0) (2025-08-06)
|
|
15
24
|
|
|
16
25
|
#### 🚀 Features
|
package/api.d.ts
CHANGED
|
@@ -28,7 +28,9 @@ export interface ColumnSpec {
|
|
|
28
28
|
*/
|
|
29
29
|
tx?: CellTransform;
|
|
30
30
|
/**
|
|
31
|
-
* Default value to use if column is missing.
|
|
31
|
+
* Default value or function to use if column is missing. If `default` is a
|
|
32
|
+
* function, it will be called with the entire {@link CSVRecord} constructed
|
|
33
|
+
* so far and the return value used as default.
|
|
32
34
|
*
|
|
33
35
|
* @remarks
|
|
34
36
|
* Also see note about {@link ColumnSpec.alias}.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/csv",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "Customizable, transducer-based CSV parser/object mapper and transformer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"thi.ng": {
|
|
89
89
|
"year": 2014
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "a07af3b3e8e8f3b07e326156bd1fce36b9a97108\n"
|
|
92
92
|
}
|
package/parse.js
CHANGED
|
@@ -55,7 +55,9 @@ function parseCSV(opts, src) {
|
|
|
55
55
|
return acc;
|
|
56
56
|
}, row);
|
|
57
57
|
const collectDefaults = (row) => defaults.reduce((acc, { alias, default: val }) => {
|
|
58
|
-
if (acc[alias] === void 0)
|
|
58
|
+
if (acc[alias] === void 0) {
|
|
59
|
+
acc[alias] = isFunction(val) ? val(acc) : val;
|
|
60
|
+
}
|
|
59
61
|
return acc;
|
|
60
62
|
}, row);
|
|
61
63
|
header && init(header);
|