@dpuse/dpuse-tool-adaltas-csv-parser 1.0.125 → 1.0.127
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/README.md
CHANGED
|
@@ -61,7 +61,7 @@ License data is updated each time `npm run document` is run, using [license-chec
|
|
|
61
61
|
|
|
62
62
|
| Dependency | Version | License(s) | Document |
|
|
63
63
|
| :----------------------------------------------------------- | :-----: | :--------- | :-------------------------------------------------------------------- |
|
|
64
|
-
| [@dpuse/dpuse-shared](https://github.com/dpuse/dpuse-shared) | 1.0.
|
|
64
|
+
| [@dpuse/dpuse-shared](https://github.com/dpuse/dpuse-shared) | 1.0.174 | MIT | [LICENSE](licenses/downloads/@dpuse/dpuse-shared@1.0.174-LICENSE.txt) |
|
|
65
65
|
| [csv-parse](https://github.com/adaltas/node-csv) | 7.0.3 | MIT | [LICENSE](licenses/downloads/csv-parse@7.0.3-LICENSE.txt) |
|
|
66
66
|
| [valibot](https://github.com/open-circle/valibot) | 1.5.0 | MIT | [LICENSE](licenses/downloads/valibot@1.5.0-LICENSE.txt) |
|
|
67
67
|
|
|
@@ -69,7 +69,7 @@ License data is updated each time `npm run document` is run, using [license-chec
|
|
|
69
69
|
|
|
70
70
|
The dependency tree below shows how each package in the table above is reached — direct and transitive — along with its installed version, release date, and update status. A package that does not ship itself, such as one whose parts are bundled separately, is left out and what ships beneath it is shown in its place. Packages flagged ❗ have a newer version available; ⚠️ indicates a package that hasn't been updated in the last 6 months or longer. Neither flag necessarily indicates a problem: we let new releases stabilise before upgrading, and some packages are mature and stable (have limited or no dependencies), so they require no active development.
|
|
71
71
|
|
|
72
|
-
- **[@dpuse/dpuse-shared](https://github.com/dpuse/dpuse-shared)** 1.0.
|
|
72
|
+
- **[@dpuse/dpuse-shared](https://github.com/dpuse/dpuse-shared)** 1.0.174 — this month: 2026-11-02
|
|
73
73
|
- **[valibot](https://github.com/open-circle/valibot)** 1.5.0 — 1 mth ago: 2026-09-09
|
|
74
74
|
- **[csv-parse](https://github.com/adaltas/node-csv)** 7.0.3 — 1 mth ago: 2026-09-25
|
|
75
75
|
|
|
@@ -85,10 +85,10 @@ _Note: Sonda's Vite reports currently exclude CSS files, since Vite does not gen
|
|
|
85
85
|
|
|
86
86
|
| Chunk/Module/File | Composition |
|
|
87
87
|
| :-------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------- |
|
|
88
|
-
| **dist/dpuse-tool-adaltas-csv-parser.es.js** | 126.
|
|
89
|
-
| csv-parse → dist/esm/index.js | `████████████████░░░░` 78.
|
|
90
|
-
| @dpuse/dpuse-shared → dist/dpuse-shared.es.js | `███░░░░░░░░░░░░░░░░░` 12.
|
|
91
|
-
| src → index.ts | `█░░░░░░░░░░░░░░░░░░░` 3.
|
|
88
|
+
| **dist/dpuse-tool-adaltas-csv-parser.es.js** | 126.9 kB · gzip 31.9 kB · 100.0% of the build |
|
|
89
|
+
| csv-parse → dist/esm/index.js | `████████████████░░░░` 78.2% · 99.2 kB |
|
|
90
|
+
| @dpuse/dpuse-shared → dist/dpuse-shared.es.js | `███░░░░░░░░░░░░░░░░░` 12.6% · 15.9 kB |
|
|
91
|
+
| src → index.ts | `█░░░░░░░░░░░░░░░░░░░` 3.5% · 4.4 kB |
|
|
92
92
|
| (bundler output, whitespace & JSON) | `█░░░░░░░░░░░░░░░░░░░` 5.8% · 7.4 kB |
|
|
93
93
|
|
|
94
94
|
Bars show each row's share of its output file.
|
|
@@ -2955,91 +2955,7 @@ var Er = {
|
|
|
2955
2955
|
"oAuth2",
|
|
2956
2956
|
"none"
|
|
2957
2957
|
]), { ...Er };
|
|
2958
|
-
|
|
2959
|
-
try {
|
|
2960
|
-
e();
|
|
2961
|
-
} catch {}
|
|
2962
|
-
}
|
|
2963
|
-
$([
|
|
2964
|
-
"arrow",
|
|
2965
|
-
"avro",
|
|
2966
|
-
"dtv",
|
|
2967
|
-
"json",
|
|
2968
|
-
"jsonl",
|
|
2969
|
-
"markdown",
|
|
2970
|
-
"ods",
|
|
2971
|
-
"parquet",
|
|
2972
|
-
"sav",
|
|
2973
|
-
"sqlite",
|
|
2974
|
-
"xlsx",
|
|
2975
|
-
"xml"
|
|
2976
|
-
]), { ...Er };
|
|
2977
|
-
async function Or(e, t, n) {
|
|
2978
|
-
let r = kr(e), { issues: i, parsedRecords: a, valueDelimiterId: o } = await Ar(e, t.valueDelimiterIds, t.isComplete, n);
|
|
2979
|
-
return {
|
|
2980
|
-
issues: i,
|
|
2981
|
-
parsedRecords: a,
|
|
2982
|
-
recordDelimiterId: r,
|
|
2983
|
-
valueDelimiterId: o
|
|
2984
|
-
};
|
|
2985
|
-
}
|
|
2986
|
-
function kr(e) {
|
|
2987
|
-
let t = (e.match(/\r\n/g) ?? []).length, n = (e.match(/(?<!\r)\n/g) ?? []).length, r = (e.match(/\r(?!\n)/g) ?? []).length;
|
|
2988
|
-
return t >= n && t >= r ? "\r\n" : n >= t && n >= r ? "\n" : r >= t && r >= n ? "\r" : "\n";
|
|
2989
|
-
}
|
|
2990
|
-
async function Ar(e, t, n, r) {
|
|
2991
|
-
let i, a, o, s = [], c, l = !1;
|
|
2992
|
-
for (let u of t) {
|
|
2993
|
-
let { issues: t, records: d } = await r(e, u, n);
|
|
2994
|
-
if (t.length > 0) {
|
|
2995
|
-
c = jr(c, {
|
|
2996
|
-
delimiter: u,
|
|
2997
|
-
issues: t,
|
|
2998
|
-
records: d
|
|
2999
|
-
});
|
|
3000
|
-
continue;
|
|
3001
|
-
}
|
|
3002
|
-
if (l = !0, d.length === 0) continue;
|
|
3003
|
-
let { averageValueCount: f, sumOfValueCountDiffs: p } = Mr(d);
|
|
3004
|
-
(!o || p <= o) && (!a || f > a) && (i = u, a = f, o = p, s = d);
|
|
3005
|
-
}
|
|
3006
|
-
if (!l && c != null) {
|
|
3007
|
-
let { delimiter: e, issues: t, records: n } = c;
|
|
3008
|
-
return {
|
|
3009
|
-
issues: t,
|
|
3010
|
-
parsedRecords: n,
|
|
3011
|
-
valueDelimiterId: Nr(n) ? e : void 0
|
|
3012
|
-
};
|
|
3013
|
-
}
|
|
3014
|
-
return {
|
|
3015
|
-
issues: [],
|
|
3016
|
-
parsedRecords: s,
|
|
3017
|
-
valueDelimiterId: i != null && Nr(s) ? i : void 0
|
|
3018
|
-
};
|
|
3019
|
-
}
|
|
3020
|
-
function jr(e, t) {
|
|
3021
|
-
return e == null || t.issues.length < e.issues.length ? t : e;
|
|
3022
|
-
}
|
|
3023
|
-
function Mr(e) {
|
|
3024
|
-
let t = 0, n = 0, r;
|
|
3025
|
-
for (let i of e) r != null && (n += Math.abs(i.length - r)), r = i.length, t += i.length;
|
|
3026
|
-
return {
|
|
3027
|
-
averageValueCount: t / e.length,
|
|
3028
|
-
sumOfValueCountDiffs: n
|
|
3029
|
-
};
|
|
3030
|
-
}
|
|
3031
|
-
function Nr(e) {
|
|
3032
|
-
let t = /* @__PURE__ */ new Map();
|
|
3033
|
-
for (let n of e) t.set(n.length, (t.get(n.length) ?? 0) + 1);
|
|
3034
|
-
let [n = 0, r = 0] = [...t].toSorted((e, t) => t[1] - e[1])[0] ?? [];
|
|
3035
|
-
return n > 1 && r * 2 > e.length;
|
|
3036
|
-
}
|
|
3037
|
-
$(["list"]), { ...Er }, $([
|
|
3038
|
-
"list",
|
|
3039
|
-
"render",
|
|
3040
|
-
"setColorMode"
|
|
3041
|
-
]), { ...Er };
|
|
3042
|
-
var Pr = {
|
|
2958
|
+
var Dr = {
|
|
3043
2959
|
ascii: {
|
|
3044
2960
|
id: "ascii",
|
|
3045
2961
|
groupId: null,
|
|
@@ -3471,12 +3387,96 @@ var Pr = {
|
|
|
3471
3387
|
decoderId: "windows-1257"
|
|
3472
3388
|
}
|
|
3473
3389
|
};
|
|
3390
|
+
function Or(e) {
|
|
3391
|
+
return Object.hasOwn(Dr, e);
|
|
3392
|
+
}
|
|
3393
|
+
function kr(e) {
|
|
3394
|
+
return Or(e) ? Dr[e].decoderId ?? e : e;
|
|
3395
|
+
}
|
|
3396
|
+
function Ar(e) {
|
|
3397
|
+
try {
|
|
3398
|
+
e();
|
|
3399
|
+
} catch {}
|
|
3400
|
+
}
|
|
3401
|
+
$([
|
|
3402
|
+
"arrow",
|
|
3403
|
+
"avro",
|
|
3404
|
+
"dtv",
|
|
3405
|
+
"json",
|
|
3406
|
+
"jsonl",
|
|
3407
|
+
"markdown",
|
|
3408
|
+
"ods",
|
|
3409
|
+
"parquet",
|
|
3410
|
+
"sav",
|
|
3411
|
+
"sqlite",
|
|
3412
|
+
"xlsx",
|
|
3413
|
+
"xml"
|
|
3414
|
+
]), { ...Er };
|
|
3415
|
+
async function jr(e, t, n) {
|
|
3416
|
+
let r = Mr(e), { issues: i, parsedRecords: a, valueDelimiterId: o } = await Nr(e, t.valueDelimiterIds, t.isComplete, n);
|
|
3417
|
+
return {
|
|
3418
|
+
issues: i,
|
|
3419
|
+
parsedRecords: a,
|
|
3420
|
+
recordDelimiterId: r,
|
|
3421
|
+
valueDelimiterId: o
|
|
3422
|
+
};
|
|
3423
|
+
}
|
|
3424
|
+
function Mr(e) {
|
|
3425
|
+
let t = (e.match(/\r\n/g) ?? []).length, n = (e.match(/(?<!\r)\n/g) ?? []).length, r = (e.match(/\r(?!\n)/g) ?? []).length;
|
|
3426
|
+
return t >= n && t >= r ? "\r\n" : n >= t && n >= r ? "\n" : r >= t && r >= n ? "\r" : "\n";
|
|
3427
|
+
}
|
|
3428
|
+
async function Nr(e, t, n, r) {
|
|
3429
|
+
let i, a, o, s = [], c, l = !1;
|
|
3430
|
+
for (let u of t) {
|
|
3431
|
+
let { issues: t, records: d } = await r(e, u, n);
|
|
3432
|
+
if (t.length > 0) {
|
|
3433
|
+
c = Pr(c, {
|
|
3434
|
+
delimiter: u,
|
|
3435
|
+
issues: t,
|
|
3436
|
+
records: d
|
|
3437
|
+
});
|
|
3438
|
+
continue;
|
|
3439
|
+
}
|
|
3440
|
+
if (l = !0, d.length === 0) continue;
|
|
3441
|
+
let { averageValueCount: f, sumOfValueCountDiffs: p } = Fr(d);
|
|
3442
|
+
(a === void 0 || a <= 1 || p <= (o ?? 0)) && (a === void 0 || f > a) && (i = u, a = f, o = p, s = d);
|
|
3443
|
+
}
|
|
3444
|
+
if (!l && c != null) {
|
|
3445
|
+
let { delimiter: e, issues: t, records: n } = c;
|
|
3446
|
+
return {
|
|
3447
|
+
issues: t,
|
|
3448
|
+
parsedRecords: n,
|
|
3449
|
+
valueDelimiterId: Ir(n) ? e : void 0
|
|
3450
|
+
};
|
|
3451
|
+
}
|
|
3452
|
+
return {
|
|
3453
|
+
issues: [],
|
|
3454
|
+
parsedRecords: s,
|
|
3455
|
+
valueDelimiterId: i != null && Ir(s) ? i : void 0
|
|
3456
|
+
};
|
|
3457
|
+
}
|
|
3458
|
+
function Pr(e, t) {
|
|
3459
|
+
return e == null || t.issues.length < e.issues.length ? t : e;
|
|
3460
|
+
}
|
|
3474
3461
|
function Fr(e) {
|
|
3475
|
-
|
|
3462
|
+
let t = 0, n = 0, r;
|
|
3463
|
+
for (let i of e) r != null && (n += Math.abs(i.length - r)), r = i.length, t += i.length;
|
|
3464
|
+
return {
|
|
3465
|
+
averageValueCount: t / e.length,
|
|
3466
|
+
sumOfValueCountDiffs: n
|
|
3467
|
+
};
|
|
3476
3468
|
}
|
|
3477
3469
|
function Ir(e) {
|
|
3478
|
-
|
|
3470
|
+
let t = /* @__PURE__ */ new Map();
|
|
3471
|
+
for (let n of e) t.set(n.length, (t.get(n.length) ?? 0) + 1);
|
|
3472
|
+
let [n = 0, r = 0] = [...t].toSorted((e, t) => t[1] - e[1])[0] ?? [];
|
|
3473
|
+
return n > 1 && r * 2 > e.length;
|
|
3479
3474
|
}
|
|
3475
|
+
$(["list"]), { ...Er }, $([
|
|
3476
|
+
"list",
|
|
3477
|
+
"render",
|
|
3478
|
+
"setColorMode"
|
|
3479
|
+
]), { ...Er };
|
|
3480
3480
|
// src/index.ts
|
|
3481
3481
|
var Lr = {
|
|
3482
3482
|
bom: !1,
|
|
@@ -3507,14 +3507,14 @@ var Lr = {
|
|
|
3507
3507
|
skip_records_with_error: !1,
|
|
3508
3508
|
to_line: -1,
|
|
3509
3509
|
trim: !1
|
|
3510
|
-
}, Rr = 4, zr =
|
|
3510
|
+
}, Rr = 4, zr = 1048576, Br = 50, Vr = 1e4, Hr = class {
|
|
3511
3511
|
async parseStream(e, t, n) {
|
|
3512
3512
|
return new Promise((r, i) => {
|
|
3513
3513
|
let a, o, s, c = !1, l = !1, u = () => {
|
|
3514
3514
|
if (l) return;
|
|
3515
3515
|
l = !0;
|
|
3516
3516
|
let e = a;
|
|
3517
|
-
a = void 0, s = void 0, e != null && (
|
|
3517
|
+
a = void 0, s = void 0, e != null && (Ar(() => e.removeAllListeners()), Ar(() => e.end())), Ar(() => void o?.cancel()), o = void 0;
|
|
3518
3518
|
}, d = (e) => {
|
|
3519
3519
|
c || (c = !0, u(), i(e instanceof Error ? e : Error(String(e))));
|
|
3520
3520
|
};
|
|
@@ -3530,9 +3530,9 @@ var Lr = {
|
|
|
3530
3530
|
delimiter: t.valueDelimiterId,
|
|
3531
3531
|
relax_column_count: !0
|
|
3532
3532
|
});
|
|
3533
|
-
let i =
|
|
3533
|
+
let i = Gr({
|
|
3534
3534
|
chunk: n,
|
|
3535
|
-
chunkSize: t.chunkSize ??
|
|
3535
|
+
chunkSize: t.chunkSize ?? Vr
|
|
3536
3536
|
});
|
|
3537
3537
|
s = i, a.on("readable", () => {
|
|
3538
3538
|
try {
|
|
@@ -3556,14 +3556,12 @@ var Lr = {
|
|
|
3556
3556
|
}
|
|
3557
3557
|
};
|
|
3558
3558
|
a.on("end", () => {
|
|
3559
|
-
c || (i.flush(), l(
|
|
3559
|
+
c || (i.flush(), l(Kr(a)));
|
|
3560
3560
|
}), o = e.getReader();
|
|
3561
|
-
let u = new TextDecoder(
|
|
3561
|
+
let u = new TextDecoder(kr(t.encodingId)), f = 0, p = !1, m = await o.read();
|
|
3562
3562
|
for (; !m.done;) {
|
|
3563
3563
|
if (c) return;
|
|
3564
|
-
t.abortSignal.throwIfAborted(), f += m.value.length;
|
|
3565
|
-
let e = u.decode(m.value, { stream: !0 });
|
|
3566
|
-
e.length > 0 && (p = !0, a.write(e) || await Hr(a)), await i.drain(), m = await o.read();
|
|
3564
|
+
t.abortSignal.throwIfAborted(), f += m.value.length, await Ur(a, u, m.value, i) > 0 && (p = !0), m = await o.read();
|
|
3567
3565
|
}
|
|
3568
3566
|
if (c) return;
|
|
3569
3567
|
let h = u.decode();
|
|
@@ -3581,17 +3579,25 @@ var Lr = {
|
|
|
3581
3579
|
});
|
|
3582
3580
|
}
|
|
3583
3581
|
async parseText(e, t) {
|
|
3584
|
-
return await
|
|
3582
|
+
return await jr(e, t, qr);
|
|
3585
3583
|
}
|
|
3586
3584
|
};
|
|
3587
|
-
function
|
|
3585
|
+
async function Ur(e, t, n, r) {
|
|
3586
|
+
let i = 0;
|
|
3587
|
+
for (let a = 0; a < n.length; a += zr) {
|
|
3588
|
+
let o = t.decode(n.subarray(a, a + zr), { stream: !0 });
|
|
3589
|
+
o.length > 0 && (i += o.length, e.write(o) || await Wr(e)), await r.drain();
|
|
3590
|
+
}
|
|
3591
|
+
return i;
|
|
3592
|
+
}
|
|
3593
|
+
function Wr(e) {
|
|
3588
3594
|
return new Promise((t) => {
|
|
3589
3595
|
e.once("drain", () => {
|
|
3590
3596
|
t();
|
|
3591
3597
|
});
|
|
3592
3598
|
});
|
|
3593
3599
|
}
|
|
3594
|
-
function
|
|
3600
|
+
function Gr(e) {
|
|
3595
3601
|
let t = Math.max(1, Math.floor(e.chunkSize)), n = [], r = [], i = s(), a = 0, o = () => {
|
|
3596
3602
|
if (a === 0) return;
|
|
3597
3603
|
let t = i;
|
|
@@ -3615,7 +3621,7 @@ function Ur(e) {
|
|
|
3615
3621
|
return r.length = 0, r;
|
|
3616
3622
|
}
|
|
3617
3623
|
}
|
|
3618
|
-
function
|
|
3624
|
+
function Kr(e) {
|
|
3619
3625
|
return {
|
|
3620
3626
|
byteCount: e?.info.bytes ?? -1,
|
|
3621
3627
|
commentLineCount: e?.info.comment_lines ?? -1,
|
|
@@ -3625,10 +3631,10 @@ function Wr(e) {
|
|
|
3625
3631
|
recordCount: e?.info.records ?? -1
|
|
3626
3632
|
};
|
|
3627
3633
|
}
|
|
3628
|
-
function
|
|
3634
|
+
function qr(e, t, n) {
|
|
3629
3635
|
return new Promise((r) => {
|
|
3630
3636
|
let i = [], a = [], o = 0, s = (e) => {
|
|
3631
|
-
e == null || !n && e.code === "CSV_QUOTE_NOT_CLOSED" || (i.push(
|
|
3637
|
+
e == null || !n && e.code === "CSV_QUOTE_NOT_CLOSED" || (i.push(Jr(e, o + 1)), e.lines != null && (o = e.lines));
|
|
3632
3638
|
}, c = ar({
|
|
3633
3639
|
...Lr,
|
|
3634
3640
|
cast: (e, t) => ({
|
|
@@ -3658,7 +3664,7 @@ function Gr(e, t, n) {
|
|
|
3658
3664
|
}), c.write(e), c.end();
|
|
3659
3665
|
});
|
|
3660
3666
|
}
|
|
3661
|
-
function
|
|
3667
|
+
function Jr(e, t) {
|
|
3662
3668
|
let n = e.lines, r = e.code === "CSV_INVALID_CLOSING_QUOTE" ? /got "(.*?)" at line/u.exec(e.message)?.[1] : void 0, i = typeof e.field == "string" ? e.field : r;
|
|
3663
3669
|
return {
|
|
3664
3670
|
endLineNumber: n != null && n > t ? n : void 0,
|
|
@@ -3668,7 +3674,7 @@ function Kr(e, t) {
|
|
|
3668
3674
|
message: e.message,
|
|
3669
3675
|
recordNumber: e.records == null ? void 0 : e.records + 1,
|
|
3670
3676
|
severityId: "error",
|
|
3671
|
-
value: i != null && i.length >
|
|
3677
|
+
value: i != null && i.length > Br ? `${i.slice(0, Br)}…` : i
|
|
3672
3678
|
};
|
|
3673
3679
|
}
|
|
3674
|
-
export {
|
|
3680
|
+
export { Hr as Tool };
|