@datapos/datapos-tool-csv-parse 0.0.85 → 0.0.87
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.
|
@@ -31,10 +31,10 @@ function Ze(t) {
|
|
|
31
31
|
return n === 1 ? (e = t[r - 1], i += P[e >> 2], i += P[e << 4 & 63], i += "==") : n === 2 && (e = (t[r - 2] << 8) + t[r - 1], i += P[e >> 10], i += P[e >> 4 & 63], i += P[e << 2 & 63], i += "="), o.push(i), o.join("");
|
|
32
32
|
}
|
|
33
33
|
function ve(t, e, r, n, i) {
|
|
34
|
-
var o, s, f = i * 8 - n - 1, a = (1 << f) - 1, l = a >> 1,
|
|
35
|
-
for (
|
|
34
|
+
var o, s, f = i * 8 - n - 1, a = (1 << f) - 1, l = a >> 1, c = -7, h = r ? i - 1 : 0, p = r ? -1 : 1, m = t[e + h];
|
|
35
|
+
for (h += p, o = m & (1 << -c) - 1, m >>= -c, c += f; c > 0; o = o * 256 + t[e + h], h += p, c -= 8)
|
|
36
36
|
;
|
|
37
|
-
for (s = o & (1 << -
|
|
37
|
+
for (s = o & (1 << -c) - 1, o >>= -c, c += n; c > 0; s = s * 256 + t[e + h], h += p, c -= 8)
|
|
38
38
|
;
|
|
39
39
|
if (o === 0)
|
|
40
40
|
o = 1 - l;
|
|
@@ -46,8 +46,8 @@ function ve(t, e, r, n, i) {
|
|
|
46
46
|
return (m ? -1 : 1) * s * Math.pow(2, o - n);
|
|
47
47
|
}
|
|
48
48
|
function ht(t, e, r, n, i, o) {
|
|
49
|
-
var s, f, a, l = o * 8 - i - 1,
|
|
50
|
-
for (e = Math.abs(e), isNaN(e) || e === 1 / 0 ? (f = isNaN(e) ? 1 : 0, s =
|
|
49
|
+
var s, f, a, l = o * 8 - i - 1, c = (1 << l) - 1, h = c >> 1, p = i === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, m = n ? 0 : o - 1, x = n ? 1 : -1, y = e < 0 || e === 0 && 1 / e < 0 ? 1 : 0;
|
|
50
|
+
for (e = Math.abs(e), isNaN(e) || e === 1 / 0 ? (f = isNaN(e) ? 1 : 0, s = c) : (s = Math.floor(Math.log(e) / Math.LN2), e * (a = Math.pow(2, -s)) < 1 && (s--, a *= 2), s + h >= 1 ? e += p / a : e += p * Math.pow(2, 1 - h), e * a >= 2 && (s++, a /= 2), s + h >= c ? (f = 0, s = c) : s + h >= 1 ? (f = (e * a - 1) * Math.pow(2, i), s = s + h) : (f = e * Math.pow(2, h - 1) * Math.pow(2, i), s = 0)); i >= 8; t[r + m] = f & 255, m += x, f /= 256, i -= 8)
|
|
51
51
|
;
|
|
52
52
|
for (s = s << i | f, l += i; l > 0; t[r + m] = s & 255, m += x, s /= 256, l -= 8)
|
|
53
53
|
;
|
|
@@ -320,9 +320,9 @@ u.prototype.compare = function(e, r, n, i, o) {
|
|
|
320
320
|
if (r >= n)
|
|
321
321
|
return 1;
|
|
322
322
|
if (r >>>= 0, n >>>= 0, i >>>= 0, o >>>= 0, this === e) return 0;
|
|
323
|
-
for (var s = o - i, f = n - r, a = Math.min(s, f), l = this.slice(i, o),
|
|
324
|
-
if (l[
|
|
325
|
-
s = l[
|
|
323
|
+
for (var s = o - i, f = n - r, a = Math.min(s, f), l = this.slice(i, o), c = e.slice(r, n), h = 0; h < a; ++h)
|
|
324
|
+
if (l[h] !== c[h]) {
|
|
325
|
+
s = l[h], f = c[h];
|
|
326
326
|
break;
|
|
327
327
|
}
|
|
328
328
|
return s < f ? -1 : f < s ? 1 : 0;
|
|
@@ -353,20 +353,20 @@ function Xe(t, e, r, n, i) {
|
|
|
353
353
|
}
|
|
354
354
|
var l;
|
|
355
355
|
if (i) {
|
|
356
|
-
var
|
|
356
|
+
var c = -1;
|
|
357
357
|
for (l = r; l < s; l++)
|
|
358
|
-
if (a(t, l) === a(e,
|
|
359
|
-
if (
|
|
358
|
+
if (a(t, l) === a(e, c === -1 ? 0 : l - c)) {
|
|
359
|
+
if (c === -1 && (c = l), l - c + 1 === f) return c * o;
|
|
360
360
|
} else
|
|
361
|
-
|
|
361
|
+
c !== -1 && (l -= l - c), c = -1;
|
|
362
362
|
} else
|
|
363
363
|
for (r + f > s && (r = s - f), l = r; l >= 0; l--) {
|
|
364
|
-
for (var
|
|
364
|
+
for (var h = !0, p = 0; p < f; p++)
|
|
365
365
|
if (a(t, l + p) !== a(e, p)) {
|
|
366
|
-
|
|
366
|
+
h = !1;
|
|
367
367
|
break;
|
|
368
368
|
}
|
|
369
|
-
if (
|
|
369
|
+
if (h) return l;
|
|
370
370
|
}
|
|
371
371
|
return -1;
|
|
372
372
|
}
|
|
@@ -461,19 +461,19 @@ function yt(t, e, r) {
|
|
|
461
461
|
for (var n = [], i = e; i < r; ) {
|
|
462
462
|
var o = t[i], s = null, f = o > 239 ? 4 : o > 223 ? 3 : o > 191 ? 2 : 1;
|
|
463
463
|
if (i + f <= r) {
|
|
464
|
-
var a, l,
|
|
464
|
+
var a, l, c, h;
|
|
465
465
|
switch (f) {
|
|
466
466
|
case 1:
|
|
467
467
|
o < 128 && (s = o);
|
|
468
468
|
break;
|
|
469
469
|
case 2:
|
|
470
|
-
a = t[i + 1], (a & 192) === 128 && (
|
|
470
|
+
a = t[i + 1], (a & 192) === 128 && (h = (o & 31) << 6 | a & 63, h > 127 && (s = h));
|
|
471
471
|
break;
|
|
472
472
|
case 3:
|
|
473
|
-
a = t[i + 1], l = t[i + 2], (a & 192) === 128 && (l & 192) === 128 && (
|
|
473
|
+
a = t[i + 1], l = t[i + 2], (a & 192) === 128 && (l & 192) === 128 && (h = (o & 15) << 12 | (a & 63) << 6 | l & 63, h > 2047 && (h < 55296 || h > 57343) && (s = h));
|
|
474
474
|
break;
|
|
475
475
|
case 4:
|
|
476
|
-
a = t[i + 1], l = t[i + 2],
|
|
476
|
+
a = t[i + 1], l = t[i + 2], c = t[i + 3], (a & 192) === 128 && (l & 192) === 128 && (c & 192) === 128 && (h = (o & 15) << 18 | (a & 63) << 12 | (l & 63) << 6 | c & 63, h > 65535 && h < 1114112 && (s = h));
|
|
477
477
|
}
|
|
478
478
|
}
|
|
479
479
|
s === null ? (s = 65533, f = 1) : s > 65535 && (s -= 65536, n.push(s >>> 10 & 1023 | 55296), s = 56320 | s & 1023), n.push(s), i += f;
|
|
@@ -929,33 +929,33 @@ g.prototype.emit = function(e) {
|
|
|
929
929
|
else {
|
|
930
930
|
if (r instanceof Error)
|
|
931
931
|
throw r;
|
|
932
|
-
var
|
|
933
|
-
throw
|
|
932
|
+
var c = new Error('Uncaught, unspecified "error" event. (' + r + ")");
|
|
933
|
+
throw c.context = r, c;
|
|
934
934
|
}
|
|
935
935
|
return !1;
|
|
936
936
|
}
|
|
937
937
|
if (n = f[e], !n)
|
|
938
938
|
return !1;
|
|
939
|
-
var
|
|
939
|
+
var h = typeof n == "function";
|
|
940
940
|
switch (i = arguments.length, i) {
|
|
941
941
|
// fast cases
|
|
942
942
|
case 1:
|
|
943
|
-
Ir(n,
|
|
943
|
+
Ir(n, h, this);
|
|
944
944
|
break;
|
|
945
945
|
case 2:
|
|
946
|
-
Cr(n,
|
|
946
|
+
Cr(n, h, this, arguments[1]);
|
|
947
947
|
break;
|
|
948
948
|
case 3:
|
|
949
|
-
Or(n,
|
|
949
|
+
Or(n, h, this, arguments[1], arguments[2]);
|
|
950
950
|
break;
|
|
951
951
|
case 4:
|
|
952
|
-
Ar(n,
|
|
952
|
+
Ar(n, h, this, arguments[1], arguments[2], arguments[3]);
|
|
953
953
|
break;
|
|
954
954
|
// slower
|
|
955
955
|
default:
|
|
956
956
|
for (o = new Array(i - 1), s = 1; s < i; s++)
|
|
957
957
|
o[s - 1] = arguments[s];
|
|
958
|
-
Tr(n,
|
|
958
|
+
Tr(n, h, this, o);
|
|
959
959
|
}
|
|
960
960
|
return !0;
|
|
961
961
|
};
|
|
@@ -1306,20 +1306,20 @@ function ye(t, e, r) {
|
|
|
1306
1306
|
if (Le(e))
|
|
1307
1307
|
return Ae(e);
|
|
1308
1308
|
}
|
|
1309
|
-
var a = "", l = !1,
|
|
1310
|
-
if (Yr(e) && (l = !0,
|
|
1311
|
-
var
|
|
1312
|
-
a = " [Function" +
|
|
1309
|
+
var a = "", l = !1, c = ["{", "}"];
|
|
1310
|
+
if (Yr(e) && (l = !0, c = ["[", "]"]), De(e)) {
|
|
1311
|
+
var h = e.name ? ": " + e.name : "";
|
|
1312
|
+
a = " [Function" + h + "]";
|
|
1313
1313
|
}
|
|
1314
1314
|
if (Te(e) && (a = " " + RegExp.prototype.toString.call(e)), et(e) && (a = " " + Date.prototype.toUTCString.call(e)), Le(e) && (a = " " + Ae(e)), o.length === 0 && (!l || e.length == 0))
|
|
1315
|
-
return
|
|
1315
|
+
return c[0] + a + c[1];
|
|
1316
1316
|
if (r < 0)
|
|
1317
1317
|
return Te(e) ? t.stylize(RegExp.prototype.toString.call(e), "regexp") : t.stylize("[Object]", "special");
|
|
1318
1318
|
t.seen.push(e);
|
|
1319
1319
|
var p;
|
|
1320
1320
|
return l ? p = Vr(t, e, r, s, o) : p = o.map(function(m) {
|
|
1321
1321
|
return Pe(t, e, r, s, m, l);
|
|
1322
|
-
}), t.seen.pop(), Jr(p, a,
|
|
1322
|
+
}), t.seen.pop(), Jr(p, a, c);
|
|
1323
1323
|
}
|
|
1324
1324
|
function zr(t, e) {
|
|
1325
1325
|
if (Q(e))
|
|
@@ -1686,10 +1686,10 @@ C.prototype.pipe = function(t, e) {
|
|
|
1686
1686
|
break;
|
|
1687
1687
|
}
|
|
1688
1688
|
n.pipesCount += 1, E("pipe count=%d opts=%j", n.pipesCount, e);
|
|
1689
|
-
var i = !e || e.end !== !1, o = i ? f :
|
|
1689
|
+
var i = !e || e.end !== !1, o = i ? f : c;
|
|
1690
1690
|
n.endEmitted ? U(o) : r.once("end", o), t.on("unpipe", s);
|
|
1691
1691
|
function s(I) {
|
|
1692
|
-
E("onunpipe"), I === r &&
|
|
1692
|
+
E("onunpipe"), I === r && c();
|
|
1693
1693
|
}
|
|
1694
1694
|
function f() {
|
|
1695
1695
|
E("onend"), t.end();
|
|
@@ -1697,15 +1697,15 @@ C.prototype.pipe = function(t, e) {
|
|
|
1697
1697
|
var a = un(r);
|
|
1698
1698
|
t.on("drain", a);
|
|
1699
1699
|
var l = !1;
|
|
1700
|
-
function
|
|
1701
|
-
E("cleanup"), t.removeListener("close", x), t.removeListener("finish", y), t.removeListener("drain", a), t.removeListener("error", m), t.removeListener("unpipe", s), r.removeListener("end", f), r.removeListener("end",
|
|
1700
|
+
function c() {
|
|
1701
|
+
E("cleanup"), t.removeListener("close", x), t.removeListener("finish", y), t.removeListener("drain", a), t.removeListener("error", m), t.removeListener("unpipe", s), r.removeListener("end", f), r.removeListener("end", c), r.removeListener("data", p), l = !0, n.awaitDrain && (!t._writableState || t._writableState.needDrain) && a();
|
|
1702
1702
|
}
|
|
1703
|
-
var
|
|
1703
|
+
var h = !1;
|
|
1704
1704
|
r.on("data", p);
|
|
1705
1705
|
function p(I) {
|
|
1706
|
-
E("ondata"),
|
|
1706
|
+
E("ondata"), h = !1;
|
|
1707
1707
|
var v = t.write(I);
|
|
1708
|
-
v === !1 && !
|
|
1708
|
+
v === !1 && !h && ((n.pipesCount === 1 && n.pipes === t || n.pipesCount > 1 && $t(n.pipes, t) !== -1) && !l && (E("false write response, pause", r._readableState.awaitDrain), r._readableState.awaitDrain++, h = !0), r.pause());
|
|
1709
1709
|
}
|
|
1710
1710
|
function m(I) {
|
|
1711
1711
|
E("onerror", I), S(), t.removeListener("error", m), tn(t, "error") === 0 && t.emit("error", I);
|
|
@@ -1960,8 +1960,8 @@ function jt(t, e) {
|
|
|
1960
1960
|
$e(t, e, !0, e.length, i, "", o.finish), e.pendingcb++, e.lastBufferedRequest = null, o.next ? (e.corkedRequestsFree = o.next, o.next = null) : e.corkedRequestsFree = new Vt(e);
|
|
1961
1961
|
} else {
|
|
1962
1962
|
for (; r; ) {
|
|
1963
|
-
var f = r.chunk, a = r.encoding, l = r.callback,
|
|
1964
|
-
if ($e(t, e, !1,
|
|
1963
|
+
var f = r.chunk, a = r.encoding, l = r.callback, c = e.objectMode ? 1 : f.length;
|
|
1964
|
+
if ($e(t, e, !1, c, f, a, l), r = r.next, e.writing)
|
|
1965
1965
|
break;
|
|
1966
1966
|
}
|
|
1967
1967
|
r === null && (e.lastBufferedRequest = null);
|
|
@@ -2085,8 +2085,8 @@ function V() {
|
|
|
2085
2085
|
}
|
|
2086
2086
|
V.prototype.pipe = function(t, e) {
|
|
2087
2087
|
var r = this;
|
|
2088
|
-
function n(
|
|
2089
|
-
t.writable && t.write(
|
|
2088
|
+
function n(c) {
|
|
2089
|
+
t.writable && t.write(c) === !1 && r.pause && r.pause();
|
|
2090
2090
|
}
|
|
2091
2091
|
r.on("data", n);
|
|
2092
2092
|
function i() {
|
|
@@ -2100,9 +2100,9 @@ V.prototype.pipe = function(t, e) {
|
|
|
2100
2100
|
function f() {
|
|
2101
2101
|
o || (o = !0, typeof t.destroy == "function" && t.destroy());
|
|
2102
2102
|
}
|
|
2103
|
-
function a(
|
|
2103
|
+
function a(c) {
|
|
2104
2104
|
if (l(), g.listenerCount(this, "error") === 0)
|
|
2105
|
-
throw
|
|
2105
|
+
throw c;
|
|
2106
2106
|
}
|
|
2107
2107
|
r.on("error", a), t.on("error", a);
|
|
2108
2108
|
function l() {
|
|
@@ -2665,20 +2665,20 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
|
|
|
2665
2665
|
state: kn(r),
|
|
2666
2666
|
__needMoreData: function(n, i, o) {
|
|
2667
2667
|
if (o) return !1;
|
|
2668
|
-
const { encoding: s, escape: f, quote: a } = this.options, { quoting: l, needMoreDataSize:
|
|
2669
|
-
|
|
2668
|
+
const { encoding: s, escape: f, quote: a } = this.options, { quoting: l, needMoreDataSize: c, recordDelimiterMaxLength: h } = this.state, p = i - n - 1, m = Math.max(
|
|
2669
|
+
c,
|
|
2670
2670
|
// Skip if the remaining buffer smaller than record delimiter
|
|
2671
2671
|
// If "record_delimiter" is yet to be discovered:
|
|
2672
2672
|
// 1. It is equals to `[]` and "recordDelimiterMaxLength" equals `0`
|
|
2673
2673
|
// 2. We set the length to windows line ending in the current encoding
|
|
2674
2674
|
// Note, that encoding is known from user or bom discovery at that point
|
|
2675
2675
|
// recordDelimiterMaxLength,
|
|
2676
|
-
|
|
2677
|
-
`, s).length :
|
|
2676
|
+
h === 0 ? u.from(`\r
|
|
2677
|
+
`, s).length : h,
|
|
2678
2678
|
// Skip if remaining buffer can be an escaped quote
|
|
2679
2679
|
l ? (f === null ? 0 : f.length) + a.length : 0,
|
|
2680
2680
|
// Skip if remaining buffer can be record delimiter following the closing quote
|
|
2681
|
-
l ? a.length +
|
|
2681
|
+
l ? a.length + h : 0
|
|
2682
2682
|
);
|
|
2683
2683
|
return p < m;
|
|
2684
2684
|
},
|
|
@@ -2688,8 +2688,8 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
|
|
|
2688
2688
|
bom: f,
|
|
2689
2689
|
comment_no_infix: a,
|
|
2690
2690
|
encoding: l,
|
|
2691
|
-
from_line:
|
|
2692
|
-
ltrim:
|
|
2691
|
+
from_line: c,
|
|
2692
|
+
ltrim: h,
|
|
2693
2693
|
max_record_size: p,
|
|
2694
2694
|
raw: m,
|
|
2695
2695
|
relax_quotes: x,
|
|
@@ -2822,7 +2822,7 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
|
|
|
2822
2822
|
if (this.state.commenting && this.state.wasQuoting === !1 && this.state.record.length === 0 && this.state.field.length === 0)
|
|
2823
2823
|
this.info.comment_lines++;
|
|
2824
2824
|
else {
|
|
2825
|
-
if (this.state.enabled === !1 && this.info.lines + (this.state.wasRowDelimiter === !0 ? 1 : 0) >=
|
|
2825
|
+
if (this.state.enabled === !1 && this.info.lines + (this.state.wasRowDelimiter === !0 ? 1 : 0) >= c) {
|
|
2826
2826
|
this.state.enabled = !0, this.__resetField(), this.__resetRecord(), d += A - 1;
|
|
2827
2827
|
continue;
|
|
2828
2828
|
}
|
|
@@ -2874,7 +2874,7 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
|
|
|
2874
2874
|
this.__infoField()
|
|
2875
2875
|
)
|
|
2876
2876
|
);
|
|
2877
|
-
const J =
|
|
2877
|
+
const J = h === !1 || this.state.quoting === !0 || this.state.field.length !== 0 || !this.__isCharTrimable(b, d), he = y === !1 || this.state.wasQuoting === !1;
|
|
2878
2878
|
if (J === !0 && he === !0)
|
|
2879
2879
|
this.state.field.append(O);
|
|
2880
2880
|
else {
|
|
@@ -2928,8 +2928,8 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
|
|
|
2928
2928
|
info: f,
|
|
2929
2929
|
from: a,
|
|
2930
2930
|
relax_column_count: l,
|
|
2931
|
-
relax_column_count_less:
|
|
2932
|
-
relax_column_count_more:
|
|
2931
|
+
relax_column_count_less: c,
|
|
2932
|
+
relax_column_count_more: h,
|
|
2933
2933
|
raw: p,
|
|
2934
2934
|
skip_records_with_empty_values: m
|
|
2935
2935
|
} = this.options, { enabled: x, record: y } = this.state;
|
|
@@ -2970,7 +2970,7 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
|
|
|
2970
2970
|
record: y
|
|
2971
2971
|
}
|
|
2972
2972
|
);
|
|
2973
|
-
if (l === !0 ||
|
|
2973
|
+
if (l === !0 || c === !0 && S < this.state.expectedRecordLength || h === !0 && S > this.state.expectedRecordLength)
|
|
2974
2974
|
this.info.invalid_field_length++, this.state.error = I;
|
|
2975
2975
|
else {
|
|
2976
2976
|
const v = this.__error(I);
|
|
@@ -3068,9 +3068,9 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
|
|
|
3068
3068
|
return this.__resetField();
|
|
3069
3069
|
let l = this.state.field.toString(i);
|
|
3070
3070
|
if (o === !0 && a === !1 && (l = l.trimRight()), n === !0) {
|
|
3071
|
-
const [
|
|
3072
|
-
if (
|
|
3073
|
-
l =
|
|
3071
|
+
const [c, h] = this.__cast(l);
|
|
3072
|
+
if (c !== void 0) return c;
|
|
3073
|
+
l = h;
|
|
3074
3074
|
}
|
|
3075
3075
|
this.state.record.push(l), s !== 0 && typeof l == "string" && (this.state.record_length += l.length), this.__resetField();
|
|
3076
3076
|
},
|
|
@@ -3116,10 +3116,10 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
|
|
|
3116
3116
|
return ((s, f) => {
|
|
3117
3117
|
const { timchars: a } = this.state;
|
|
3118
3118
|
e: for (let l = 0; l < a.length; l++) {
|
|
3119
|
-
const
|
|
3120
|
-
for (let
|
|
3121
|
-
if (h
|
|
3122
|
-
return
|
|
3119
|
+
const c = a[l];
|
|
3120
|
+
for (let h = 0; h < c.length; h++)
|
|
3121
|
+
if (c[h] !== s[f + h]) continue e;
|
|
3122
|
+
return c.length;
|
|
3123
3123
|
}
|
|
3124
3124
|
return 0;
|
|
3125
3125
|
})(n, i);
|
|
@@ -3149,8 +3149,8 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
|
|
|
3149
3149
|
e: for (let a = 0; a < s.length; a++) {
|
|
3150
3150
|
const l = s[a];
|
|
3151
3151
|
if (l[0] === o) {
|
|
3152
|
-
for (let
|
|
3153
|
-
if (l[
|
|
3152
|
+
for (let c = 1; c < l.length; c++)
|
|
3153
|
+
if (l[c] !== n[i + c]) continue e;
|
|
3154
3154
|
return l.length;
|
|
3155
3155
|
}
|
|
3156
3156
|
}
|
|
@@ -3159,10 +3159,10 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
|
|
|
3159
3159
|
__isRecordDelimiter: function(n, i, o) {
|
|
3160
3160
|
const { record_delimiter: s } = this.options, f = s.length;
|
|
3161
3161
|
e: for (let a = 0; a < f; a++) {
|
|
3162
|
-
const l = s[a],
|
|
3162
|
+
const l = s[a], c = l.length;
|
|
3163
3163
|
if (l[0] === n) {
|
|
3164
|
-
for (let
|
|
3165
|
-
if (l[
|
|
3164
|
+
for (let h = 1; h < c; h++)
|
|
3165
|
+
if (l[h] !== i[o + h])
|
|
3166
3166
|
continue e;
|
|
3167
3167
|
return l.length;
|
|
3168
3168
|
}
|
|
@@ -3390,43 +3390,49 @@ class ri {
|
|
|
3390
3390
|
*/
|
|
3391
3391
|
async determineSchemaConfig(e, r, n) {
|
|
3392
3392
|
const i = Xn(r), { records: o, valueDelimiterId: s } = await Kn(r, n);
|
|
3393
|
-
|
|
3393
|
+
console.log("records", o);
|
|
3394
|
+
const f = [], a = [];
|
|
3395
|
+
for (const l of o) {
|
|
3396
|
+
const c = e.parseRecord(a, l, !0);
|
|
3397
|
+
f.push(c);
|
|
3398
|
+
}
|
|
3399
|
+
return { columnConfigs: a, recordDelimiterId: i, records: f, valueDelimiterId: s };
|
|
3394
3400
|
}
|
|
3395
3401
|
/**
|
|
3396
3402
|
* Parse stream.
|
|
3397
3403
|
*/
|
|
3398
3404
|
async parseStream(e, r, n, i, o) {
|
|
3399
3405
|
return new Promise((s, f) => {
|
|
3400
|
-
let a, l,
|
|
3406
|
+
let a, l, c, h = !1, p = !1;
|
|
3401
3407
|
const m = () => {
|
|
3402
3408
|
if (p) return;
|
|
3403
3409
|
p = !0;
|
|
3404
3410
|
const S = a;
|
|
3405
|
-
a = void 0,
|
|
3411
|
+
a = void 0, c = void 0, S != null && (Be(() => S.removeAllListeners()), Be(() => S.end())), Be(() => {
|
|
3406
3412
|
l?.cancel();
|
|
3407
3413
|
}), l = void 0;
|
|
3408
3414
|
};
|
|
3409
3415
|
i.signal.addEventListener("abort", m, { once: !0 });
|
|
3410
3416
|
const x = (S) => {
|
|
3411
|
-
|
|
3417
|
+
h || (h = !0, m(), i.signal.aborted || i.abort(S), f(S));
|
|
3412
3418
|
};
|
|
3413
3419
|
(async () => {
|
|
3414
3420
|
a = je({
|
|
3415
3421
|
...r,
|
|
3416
|
-
cast: (R, F) => ({ value: R,
|
|
3417
|
-
}),
|
|
3422
|
+
cast: (R, F) => ({ value: R, wasValueQuoted: F.quoting })
|
|
3423
|
+
}), c = ei({ chunk: o, chunkSize: e.chunkSize ?? Gn }), a.on("readable", () => {
|
|
3418
3424
|
try {
|
|
3419
|
-
if (a == null ||
|
|
3425
|
+
if (a == null || c == null) return;
|
|
3420
3426
|
let R;
|
|
3421
3427
|
for (; (R = a.read()) != null; ) {
|
|
3422
|
-
if (
|
|
3423
|
-
i.signal.throwIfAborted(),
|
|
3428
|
+
if (h) return;
|
|
3429
|
+
i.signal.throwIfAborted(), c.push(R);
|
|
3424
3430
|
}
|
|
3425
3431
|
} catch (R) {
|
|
3426
3432
|
x(R);
|
|
3427
3433
|
}
|
|
3428
3434
|
}), a.on("error", (R) => x(R)), a.on("end", () => {
|
|
3429
|
-
|
|
3435
|
+
h || (c?.flush(), s(ti(a)));
|
|
3430
3436
|
});
|
|
3431
3437
|
const S = await fetch(encodeURI(n), { signal: i.signal });
|
|
3432
3438
|
if (!S.ok || S.body == null)
|
|
@@ -3435,12 +3441,12 @@ class ri {
|
|
|
3435
3441
|
const I = new TextDecoder(e.encodingId);
|
|
3436
3442
|
let v = await l.read();
|
|
3437
3443
|
for (; !v.done; ) {
|
|
3438
|
-
if (
|
|
3444
|
+
if (h) return;
|
|
3439
3445
|
i.signal.throwIfAborted();
|
|
3440
3446
|
const R = I.decode(v.value, { stream: !0 });
|
|
3441
3447
|
R.length > 0 && a.write(R), v = await l.read();
|
|
3442
3448
|
}
|
|
3443
|
-
if (
|
|
3449
|
+
if (h) return;
|
|
3444
3450
|
const _ = I.decode();
|
|
3445
3451
|
_.length > 0 && a.write(_), a.end();
|
|
3446
3452
|
})().catch((S) => x(S));
|
|
@@ -3458,26 +3464,26 @@ async function Kn(t, e) {
|
|
|
3458
3464
|
let r, n, i, o = [];
|
|
3459
3465
|
for (const s of e)
|
|
3460
3466
|
try {
|
|
3461
|
-
let f = 0, a, l = 0,
|
|
3462
|
-
const
|
|
3463
|
-
cast: (p, m) => ({ value: p,
|
|
3467
|
+
let f = 0, a, l = 0, c = 0;
|
|
3468
|
+
const h = je({
|
|
3469
|
+
cast: (p, m) => ({ value: p, wasValueQuoted: m.quoting }),
|
|
3464
3470
|
delimiter: s,
|
|
3465
3471
|
relax_column_count: !0
|
|
3466
3472
|
});
|
|
3467
3473
|
await new Promise((p) => {
|
|
3468
3474
|
try {
|
|
3469
3475
|
const m = [];
|
|
3470
|
-
|
|
3476
|
+
h.on("readable", () => {
|
|
3471
3477
|
let x;
|
|
3472
|
-
for (; (x =
|
|
3478
|
+
for (; (x = h.read()) != null; ) {
|
|
3473
3479
|
l++;
|
|
3474
3480
|
const y = x.length;
|
|
3475
|
-
a != null && (
|
|
3481
|
+
a != null && (c += Math.abs(y - a)), a = y, f += y, m.push(x);
|
|
3476
3482
|
}
|
|
3477
|
-
}),
|
|
3483
|
+
}), h.on("error", () => p()), h.on("end", () => {
|
|
3478
3484
|
const x = f / l;
|
|
3479
|
-
(!i ||
|
|
3480
|
-
}),
|
|
3485
|
+
(!i || c <= i) && (!n || x > n) && (r = s, n = x, i = c, o = [...m]), p();
|
|
3486
|
+
}), h.write(t), h.end();
|
|
3481
3487
|
} catch {
|
|
3482
3488
|
p();
|
|
3483
3489
|
}
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import { Options as ParseOptions, Parser } from 'csv-parse/browser/esm';
|
|
2
2
|
import { EngineUtilities } from '@datapos/datapos-shared/engine';
|
|
3
|
-
import {
|
|
4
|
-
import { ParseRecord,
|
|
5
|
-
/**
|
|
6
|
-
* Schema configuration.
|
|
7
|
-
*/
|
|
8
|
-
interface SchemaConfig {
|
|
9
|
-
columnConfigs: ConnectionColumnConfig[];
|
|
10
|
-
recordDelimiterId: RecordDelimiterId;
|
|
11
|
-
records: ParseRecord[][];
|
|
12
|
-
valueDelimiterId: ValueDelimiterId;
|
|
13
|
-
}
|
|
3
|
+
import { RetrieveRecordsOptions, RetrieveRecordsSummary } from '@datapos/datapos-shared/component/connector';
|
|
4
|
+
import { ParseRecord, ValueDelimiterId } from '@datapos/datapos-shared/component/dataView';
|
|
14
5
|
/** Tool. */
|
|
15
6
|
declare class Tool {
|
|
16
7
|
/** Build parser. */
|
|
@@ -25,4 +16,4 @@ declare class Tool {
|
|
|
25
16
|
parseStream(retrieveRecordsOptions: RetrieveRecordsOptions, parseOptions: ParseOptions, url: string, abortController: AbortController, chunk: (records: ParseRecord[]) => void): Promise<RetrieveRecordsSummary>;
|
|
26
17
|
}
|
|
27
18
|
export type { Options as ParseOptions, Parser } from 'csv-parse/browser/esm';
|
|
28
|
-
export {
|
|
19
|
+
export { Tool };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datapos/datapos-tool-csv-parse",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.87",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"prettier": "@datapos/datapos-development/prettierrc",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@datapos/datapos-shared": "^0.3.
|
|
29
|
+
"@datapos/datapos-shared": "^0.3.468",
|
|
30
30
|
"csv-parse": "^6.1.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"license-report-check": "^0.1.2",
|
|
48
48
|
"license-report-recursive": "^6.8.2",
|
|
49
49
|
"npm-check-updates": "^19.3.1",
|
|
50
|
-
"owasp-dependency-check": "^1.0.
|
|
50
|
+
"owasp-dependency-check": "^1.0.1",
|
|
51
51
|
"prettier": "^3.7.4",
|
|
52
52
|
"rollup-plugin-visualizer": "^6.0.5",
|
|
53
53
|
"sonda": "^0.10.1",
|