@datapos/datapos-tool-csv-parse 0.0.71 → 0.0.73
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/dist/datapos-tool-csv-parse.es.js +257 -254
- package/dist/types/src/index.d.ts +8 -3
- package/package.json +1 -1
|
@@ -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, h = -7, c = r ? i - 1 : 0, p = r ? -1 : 1, g = t[e + c];
|
|
35
|
+
for (c += p, o = g & (1 << -h) - 1, g >>= -h, h += f; h > 0; o = o * 256 + t[e + c], c += p, h -= 8)
|
|
36
36
|
;
|
|
37
|
-
for (s = o & (1 << -
|
|
37
|
+
for (s = o & (1 << -h) - 1, o >>= -h, h += n; h > 0; s = s * 256 + t[e + c], c += p, h -= 8)
|
|
38
38
|
;
|
|
39
39
|
if (o === 0)
|
|
40
40
|
o = 1 - l;
|
|
@@ -46,12 +46,12 @@ function ve(t, e, r, n, i) {
|
|
|
46
46
|
return (g ? -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, h = (1 << l) - 1, c = h >> 1, p = i === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, g = 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 = h) : (s = Math.floor(Math.log(e) / Math.LN2), e * (a = Math.pow(2, -s)) < 1 && (s--, a *= 2), s + c >= 1 ? e += p / a : e += p * Math.pow(2, 1 - c), e * a >= 2 && (s++, a /= 2), s + c >= h ? (f = 0, s = h) : s + c >= 1 ? (f = (e * a - 1) * Math.pow(2, i), s = s + c) : (f = e * Math.pow(2, c - 1) * Math.pow(2, i), s = 0)); i >= 8; t[r + g] = f & 255, g += x, f /= 256, i -= 8)
|
|
51
51
|
;
|
|
52
|
-
for (s = s << i | f, l += i; l > 0; t[r + g] = s & 255, g +=
|
|
52
|
+
for (s = s << i | f, l += i; l > 0; t[r + g] = s & 255, g += x, s /= 256, l -= 8)
|
|
53
53
|
;
|
|
54
|
-
t[r + g -
|
|
54
|
+
t[r + g - x] |= y * 128;
|
|
55
55
|
}
|
|
56
56
|
var er = {}.toString, dt = Array.isArray || function(t) {
|
|
57
57
|
return er.call(t) == "[object Array]";
|
|
@@ -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), h = e.slice(r, n), c = 0; c < a; ++c)
|
|
324
|
+
if (l[c] !== h[c]) {
|
|
325
|
+
s = l[c], f = h[c];
|
|
326
326
|
break;
|
|
327
327
|
}
|
|
328
328
|
return s < f ? -1 : f < s ? 1 : 0;
|
|
@@ -348,25 +348,25 @@ function Xe(t, e, r, n, i) {
|
|
|
348
348
|
return -1;
|
|
349
349
|
o = 2, s /= 2, f /= 2, r /= 2;
|
|
350
350
|
}
|
|
351
|
-
function a(g,
|
|
352
|
-
return o === 1 ? g[
|
|
351
|
+
function a(g, x) {
|
|
352
|
+
return o === 1 ? g[x] : g.readUInt16BE(x * o);
|
|
353
353
|
}
|
|
354
354
|
var l;
|
|
355
355
|
if (i) {
|
|
356
|
-
var
|
|
356
|
+
var h = -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, h === -1 ? 0 : l - h)) {
|
|
359
|
+
if (h === -1 && (h = l), l - h + 1 === f) return h * o;
|
|
360
360
|
} else
|
|
361
|
-
|
|
361
|
+
h !== -1 && (l -= l - h), h = -1;
|
|
362
362
|
} else
|
|
363
363
|
for (r + f > s && (r = s - f), l = r; l >= 0; l--) {
|
|
364
|
-
for (var
|
|
364
|
+
for (var c = !0, p = 0; p < f; p++)
|
|
365
365
|
if (a(t, l + p) !== a(e, p)) {
|
|
366
|
-
|
|
366
|
+
c = !1;
|
|
367
367
|
break;
|
|
368
368
|
}
|
|
369
|
-
if (
|
|
369
|
+
if (c) 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, h, c;
|
|
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 && (c = (o & 31) << 6 | a & 63, c > 127 && (s = c));
|
|
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 && (c = (o & 15) << 12 | (a & 63) << 6 | l & 63, c > 2047 && (c < 55296 || c > 57343) && (s = c));
|
|
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], h = t[i + 3], (a & 192) === 128 && (l & 192) === 128 && (h & 192) === 128 && (c = (o & 15) << 18 | (a & 63) << 12 | (l & 63) << 6 | h & 63, c > 65535 && c < 1114112 && (s = c));
|
|
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 @@ m.prototype.emit = function(e) {
|
|
|
929
929
|
else {
|
|
930
930
|
if (r instanceof Error)
|
|
931
931
|
throw r;
|
|
932
|
-
var
|
|
933
|
-
throw
|
|
932
|
+
var h = new Error('Uncaught, unspecified "error" event. (' + r + ")");
|
|
933
|
+
throw h.context = r, h;
|
|
934
934
|
}
|
|
935
935
|
return !1;
|
|
936
936
|
}
|
|
937
937
|
if (n = f[e], !n)
|
|
938
938
|
return !1;
|
|
939
|
-
var
|
|
939
|
+
var c = typeof n == "function";
|
|
940
940
|
switch (i = arguments.length, i) {
|
|
941
941
|
// fast cases
|
|
942
942
|
case 1:
|
|
943
|
-
Ir(n,
|
|
943
|
+
Ir(n, c, this);
|
|
944
944
|
break;
|
|
945
945
|
case 2:
|
|
946
|
-
Cr(n,
|
|
946
|
+
Cr(n, c, this, arguments[1]);
|
|
947
947
|
break;
|
|
948
948
|
case 3:
|
|
949
|
-
Or(n,
|
|
949
|
+
Or(n, c, this, arguments[1], arguments[2]);
|
|
950
950
|
break;
|
|
951
951
|
case 4:
|
|
952
|
-
Ar(n,
|
|
952
|
+
Ar(n, c, 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
|
-
Lr(n,
|
|
958
|
+
Lr(n, c, this, o);
|
|
959
959
|
}
|
|
960
960
|
return !0;
|
|
961
961
|
};
|
|
@@ -1306,20 +1306,20 @@ function ye(t, e, r) {
|
|
|
1306
1306
|
if (Te(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, h = ["{", "}"];
|
|
1310
|
+
if (Yr(e) && (l = !0, h = ["[", "]"]), De(e)) {
|
|
1311
|
+
var c = e.name ? ": " + e.name : "";
|
|
1312
|
+
a = " [Function" + c + "]";
|
|
1313
1313
|
}
|
|
1314
1314
|
if (Le(e) && (a = " " + RegExp.prototype.toString.call(e)), et(e) && (a = " " + Date.prototype.toUTCString.call(e)), Te(e) && (a = " " + Ae(e)), o.length === 0 && (!l || e.length == 0))
|
|
1315
|
-
return
|
|
1315
|
+
return h[0] + a + h[1];
|
|
1316
1316
|
if (r < 0)
|
|
1317
1317
|
return Le(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(g) {
|
|
1321
1321
|
return Pe(t, e, r, s, g, l);
|
|
1322
|
-
}), t.seen.pop(), Jr(p, a,
|
|
1322
|
+
}), t.seen.pop(), Jr(p, a, h);
|
|
1323
1323
|
}
|
|
1324
1324
|
function zr(t, e) {
|
|
1325
1325
|
if (Q(e))
|
|
@@ -1565,9 +1565,9 @@ function Xr(t) {
|
|
|
1565
1565
|
function Kr(t) {
|
|
1566
1566
|
this.charReceived = t.length % 3, this.charLength = this.charReceived ? 3 : 0;
|
|
1567
1567
|
}
|
|
1568
|
-
|
|
1569
|
-
var
|
|
1570
|
-
oe(
|
|
1568
|
+
C.ReadableState = Ut;
|
|
1569
|
+
var E = Pr("stream");
|
|
1570
|
+
oe(C, m);
|
|
1571
1571
|
function en(t, e, r) {
|
|
1572
1572
|
if (typeof t.prependListener == "function")
|
|
1573
1573
|
return t.prependListener(e, r);
|
|
@@ -1581,19 +1581,19 @@ function Ut(t, e) {
|
|
|
1581
1581
|
var r = t.highWaterMark, n = this.objectMode ? 16 : 16 * 1024;
|
|
1582
1582
|
this.highWaterMark = r || r === 0 ? r : n, this.highWaterMark = ~~this.highWaterMark, this.buffer = new te(), this.length = 0, this.pipes = null, this.pipesCount = 0, this.flowing = null, this.ended = !1, this.endEmitted = !1, this.reading = !1, this.sync = !0, this.needReadable = !1, this.emittedReadable = !1, this.readableListening = !1, this.resumeScheduled = !1, this.defaultEncoding = t.defaultEncoding || "utf8", this.ranOut = !1, this.awaitDrain = 0, this.readingMore = !1, this.decoder = null, this.encoding = null, t.encoding && (this.decoder = new le(t.encoding), this.encoding = t.encoding);
|
|
1583
1583
|
}
|
|
1584
|
-
function
|
|
1585
|
-
if (!(this instanceof
|
|
1584
|
+
function C(t) {
|
|
1585
|
+
if (!(this instanceof C)) return new C(t);
|
|
1586
1586
|
this._readableState = new Ut(t, this), this.readable = !0, t && typeof t.read == "function" && (this._read = t.read), m.call(this);
|
|
1587
1587
|
}
|
|
1588
|
-
|
|
1588
|
+
C.prototype.push = function(t, e) {
|
|
1589
1589
|
var r = this._readableState;
|
|
1590
1590
|
return !r.objectMode && typeof t == "string" && (e = e || r.defaultEncoding, e !== r.encoding && (t = u.from(t, e), e = "")), kt(this, r, t, e, !1);
|
|
1591
1591
|
};
|
|
1592
|
-
|
|
1592
|
+
C.prototype.unshift = function(t) {
|
|
1593
1593
|
var e = this._readableState;
|
|
1594
1594
|
return kt(this, e, t, "", !0);
|
|
1595
1595
|
};
|
|
1596
|
-
|
|
1596
|
+
C.prototype.isPaused = function() {
|
|
1597
1597
|
return this._readableState.flowing === !1;
|
|
1598
1598
|
};
|
|
1599
1599
|
function kt(t, e, r, n, i) {
|
|
@@ -1619,7 +1619,7 @@ function kt(t, e, r, n, i) {
|
|
|
1619
1619
|
function rn(t) {
|
|
1620
1620
|
return !t.ended && (t.needReadable || t.length < t.highWaterMark || t.length === 0);
|
|
1621
1621
|
}
|
|
1622
|
-
|
|
1622
|
+
C.prototype.setEncoding = function(t) {
|
|
1623
1623
|
return this._readableState.decoder = new le(t), this._readableState.encoding = t, this;
|
|
1624
1624
|
};
|
|
1625
1625
|
var tt = 8388608;
|
|
@@ -1629,15 +1629,15 @@ function nn(t) {
|
|
|
1629
1629
|
function rt(t, e) {
|
|
1630
1630
|
return t <= 0 || e.length === 0 && e.ended ? 0 : e.objectMode ? 1 : t !== t ? e.flowing && e.length ? e.buffer.head.data.length : e.length : (t > e.highWaterMark && (e.highWaterMark = nn(t)), t <= e.length ? t : e.ended ? e.length : (e.needReadable = !0, 0));
|
|
1631
1631
|
}
|
|
1632
|
-
|
|
1633
|
-
|
|
1632
|
+
C.prototype.read = function(t) {
|
|
1633
|
+
E("read", t), t = parseInt(t, 10);
|
|
1634
1634
|
var e = this._readableState, r = t;
|
|
1635
1635
|
if (t !== 0 && (e.emittedReadable = !1), t === 0 && e.needReadable && (e.length >= e.highWaterMark || e.ended))
|
|
1636
|
-
return
|
|
1636
|
+
return E("read: emitReadable", e.length, e.ended), e.length === 0 && e.ended ? Ne(this) : Se(this), null;
|
|
1637
1637
|
if (t = rt(t, e), t === 0 && e.ended)
|
|
1638
1638
|
return e.length === 0 && Ne(this), null;
|
|
1639
1639
|
var n = e.needReadable;
|
|
1640
|
-
|
|
1640
|
+
E("need readable", n), (e.length === 0 || e.length - t < e.highWaterMark) && (n = !0, E("length less than watermark", n)), e.ended || e.reading ? (n = !1, E("reading or ended", n)) : n && (E("do read"), e.reading = !0, e.sync = !0, e.length === 0 && (e.needReadable = !0), this._read(e.highWaterMark), e.sync = !1, e.reading || (t = rt(r, e)));
|
|
1641
1641
|
var i;
|
|
1642
1642
|
return t > 0 ? i = Pt(t, e) : i = null, i === null ? (e.needReadable = !0, t = 0) : e.length -= t, e.length === 0 && (e.ended || (e.needReadable = !0), r !== t && e.ended && Ne(this)), i !== null && this.emit("data", i), i;
|
|
1643
1643
|
};
|
|
@@ -1656,23 +1656,23 @@ function sn(t, e) {
|
|
|
1656
1656
|
}
|
|
1657
1657
|
function Se(t) {
|
|
1658
1658
|
var e = t._readableState;
|
|
1659
|
-
e.needReadable = !1, e.emittedReadable || (
|
|
1659
|
+
e.needReadable = !1, e.emittedReadable || (E("emitReadable", e.flowing), e.emittedReadable = !0, e.sync ? B(nt, t) : nt(t));
|
|
1660
1660
|
}
|
|
1661
1661
|
function nt(t) {
|
|
1662
|
-
|
|
1662
|
+
E("emit readable"), t.emit("readable"), Qe(t);
|
|
1663
1663
|
}
|
|
1664
1664
|
function fn(t, e) {
|
|
1665
1665
|
e.readingMore || (e.readingMore = !0, B(an, t, e));
|
|
1666
1666
|
}
|
|
1667
1667
|
function an(t, e) {
|
|
1668
|
-
for (var r = e.length; !e.reading && !e.flowing && !e.ended && e.length < e.highWaterMark && (
|
|
1668
|
+
for (var r = e.length; !e.reading && !e.flowing && !e.ended && e.length < e.highWaterMark && (E("maybeReadMore read 0"), t.read(0), r !== e.length); )
|
|
1669
1669
|
r = e.length;
|
|
1670
1670
|
e.readingMore = !1;
|
|
1671
1671
|
}
|
|
1672
|
-
|
|
1672
|
+
C.prototype._read = function(t) {
|
|
1673
1673
|
this.emit("error", new Error("not implemented"));
|
|
1674
1674
|
};
|
|
1675
|
-
|
|
1675
|
+
C.prototype.pipe = function(t, e) {
|
|
1676
1676
|
var r = this, n = this._readableState;
|
|
1677
1677
|
switch (n.pipesCount) {
|
|
1678
1678
|
case 0:
|
|
@@ -1685,52 +1685,52 @@ I.prototype.pipe = function(t, e) {
|
|
|
1685
1685
|
n.pipes.push(t);
|
|
1686
1686
|
break;
|
|
1687
1687
|
}
|
|
1688
|
-
n.pipesCount += 1,
|
|
1689
|
-
var i = !e || e.end !== !1, o = i ? f :
|
|
1688
|
+
n.pipesCount += 1, E("pipe count=%d opts=%j", n.pipesCount, e);
|
|
1689
|
+
var i = !e || e.end !== !1, o = i ? f : h;
|
|
1690
1690
|
n.endEmitted ? B(o) : r.once("end", o), t.on("unpipe", s);
|
|
1691
|
-
function s(
|
|
1692
|
-
|
|
1691
|
+
function s(R) {
|
|
1692
|
+
E("onunpipe"), R === r && h();
|
|
1693
1693
|
}
|
|
1694
1694
|
function f() {
|
|
1695
|
-
|
|
1695
|
+
E("onend"), t.end();
|
|
1696
1696
|
}
|
|
1697
1697
|
var a = un(r);
|
|
1698
1698
|
t.on("drain", a);
|
|
1699
1699
|
var l = !1;
|
|
1700
|
-
function
|
|
1701
|
-
|
|
1700
|
+
function h() {
|
|
1701
|
+
E("cleanup"), t.removeListener("close", x), t.removeListener("finish", y), t.removeListener("drain", a), t.removeListener("error", g), t.removeListener("unpipe", s), r.removeListener("end", f), r.removeListener("end", h), r.removeListener("data", p), l = !0, n.awaitDrain && (!t._writableState || t._writableState.needDrain) && a();
|
|
1702
1702
|
}
|
|
1703
|
-
var
|
|
1703
|
+
var c = !1;
|
|
1704
1704
|
r.on("data", p);
|
|
1705
|
-
function p(
|
|
1706
|
-
|
|
1707
|
-
var
|
|
1708
|
-
|
|
1705
|
+
function p(R) {
|
|
1706
|
+
E("ondata"), c = !1;
|
|
1707
|
+
var v = t.write(R);
|
|
1708
|
+
v === !1 && !c && ((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++, c = !0), r.pause());
|
|
1709
1709
|
}
|
|
1710
|
-
function g(
|
|
1711
|
-
|
|
1710
|
+
function g(R) {
|
|
1711
|
+
E("onerror", R), S(), t.removeListener("error", g), tn(t, "error") === 0 && t.emit("error", R);
|
|
1712
1712
|
}
|
|
1713
1713
|
en(t, "error", g);
|
|
1714
|
-
function
|
|
1715
|
-
t.removeListener("finish",
|
|
1714
|
+
function x() {
|
|
1715
|
+
t.removeListener("finish", y), S();
|
|
1716
1716
|
}
|
|
1717
|
-
t.once("close",
|
|
1718
|
-
function
|
|
1719
|
-
|
|
1717
|
+
t.once("close", x);
|
|
1718
|
+
function y() {
|
|
1719
|
+
E("onfinish"), t.removeListener("close", x), S();
|
|
1720
1720
|
}
|
|
1721
|
-
t.once("finish",
|
|
1722
|
-
function
|
|
1723
|
-
|
|
1721
|
+
t.once("finish", y);
|
|
1722
|
+
function S() {
|
|
1723
|
+
E("unpipe"), r.unpipe(t);
|
|
1724
1724
|
}
|
|
1725
|
-
return t.emit("pipe", r), n.flowing || (
|
|
1725
|
+
return t.emit("pipe", r), n.flowing || (E("pipe resume"), r.resume()), t;
|
|
1726
1726
|
};
|
|
1727
1727
|
function un(t) {
|
|
1728
1728
|
return function() {
|
|
1729
1729
|
var e = t._readableState;
|
|
1730
|
-
|
|
1730
|
+
E("pipeOnDrain", e.awaitDrain), e.awaitDrain && e.awaitDrain--, e.awaitDrain === 0 && t.listeners("data").length && (e.flowing = !0, Qe(t));
|
|
1731
1731
|
};
|
|
1732
1732
|
}
|
|
1733
|
-
|
|
1733
|
+
C.prototype.unpipe = function(t) {
|
|
1734
1734
|
var e = this._readableState;
|
|
1735
1735
|
if (e.pipesCount === 0) return this;
|
|
1736
1736
|
if (e.pipesCount === 1)
|
|
@@ -1745,7 +1745,7 @@ I.prototype.unpipe = function(t) {
|
|
|
1745
1745
|
var o = $t(e.pipes, t);
|
|
1746
1746
|
return o === -1 ? this : (e.pipes.splice(o, 1), e.pipesCount -= 1, e.pipesCount === 1 && (e.pipes = e.pipes[0]), t.emit("unpipe", this), this);
|
|
1747
1747
|
};
|
|
1748
|
-
|
|
1748
|
+
C.prototype.on = function(t, e) {
|
|
1749
1749
|
var r = m.prototype.on.call(this, t, e);
|
|
1750
1750
|
if (t === "data")
|
|
1751
1751
|
this._readableState.flowing !== !1 && this.resume();
|
|
@@ -1755,38 +1755,38 @@ I.prototype.on = function(t, e) {
|
|
|
1755
1755
|
}
|
|
1756
1756
|
return r;
|
|
1757
1757
|
};
|
|
1758
|
-
|
|
1758
|
+
C.prototype.addListener = C.prototype.on;
|
|
1759
1759
|
function ln(t) {
|
|
1760
|
-
|
|
1760
|
+
E("readable nexttick read 0"), t.read(0);
|
|
1761
1761
|
}
|
|
1762
|
-
|
|
1762
|
+
C.prototype.resume = function() {
|
|
1763
1763
|
var t = this._readableState;
|
|
1764
|
-
return t.flowing || (
|
|
1764
|
+
return t.flowing || (E("resume"), t.flowing = !0, cn(this, t)), this;
|
|
1765
1765
|
};
|
|
1766
1766
|
function cn(t, e) {
|
|
1767
1767
|
e.resumeScheduled || (e.resumeScheduled = !0, B(hn, t, e));
|
|
1768
1768
|
}
|
|
1769
1769
|
function hn(t, e) {
|
|
1770
|
-
e.reading || (
|
|
1770
|
+
e.reading || (E("resume read 0"), t.read(0)), e.resumeScheduled = !1, e.awaitDrain = 0, t.emit("resume"), Qe(t), e.flowing && !e.reading && t.read(0);
|
|
1771
1771
|
}
|
|
1772
|
-
|
|
1773
|
-
return
|
|
1772
|
+
C.prototype.pause = function() {
|
|
1773
|
+
return E("call pause flowing=%j", this._readableState.flowing), this._readableState.flowing !== !1 && (E("pause"), this._readableState.flowing = !1, this.emit("pause")), this;
|
|
1774
1774
|
};
|
|
1775
1775
|
function Qe(t) {
|
|
1776
1776
|
var e = t._readableState;
|
|
1777
|
-
for (
|
|
1777
|
+
for (E("flow", e.flowing); e.flowing && t.read() !== null; )
|
|
1778
1778
|
;
|
|
1779
1779
|
}
|
|
1780
|
-
|
|
1780
|
+
C.prototype.wrap = function(t) {
|
|
1781
1781
|
var e = this._readableState, r = !1, n = this;
|
|
1782
1782
|
t.on("end", function() {
|
|
1783
|
-
if (
|
|
1783
|
+
if (E("wrapped end"), e.decoder && !e.ended) {
|
|
1784
1784
|
var s = e.decoder.end();
|
|
1785
1785
|
s && s.length && n.push(s);
|
|
1786
1786
|
}
|
|
1787
1787
|
n.push(null);
|
|
1788
1788
|
}), t.on("data", function(s) {
|
|
1789
|
-
if (
|
|
1789
|
+
if (E("wrapped data"), e.decoder && (s = e.decoder.write(s)), !(e.objectMode && s == null) && !(!e.objectMode && (!s || !s.length))) {
|
|
1790
1790
|
var f = n.push(s);
|
|
1791
1791
|
f || (r = !0, t.pause());
|
|
1792
1792
|
}
|
|
@@ -1801,10 +1801,10 @@ I.prototype.wrap = function(t) {
|
|
|
1801
1801
|
return _n(o, function(s) {
|
|
1802
1802
|
t.on(s, n.emit.bind(n, s));
|
|
1803
1803
|
}), n._read = function(s) {
|
|
1804
|
-
|
|
1804
|
+
E("wrapped _read", s), r && (r = !1, t.resume());
|
|
1805
1805
|
}, n;
|
|
1806
1806
|
};
|
|
1807
|
-
|
|
1807
|
+
C._fromList = Pt;
|
|
1808
1808
|
function Pt(t, e) {
|
|
1809
1809
|
if (e.length === 0) return null;
|
|
1810
1810
|
var r;
|
|
@@ -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, h = e.objectMode ? 1 : f.length;
|
|
1964
|
+
if ($e(t, e, !1, h, f, a, l), r = r.next, e.writing)
|
|
1965
1965
|
break;
|
|
1966
1966
|
}
|
|
1967
1967
|
r === null && (e.lastBufferedRequest = null);
|
|
@@ -2000,7 +2000,7 @@ function Vt(t) {
|
|
|
2000
2000
|
t.corkedRequestsFree ? t.corkedRequestsFree.next = e : t.corkedRequestsFree = e;
|
|
2001
2001
|
};
|
|
2002
2002
|
}
|
|
2003
|
-
oe(M,
|
|
2003
|
+
oe(M, C);
|
|
2004
2004
|
var st = Object.keys(T.prototype);
|
|
2005
2005
|
for (var Fe = 0; Fe < st.length; Fe++) {
|
|
2006
2006
|
var Me = st[Fe];
|
|
@@ -2008,7 +2008,7 @@ for (var Fe = 0; Fe < st.length; Fe++) {
|
|
|
2008
2008
|
}
|
|
2009
2009
|
function M(t) {
|
|
2010
2010
|
if (!(this instanceof M)) return new M(t);
|
|
2011
|
-
|
|
2011
|
+
C.call(this, t), T.call(this, t), t && t.readable === !1 && (this.readable = !1), t && t.writable === !1 && (this.writable = !1), this.allowHalfOpen = !0, t && t.allowHalfOpen === !1 && (this.allowHalfOpen = !1), this.once("end", An);
|
|
2012
2012
|
}
|
|
2013
2013
|
function An() {
|
|
2014
2014
|
this.allowHalfOpen || this._writableState.ended || B(Ln, this);
|
|
@@ -2074,7 +2074,7 @@ fe.prototype._transform = function(t, e, r) {
|
|
|
2074
2074
|
r(null, t);
|
|
2075
2075
|
};
|
|
2076
2076
|
oe(V, m);
|
|
2077
|
-
V.Readable =
|
|
2077
|
+
V.Readable = C;
|
|
2078
2078
|
V.Writable = T;
|
|
2079
2079
|
V.Duplex = M;
|
|
2080
2080
|
V.Transform = k;
|
|
@@ -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(h) {
|
|
2089
|
+
t.writable && t.write(h) === !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(h) {
|
|
2104
2104
|
if (l(), m.listenerCount(this, "error") === 0)
|
|
2105
|
-
throw
|
|
2105
|
+
throw h;
|
|
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: h, recordDelimiterMaxLength: c } = this.state, p = i - n - 1, g = Math.max(
|
|
2669
|
+
h,
|
|
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
|
+
c === 0 ? u.from(`\r
|
|
2677
|
+
`, s).length : c,
|
|
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 + c : 0
|
|
2682
2682
|
);
|
|
2683
2683
|
return p < g;
|
|
2684
2684
|
},
|
|
@@ -2688,88 +2688,88 @@ 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: h,
|
|
2692
|
+
ltrim: c,
|
|
2693
2693
|
max_record_size: p,
|
|
2694
2694
|
raw: g,
|
|
2695
|
-
relax_quotes:
|
|
2696
|
-
rtrim:
|
|
2697
|
-
skip_empty_lines:
|
|
2698
|
-
to:
|
|
2699
|
-
to_line:
|
|
2695
|
+
relax_quotes: x,
|
|
2696
|
+
rtrim: y,
|
|
2697
|
+
skip_empty_lines: S,
|
|
2698
|
+
to: R,
|
|
2699
|
+
to_line: v
|
|
2700
2700
|
} = this.options;
|
|
2701
|
-
let { comment: _, escape:
|
|
2701
|
+
let { comment: _, escape: I, quote: U, record_delimiter: Re } = this.options;
|
|
2702
2702
|
const { bomSkipped: Wt, previousBuf: ce, rawBuffer: Qt, escapeIsQuote: Ht } = this.state;
|
|
2703
|
-
let
|
|
2703
|
+
let b;
|
|
2704
2704
|
if (ce === void 0)
|
|
2705
2705
|
if (n === void 0) {
|
|
2706
2706
|
s();
|
|
2707
2707
|
return;
|
|
2708
2708
|
} else
|
|
2709
|
-
|
|
2710
|
-
else ce !== void 0 && n === void 0 ?
|
|
2709
|
+
b = n;
|
|
2710
|
+
else ce !== void 0 && n === void 0 ? b = ce : b = u.concat([ce, n]);
|
|
2711
2711
|
if (Wt === !1)
|
|
2712
2712
|
if (f === !1)
|
|
2713
2713
|
this.state.bomSkipped = !0;
|
|
2714
|
-
else if (
|
|
2714
|
+
else if (b.length < 3) {
|
|
2715
2715
|
if (i === !1) {
|
|
2716
|
-
this.state.previousBuf =
|
|
2716
|
+
this.state.previousBuf = b;
|
|
2717
2717
|
return;
|
|
2718
2718
|
}
|
|
2719
2719
|
} else {
|
|
2720
|
-
for (const
|
|
2721
|
-
if (re[
|
|
2722
|
-
const J = re[
|
|
2723
|
-
this.state.bufBytesStart += J,
|
|
2720
|
+
for (const O in re)
|
|
2721
|
+
if (re[O].compare(b, 0, re[O].length) === 0) {
|
|
2722
|
+
const J = re[O].length;
|
|
2723
|
+
this.state.bufBytesStart += J, b = b.slice(J);
|
|
2724
2724
|
const he = ut({
|
|
2725
2725
|
...this.original_options,
|
|
2726
|
-
encoding:
|
|
2726
|
+
encoding: O
|
|
2727
2727
|
});
|
|
2728
2728
|
for (const A in he)
|
|
2729
2729
|
this.options[A] = he[A];
|
|
2730
|
-
({ comment: _, escape:
|
|
2730
|
+
({ comment: _, escape: I, quote: U } = this.options);
|
|
2731
2731
|
break;
|
|
2732
2732
|
}
|
|
2733
2733
|
this.state.bomSkipped = !0;
|
|
2734
2734
|
}
|
|
2735
|
-
const Ie =
|
|
2735
|
+
const Ie = b.length;
|
|
2736
2736
|
let d;
|
|
2737
2737
|
for (d = 0; d < Ie && !this.__needMoreData(d, Ie, i); d++) {
|
|
2738
|
-
if (this.state.wasRowDelimiter === !0 && (this.info.lines++, this.state.wasRowDelimiter = !1),
|
|
2738
|
+
if (this.state.wasRowDelimiter === !0 && (this.info.lines++, this.state.wasRowDelimiter = !1), v !== -1 && this.info.lines > v) {
|
|
2739
2739
|
this.state.stop = !0, s();
|
|
2740
2740
|
return;
|
|
2741
2741
|
}
|
|
2742
2742
|
this.state.quoting === !1 && Re.length === 0 && this.__autoDiscoverRecordDelimiter(
|
|
2743
|
-
|
|
2743
|
+
b,
|
|
2744
2744
|
d
|
|
2745
2745
|
) && (Re = this.options.record_delimiter);
|
|
2746
|
-
const
|
|
2747
|
-
if (g === !0 && Qt.append(
|
|
2746
|
+
const O = b[d];
|
|
2747
|
+
if (g === !0 && Qt.append(O), (O === $n || O === jn) && this.state.wasRowDelimiter === !1 && (this.state.wasRowDelimiter = !0), this.state.escaping === !0)
|
|
2748
2748
|
this.state.escaping = !1;
|
|
2749
2749
|
else {
|
|
2750
|
-
if (
|
|
2750
|
+
if (I !== null && this.state.quoting === !0 && this.__isEscape(b, d, O) && d + I.length < Ie)
|
|
2751
2751
|
if (Ht) {
|
|
2752
|
-
if (this.__isQuote(
|
|
2753
|
-
this.state.escaping = !0, d +=
|
|
2752
|
+
if (this.__isQuote(b, d + I.length)) {
|
|
2753
|
+
this.state.escaping = !0, d += I.length - 1;
|
|
2754
2754
|
continue;
|
|
2755
2755
|
}
|
|
2756
2756
|
} else {
|
|
2757
|
-
this.state.escaping = !0, d +=
|
|
2757
|
+
this.state.escaping = !0, d += I.length - 1;
|
|
2758
2758
|
continue;
|
|
2759
2759
|
}
|
|
2760
|
-
if (this.state.commenting === !1 && this.__isQuote(
|
|
2760
|
+
if (this.state.commenting === !1 && this.__isQuote(b, d))
|
|
2761
2761
|
if (this.state.quoting === !0) {
|
|
2762
|
-
const A =
|
|
2763
|
-
|
|
2762
|
+
const A = b[d + U.length], Z = y && this.__isCharTrimable(b, d + U.length), j = _ !== null && this.__compareBytes(_, b, d + U.length, A), X = this.__isDelimiter(
|
|
2763
|
+
b,
|
|
2764
2764
|
d + U.length,
|
|
2765
2765
|
A
|
|
2766
|
-
), de = Re.length === 0 ? this.__autoDiscoverRecordDelimiter(
|
|
2767
|
-
if (
|
|
2768
|
-
d +=
|
|
2766
|
+
), de = Re.length === 0 ? this.__autoDiscoverRecordDelimiter(b, d + U.length) : this.__isRecordDelimiter(A, b, d + U.length);
|
|
2767
|
+
if (I !== null && this.__isEscape(b, d, O) && this.__isQuote(b, d + I.length))
|
|
2768
|
+
d += I.length - 1;
|
|
2769
2769
|
else if (!A || X || de || j || Z) {
|
|
2770
2770
|
this.state.quoting = !1, this.state.wasQuoting = !0, d += U.length - 1;
|
|
2771
2771
|
continue;
|
|
2772
|
-
} else if (
|
|
2772
|
+
} else if (x === !1) {
|
|
2773
2773
|
const Ge = this.__error(
|
|
2774
2774
|
new w(
|
|
2775
2775
|
"CSV_INVALID_CLOSING_QUOTE",
|
|
@@ -2788,7 +2788,7 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
|
|
|
2788
2788
|
} else
|
|
2789
2789
|
this.state.quoting = !1, this.state.wasQuoting = !0, this.state.field.prepend(U), d += U.length - 1;
|
|
2790
2790
|
} else if (this.state.field.length !== 0) {
|
|
2791
|
-
if (
|
|
2791
|
+
if (x === !1) {
|
|
2792
2792
|
const A = this.__infoField(), Z = Object.keys(re).map(
|
|
2793
2793
|
(X) => re[X].equals(this.state.field.toString()) ? X : !1
|
|
2794
2794
|
).filter(Boolean)[0], j = this.__error(
|
|
@@ -2814,19 +2814,19 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
|
|
|
2814
2814
|
}
|
|
2815
2815
|
if (this.state.quoting === !1) {
|
|
2816
2816
|
const A = this.__isRecordDelimiter(
|
|
2817
|
-
|
|
2818
|
-
|
|
2817
|
+
O,
|
|
2818
|
+
b,
|
|
2819
2819
|
d
|
|
2820
2820
|
);
|
|
2821
2821
|
if (A !== 0) {
|
|
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) >= h) {
|
|
2826
2826
|
this.state.enabled = !0, this.__resetField(), this.__resetRecord(), d += A - 1;
|
|
2827
2827
|
continue;
|
|
2828
2828
|
}
|
|
2829
|
-
if (
|
|
2829
|
+
if (S === !0 && this.state.wasQuoting === !1 && this.state.record.length === 0 && this.state.field.length === 0) {
|
|
2830
2830
|
this.info.empty_lines++, d += A - 1;
|
|
2831
2831
|
continue;
|
|
2832
2832
|
}
|
|
@@ -2836,7 +2836,7 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
|
|
|
2836
2836
|
this.info.bytes = this.state.bufBytesStart + d + A;
|
|
2837
2837
|
const de = this.__onRecord(o);
|
|
2838
2838
|
if (de !== void 0) return de;
|
|
2839
|
-
if (
|
|
2839
|
+
if (R !== -1 && this.info.records >= R) {
|
|
2840
2840
|
this.state.stop = !0, s();
|
|
2841
2841
|
return;
|
|
2842
2842
|
}
|
|
@@ -2846,11 +2846,11 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
|
|
|
2846
2846
|
}
|
|
2847
2847
|
if (this.state.commenting)
|
|
2848
2848
|
continue;
|
|
2849
|
-
if (_ !== null && (a === !1 || this.state.record.length === 0 && this.state.field.length === 0) && this.__compareBytes(_,
|
|
2849
|
+
if (_ !== null && (a === !1 || this.state.record.length === 0 && this.state.field.length === 0) && this.__compareBytes(_, b, d, O) !== 0) {
|
|
2850
2850
|
this.state.commenting = !0;
|
|
2851
2851
|
continue;
|
|
2852
2852
|
}
|
|
2853
|
-
const Z = this.__isDelimiter(
|
|
2853
|
+
const Z = this.__isDelimiter(b, d, O);
|
|
2854
2854
|
if (Z !== 0) {
|
|
2855
2855
|
this.info.bytes = this.state.bufBytesStart + d;
|
|
2856
2856
|
const j = this.__onField();
|
|
@@ -2874,11 +2874,11 @@ 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 = c === !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
|
-
this.state.field.append(
|
|
2879
|
+
this.state.field.append(O);
|
|
2880
2880
|
else {
|
|
2881
|
-
if (
|
|
2881
|
+
if (y === !0 && !this.__isCharTrimable(b, d))
|
|
2882
2882
|
return this.__error(
|
|
2883
2883
|
new w(
|
|
2884
2884
|
"CSV_NON_TRIMABLE_CHAR_AFTER_CLOSING_QUOTE",
|
|
@@ -2891,13 +2891,13 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
|
|
|
2891
2891
|
this.__infoField()
|
|
2892
2892
|
)
|
|
2893
2893
|
);
|
|
2894
|
-
J === !1 && (d += this.__isCharTrimable(
|
|
2894
|
+
J === !1 && (d += this.__isCharTrimable(b, d) - 1);
|
|
2895
2895
|
continue;
|
|
2896
2896
|
}
|
|
2897
2897
|
}
|
|
2898
2898
|
if (i === !0)
|
|
2899
2899
|
if (this.state.quoting === !0) {
|
|
2900
|
-
const
|
|
2900
|
+
const O = this.__error(
|
|
2901
2901
|
new w(
|
|
2902
2902
|
"CSV_QUOTE_NOT_CLOSED",
|
|
2903
2903
|
[
|
|
@@ -2908,16 +2908,16 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
|
|
|
2908
2908
|
this.__infoField()
|
|
2909
2909
|
)
|
|
2910
2910
|
);
|
|
2911
|
-
if (
|
|
2911
|
+
if (O !== void 0) return O;
|
|
2912
2912
|
} else if (this.state.wasQuoting === !0 || this.state.record.length !== 0 || this.state.field.length !== 0) {
|
|
2913
2913
|
this.info.bytes = this.state.bufBytesStart + d;
|
|
2914
|
-
const
|
|
2915
|
-
if (
|
|
2914
|
+
const O = this.__onField();
|
|
2915
|
+
if (O !== void 0) return O;
|
|
2916
2916
|
const J = this.__onRecord(o);
|
|
2917
2917
|
if (J !== void 0) return J;
|
|
2918
2918
|
} else this.state.wasRowDelimiter === !0 ? this.info.empty_lines++ : this.state.commenting === !0 && this.info.comment_lines++;
|
|
2919
2919
|
else
|
|
2920
|
-
this.state.bufBytesStart += d, this.state.previousBuf =
|
|
2920
|
+
this.state.bufBytesStart += d, this.state.previousBuf = b.slice(d);
|
|
2921
2921
|
this.state.wasRowDelimiter === !0 && (this.info.lines++, this.state.wasRowDelimiter = !1);
|
|
2922
2922
|
},
|
|
2923
2923
|
__onRecord: function(n) {
|
|
@@ -2928,33 +2928,33 @@ 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: h,
|
|
2932
|
+
relax_column_count_more: c,
|
|
2933
2933
|
raw: p,
|
|
2934
2934
|
skip_records_with_empty_values: g
|
|
2935
|
-
} = this.options, { enabled:
|
|
2936
|
-
if (
|
|
2935
|
+
} = this.options, { enabled: x, record: y } = this.state;
|
|
2936
|
+
if (x === !1)
|
|
2937
2937
|
return this.__resetRecord();
|
|
2938
|
-
const
|
|
2938
|
+
const S = y.length;
|
|
2939
2939
|
if (i === !0) {
|
|
2940
|
-
if (g === !0 && lt(
|
|
2940
|
+
if (g === !0 && lt(y)) {
|
|
2941
2941
|
this.__resetRecord();
|
|
2942
2942
|
return;
|
|
2943
2943
|
}
|
|
2944
|
-
return this.__firstLineToColumns(
|
|
2944
|
+
return this.__firstLineToColumns(y);
|
|
2945
2945
|
}
|
|
2946
|
-
if (i === !1 && this.info.records === 0 && (this.state.expectedRecordLength =
|
|
2947
|
-
const
|
|
2946
|
+
if (i === !1 && this.info.records === 0 && (this.state.expectedRecordLength = S), S !== this.state.expectedRecordLength) {
|
|
2947
|
+
const R = i === !1 ? new w(
|
|
2948
2948
|
"CSV_RECORD_INCONSISTENT_FIELDS_LENGTH",
|
|
2949
2949
|
[
|
|
2950
2950
|
"Invalid Record Length:",
|
|
2951
2951
|
`expect ${this.state.expectedRecordLength},`,
|
|
2952
|
-
`got ${
|
|
2952
|
+
`got ${S} on line ${this.info.lines}`
|
|
2953
2953
|
],
|
|
2954
2954
|
this.options,
|
|
2955
2955
|
this.__infoField(),
|
|
2956
2956
|
{
|
|
2957
|
-
record:
|
|
2957
|
+
record: y
|
|
2958
2958
|
}
|
|
2959
2959
|
) : new w(
|
|
2960
2960
|
"CSV_RECORD_INCONSISTENT_COLUMNS",
|
|
@@ -2962,22 +2962,22 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
|
|
|
2962
2962
|
"Invalid Record Length:",
|
|
2963
2963
|
`columns length is ${i.length},`,
|
|
2964
2964
|
// rename columns
|
|
2965
|
-
`got ${
|
|
2965
|
+
`got ${S} on line ${this.info.lines}`
|
|
2966
2966
|
],
|
|
2967
2967
|
this.options,
|
|
2968
2968
|
this.__infoField(),
|
|
2969
2969
|
{
|
|
2970
|
-
record:
|
|
2970
|
+
record: y
|
|
2971
2971
|
}
|
|
2972
2972
|
);
|
|
2973
|
-
if (l === !0 ||
|
|
2974
|
-
this.info.invalid_field_length++, this.state.error =
|
|
2973
|
+
if (l === !0 || h === !0 && S < this.state.expectedRecordLength || c === !0 && S > this.state.expectedRecordLength)
|
|
2974
|
+
this.info.invalid_field_length++, this.state.error = R;
|
|
2975
2975
|
else {
|
|
2976
|
-
const
|
|
2977
|
-
if (
|
|
2976
|
+
const v = this.__error(R);
|
|
2977
|
+
if (v) return v;
|
|
2978
2978
|
}
|
|
2979
2979
|
}
|
|
2980
|
-
if (g === !0 && lt(
|
|
2980
|
+
if (g === !0 && lt(y)) {
|
|
2981
2981
|
this.__resetRecord();
|
|
2982
2982
|
return;
|
|
2983
2983
|
}
|
|
@@ -2986,48 +2986,48 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
|
|
|
2986
2986
|
return;
|
|
2987
2987
|
}
|
|
2988
2988
|
if (this.info.records++, a === 1 || this.info.records >= a) {
|
|
2989
|
-
const { objname:
|
|
2989
|
+
const { objname: R } = this.options;
|
|
2990
2990
|
if (i !== !1) {
|
|
2991
|
-
const
|
|
2992
|
-
for (let _ = 0,
|
|
2993
|
-
i[_] === void 0 || i[_].disabled || (o === !0 &&
|
|
2991
|
+
const v = {};
|
|
2992
|
+
for (let _ = 0, I = y.length; _ < I; _++)
|
|
2993
|
+
i[_] === void 0 || i[_].disabled || (o === !0 && v[i[_].name] !== void 0 ? Array.isArray(v[i[_].name]) ? v[i[_].name] = v[i[_].name].concat(y[_]) : v[i[_].name] = [v[i[_].name], y[_]] : v[i[_].name] = y[_]);
|
|
2994
2994
|
if (p === !0 || f === !0) {
|
|
2995
2995
|
const _ = Object.assign(
|
|
2996
|
-
{ record:
|
|
2996
|
+
{ record: v },
|
|
2997
2997
|
p === !0 ? { raw: this.state.rawBuffer.toString(s) } : {},
|
|
2998
2998
|
f === !0 ? { info: this.__infoRecord() } : {}
|
|
2999
|
-
),
|
|
3000
|
-
|
|
2999
|
+
), I = this.__push(
|
|
3000
|
+
R === void 0 ? _ : [v[R], _],
|
|
3001
3001
|
n
|
|
3002
3002
|
);
|
|
3003
|
-
if (
|
|
3004
|
-
return
|
|
3003
|
+
if (I)
|
|
3004
|
+
return I;
|
|
3005
3005
|
} else {
|
|
3006
3006
|
const _ = this.__push(
|
|
3007
|
-
|
|
3007
|
+
R === void 0 ? v : [v[R], v],
|
|
3008
3008
|
n
|
|
3009
3009
|
);
|
|
3010
3010
|
if (_)
|
|
3011
3011
|
return _;
|
|
3012
3012
|
}
|
|
3013
3013
|
} else if (p === !0 || f === !0) {
|
|
3014
|
-
const
|
|
3015
|
-
{ record:
|
|
3014
|
+
const v = Object.assign(
|
|
3015
|
+
{ record: y },
|
|
3016
3016
|
p === !0 ? { raw: this.state.rawBuffer.toString(s) } : {},
|
|
3017
3017
|
f === !0 ? { info: this.__infoRecord() } : {}
|
|
3018
3018
|
), _ = this.__push(
|
|
3019
|
-
|
|
3019
|
+
R === void 0 ? v : [y[R], v],
|
|
3020
3020
|
n
|
|
3021
3021
|
);
|
|
3022
3022
|
if (_)
|
|
3023
3023
|
return _;
|
|
3024
3024
|
} else {
|
|
3025
|
-
const
|
|
3026
|
-
|
|
3025
|
+
const v = this.__push(
|
|
3026
|
+
R === void 0 ? y : [y[R], y],
|
|
3027
3027
|
n
|
|
3028
3028
|
);
|
|
3029
|
-
if (
|
|
3030
|
-
return
|
|
3029
|
+
if (v)
|
|
3030
|
+
return v;
|
|
3031
3031
|
}
|
|
3032
3032
|
}
|
|
3033
3033
|
this.__resetRecord();
|
|
@@ -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 [h, c] = this.__cast(l);
|
|
3072
|
+
if (h !== void 0) return h;
|
|
3073
|
+
l = c;
|
|
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 (c
|
|
3122
|
-
return
|
|
3119
|
+
const h = a[l];
|
|
3120
|
+
for (let c = 0; c < h.length; c++)
|
|
3121
|
+
if (h[c] !== s[f + c]) continue e;
|
|
3122
|
+
return h.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 h = 1; h < l.length; h++)
|
|
3153
|
+
if (l[h] !== n[i + h]) 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], h = l.length;
|
|
3163
3163
|
if (l[0] === n) {
|
|
3164
|
-
for (let
|
|
3165
|
-
if (l[
|
|
3164
|
+
for (let c = 1; c < h; c++)
|
|
3165
|
+
if (l[c] !== i[o + c])
|
|
3166
3166
|
continue e;
|
|
3167
3167
|
return l.length;
|
|
3168
3168
|
}
|
|
@@ -3389,10 +3389,11 @@ class ri {
|
|
|
3389
3389
|
* Determine schema configuration.
|
|
3390
3390
|
*/
|
|
3391
3391
|
async determineSchemaConfig(e, r) {
|
|
3392
|
-
const n = Xn(e), i = await Kn(e);
|
|
3392
|
+
const n = Xn(e), { records: i, valueDelimiterId: o } = await Kn(e, r);
|
|
3393
3393
|
return {
|
|
3394
3394
|
recordDelimiterId: n,
|
|
3395
|
-
|
|
3395
|
+
records: i,
|
|
3396
|
+
valueDelimiterId: o
|
|
3396
3397
|
};
|
|
3397
3398
|
}
|
|
3398
3399
|
/**
|
|
@@ -3400,50 +3401,50 @@ class ri {
|
|
|
3400
3401
|
*/
|
|
3401
3402
|
async parseStream(e, r, n, i, o) {
|
|
3402
3403
|
return new Promise((s, f) => {
|
|
3403
|
-
let a, l,
|
|
3404
|
+
let a, l, h, c = !1, p = !1;
|
|
3404
3405
|
const g = () => {
|
|
3405
3406
|
if (p) return;
|
|
3406
3407
|
p = !0;
|
|
3407
|
-
const
|
|
3408
|
-
a = void 0,
|
|
3408
|
+
const S = a;
|
|
3409
|
+
a = void 0, h = void 0, S != null && (Be(() => S.removeAllListeners()), Be(() => S.end())), Be(() => {
|
|
3409
3410
|
l?.cancel();
|
|
3410
3411
|
}), l = void 0;
|
|
3411
3412
|
};
|
|
3412
3413
|
i.signal.addEventListener("abort", g, { once: !0 });
|
|
3413
|
-
const
|
|
3414
|
-
|
|
3414
|
+
const x = (S) => {
|
|
3415
|
+
c || (c = !0, g(), i.signal.aborted || i.abort(S), f(S));
|
|
3415
3416
|
};
|
|
3416
3417
|
(async () => {
|
|
3417
|
-
a = je(r),
|
|
3418
|
+
a = je(r), h = ei({ chunk: o, chunkSize: e.chunkSize ?? Gn }), a.on("readable", () => {
|
|
3418
3419
|
try {
|
|
3419
|
-
if (a == null ||
|
|
3420
|
-
let
|
|
3421
|
-
for (; (
|
|
3422
|
-
if (
|
|
3423
|
-
i.signal.throwIfAborted(),
|
|
3420
|
+
if (a == null || h == null) return;
|
|
3421
|
+
let I;
|
|
3422
|
+
for (; (I = a.read()) != null; ) {
|
|
3423
|
+
if (c) return;
|
|
3424
|
+
i.signal.throwIfAborted(), h.push(I);
|
|
3424
3425
|
}
|
|
3425
|
-
} catch (
|
|
3426
|
-
|
|
3426
|
+
} catch (I) {
|
|
3427
|
+
x(I);
|
|
3427
3428
|
}
|
|
3428
|
-
}), a.on("error", (
|
|
3429
|
-
|
|
3429
|
+
}), a.on("error", (I) => x(I)), a.on("end", () => {
|
|
3430
|
+
c || (h?.flush(), s(ti(a)));
|
|
3430
3431
|
});
|
|
3431
|
-
const
|
|
3432
|
-
if (!
|
|
3433
|
-
throw await Wn(
|
|
3434
|
-
l =
|
|
3435
|
-
const
|
|
3436
|
-
let
|
|
3437
|
-
for (; !
|
|
3438
|
-
if (
|
|
3432
|
+
const S = await fetch(encodeURI(n), { signal: i.signal });
|
|
3433
|
+
if (!S.ok || S.body == null)
|
|
3434
|
+
throw await Wn(S, `Failed to fetch '${n}' file.`, "datapos-connector-file-store-emulator|Connector|retrieve");
|
|
3435
|
+
l = S.body.getReader();
|
|
3436
|
+
const R = new TextDecoder(e.encodingId);
|
|
3437
|
+
let v = await l.read();
|
|
3438
|
+
for (; !v.done; ) {
|
|
3439
|
+
if (c) return;
|
|
3439
3440
|
i.signal.throwIfAborted();
|
|
3440
|
-
const
|
|
3441
|
-
|
|
3441
|
+
const I = R.decode(v.value, { stream: !0 });
|
|
3442
|
+
I.length > 0 && a.write(I), v = await l.read();
|
|
3442
3443
|
}
|
|
3443
|
-
if (
|
|
3444
|
-
const _ =
|
|
3444
|
+
if (c) return;
|
|
3445
|
+
const _ = R.decode();
|
|
3445
3446
|
_.length > 0 && a.write(_), a.end();
|
|
3446
|
-
})().catch((
|
|
3447
|
+
})().catch((S) => x(S));
|
|
3447
3448
|
});
|
|
3448
3449
|
}
|
|
3449
3450
|
}
|
|
@@ -3454,33 +3455,35 @@ function Xn(t) {
|
|
|
3454
3455
|
` : n >= e && n >= r ? "\r" : `
|
|
3455
3456
|
`;
|
|
3456
3457
|
}
|
|
3457
|
-
async function Kn(t) {
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
for (const o of e)
|
|
3458
|
+
async function Kn(t, e) {
|
|
3459
|
+
let r, n, i, o = [];
|
|
3460
|
+
for (const s of e)
|
|
3461
3461
|
try {
|
|
3462
|
-
let
|
|
3463
|
-
const c = je({ delimiter:
|
|
3464
|
-
await new Promise((
|
|
3462
|
+
let f = 0, a, l = 0, h = 0;
|
|
3463
|
+
const c = je({ delimiter: s, relax_column_count: !0 });
|
|
3464
|
+
await new Promise((p) => {
|
|
3465
3465
|
try {
|
|
3466
|
+
const g = [];
|
|
3466
3467
|
c.on("readable", () => {
|
|
3467
|
-
let
|
|
3468
|
-
for (; (
|
|
3469
|
-
|
|
3470
|
-
const
|
|
3471
|
-
|
|
3468
|
+
let x;
|
|
3469
|
+
for (; (x = c.read()) != null; ) {
|
|
3470
|
+
l++;
|
|
3471
|
+
const y = x.length;
|
|
3472
|
+
a != null && (h += Math.abs(y - a)), a = y, f += y, g.push(x);
|
|
3472
3473
|
}
|
|
3473
|
-
}), c.on("error", () =>
|
|
3474
|
-
|
|
3475
|
-
|
|
3474
|
+
}), c.on("error", (x) => {
|
|
3475
|
+
console.log(7777, x), p();
|
|
3476
|
+
}), c.on("end", () => {
|
|
3477
|
+
const x = f / l;
|
|
3478
|
+
(!i || h <= i) && (!n || x > n) && (r = s, n = x, i = h, o = [...g]), p();
|
|
3476
3479
|
}), c.write(t), c.end();
|
|
3477
3480
|
} catch {
|
|
3478
|
-
|
|
3481
|
+
p();
|
|
3479
3482
|
}
|
|
3480
3483
|
});
|
|
3481
3484
|
} catch {
|
|
3482
3485
|
}
|
|
3483
|
-
return r ?? ",";
|
|
3486
|
+
return { records: o, valueDelimiterId: r ?? "," };
|
|
3484
3487
|
}
|
|
3485
3488
|
function ei(t) {
|
|
3486
3489
|
const e = Math.max(1, Math.floor(t.chunkSize)), r = [];
|
|
@@ -2,10 +2,15 @@ import { Options as ParseOptions, Parser } from 'csv-parse/browser/esm';
|
|
|
2
2
|
import { RecordDelimiterId, ValueDelimiterId } from '@datapos/datapos-shared';
|
|
3
3
|
import { RetrieveRecordsOptions, RetrieveRecordsSummary } from '@datapos/datapos-shared/component/connector';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Parse record and parsed record buffer.
|
|
6
|
+
*/
|
|
7
|
+
type ParsedRecord = string[];
|
|
8
|
+
/**
|
|
9
|
+
* Schema configuration.
|
|
6
10
|
*/
|
|
7
11
|
interface SchemaConfig {
|
|
8
12
|
recordDelimiterId: RecordDelimiterId;
|
|
13
|
+
records: ParsedRecord[];
|
|
9
14
|
valueDelimiterId: ValueDelimiterId;
|
|
10
15
|
}
|
|
11
16
|
/** Tool. */
|
|
@@ -15,11 +20,11 @@ declare class Tool {
|
|
|
15
20
|
/**
|
|
16
21
|
* Determine schema configuration.
|
|
17
22
|
*/
|
|
18
|
-
determineSchemaConfig(text: string, delimiters:
|
|
23
|
+
determineSchemaConfig(text: string, delimiters: ValueDelimiterId[]): Promise<SchemaConfig>;
|
|
19
24
|
/**
|
|
20
25
|
* Parse stream.
|
|
21
26
|
*/
|
|
22
27
|
parseStream(retrieveRecordsOptions: RetrieveRecordsOptions, parseOptions: ParseOptions, url: string, abortController: AbortController, chunk: (records: (string[] | Record<string, unknown>)[]) => void): Promise<RetrieveRecordsSummary>;
|
|
23
28
|
}
|
|
24
29
|
export type { Options as ParseOptions, Parser } from 'csv-parse/browser/esm';
|
|
25
|
-
export { type SchemaConfig, Tool };
|
|
30
|
+
export { type ParsedRecord, type SchemaConfig, Tool };
|