@thi.ng/csv 2.5.1 → 2.5.2
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 +7 -3
- package/package.json +2 -2
- package/parse.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2025-08-
|
|
3
|
+
- **Last updated**: 2025-08-06T12:38:14Z
|
|
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.2](https://github.com/thi-ng/umbrella/tree/@thi.ng/csv@2.5.2) (2025-08-06)
|
|
15
|
+
|
|
16
|
+
#### 🩹 Bug fixes
|
|
17
|
+
|
|
18
|
+
- update default handling (empty) ([b223719](https://github.com/thi-ng/umbrella/commit/b223719))
|
|
19
|
+
- include empty columns/cells for default eligibility
|
|
20
|
+
- update `ColumnSpec` docs (re: role of cell transforms)
|
|
21
|
+
- update tests
|
|
22
|
+
|
|
14
23
|
### [2.5.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/csv@2.5.1) (2025-08-06)
|
|
15
24
|
|
|
16
25
|
#### ♻️ Refactoring
|
package/api.d.ts
CHANGED
|
@@ -28,11 +28,15 @@ export interface ColumnSpec {
|
|
|
28
28
|
*/
|
|
29
29
|
tx?: CellTransform;
|
|
30
30
|
/**
|
|
31
|
-
* Default value or function to use if column is missing
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
* Default value or function to use if column is missing entirely, or if a
|
|
32
|
+
* column/cell value is empty string and there is no {@link ColumnSpec.tx}
|
|
33
|
+
* defined (which would always be called first).
|
|
34
34
|
*
|
|
35
35
|
* @remarks
|
|
36
|
+
* If `default` is a function, it will be called with the entire
|
|
37
|
+
* {@link CSVRecord} constructed so far and the return value used as
|
|
38
|
+
* default.
|
|
39
|
+
*
|
|
36
40
|
* Also see note about {@link ColumnSpec.alias}.
|
|
37
41
|
*/
|
|
38
42
|
default?: any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/csv",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.2",
|
|
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": "4473edbe5529fe687e18af3a737b01fea4997801\n"
|
|
92
92
|
}
|
package/parse.js
CHANGED
|
@@ -55,7 +55,7 @@ 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 || acc[alias] === "") {
|
|
59
59
|
acc[alias] = isFunction(val) ? val(acc) : val;
|
|
60
60
|
}
|
|
61
61
|
return acc;
|