@datapos/datapos-tool-csv-parse 0.0.119 → 0.0.121
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 +183 -202
- package/dist/types/src/index.d.ts +8 -11
- package/package.json +3 -3
|
@@ -31,27 +31,27 @@ 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, u = a >> 1, h = -7, c = r ? i - 1 : 0,
|
|
35
|
-
for (c +=
|
|
34
|
+
var o, s, f = i * 8 - n - 1, a = (1 << f) - 1, u = a >> 1, h = -7, c = r ? i - 1 : 0, p = r ? -1 : 1, m = t[e + c];
|
|
35
|
+
for (c += p, o = m & (1 << -h) - 1, m >>= -h, h += f; h > 0; o = o * 256 + t[e + c], c += p, h -= 8)
|
|
36
36
|
;
|
|
37
|
-
for (s = o & (1 << -h) - 1, o >>= -h, h += n; h > 0; s = s * 256 + t[e + c], c +=
|
|
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 - u;
|
|
41
41
|
else {
|
|
42
42
|
if (o === a)
|
|
43
|
-
return s ? NaN : (
|
|
43
|
+
return s ? NaN : (m ? -1 : 1) * (1 / 0);
|
|
44
44
|
s = s + Math.pow(2, n), o = o - u;
|
|
45
45
|
}
|
|
46
|
-
return (
|
|
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, u = o * 8 - i - 1, h = (1 << u) - 1, c = h >> 1,
|
|
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 +=
|
|
49
|
+
var s, f, a, u = o * 8 - i - 1, h = (1 << u) - 1, c = h >> 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 = 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 + m] = f & 255, m += x, f /= 256, i -= 8)
|
|
51
51
|
;
|
|
52
|
-
for (s = s << i | f, u += i; u > 0; t[r +
|
|
52
|
+
for (s = s << i | f, u += i; u > 0; t[r + m] = s & 255, m += x, s /= 256, u -= 8)
|
|
53
53
|
;
|
|
54
|
-
t[r +
|
|
54
|
+
t[r + m - x] |= y * 128;
|
|
55
55
|
}
|
|
56
56
|
var tr = {}.toString, dt = Array.isArray || function(t) {
|
|
57
57
|
return tr.call(t) == "[object Array]";
|
|
@@ -74,7 +74,7 @@ function l(t, e, r) {
|
|
|
74
74
|
throw new Error(
|
|
75
75
|
"If encoding is specified then the first argument must be a string"
|
|
76
76
|
);
|
|
77
|
-
return
|
|
77
|
+
return ze(this, t);
|
|
78
78
|
}
|
|
79
79
|
return pt(this, t, e, r);
|
|
80
80
|
}
|
|
@@ -103,17 +103,17 @@ function nr(t, e, r, n) {
|
|
|
103
103
|
l.alloc = function(t, e, r) {
|
|
104
104
|
return nr(null, t, e, r);
|
|
105
105
|
};
|
|
106
|
-
function
|
|
107
|
-
if (mt(e), t = q(t, e < 0 ? 0 :
|
|
106
|
+
function ze(t, e) {
|
|
107
|
+
if (mt(e), t = q(t, e < 0 ? 0 : Ve(e) | 0), !l.TYPED_ARRAY_SUPPORT)
|
|
108
108
|
for (var r = 0; r < e; ++r)
|
|
109
109
|
t[r] = 0;
|
|
110
110
|
return t;
|
|
111
111
|
}
|
|
112
112
|
l.allocUnsafe = function(t) {
|
|
113
|
-
return
|
|
113
|
+
return ze(null, t);
|
|
114
114
|
};
|
|
115
115
|
l.allocUnsafeSlow = function(t) {
|
|
116
|
-
return
|
|
116
|
+
return ze(null, t);
|
|
117
117
|
};
|
|
118
118
|
function ir(t, e, r) {
|
|
119
119
|
if ((typeof r != "string" || r === "") && (r = "utf8"), !l.isEncoding(r))
|
|
@@ -124,7 +124,7 @@ function ir(t, e, r) {
|
|
|
124
124
|
return i !== n && (t = t.slice(0, i)), t;
|
|
125
125
|
}
|
|
126
126
|
function Ue(t, e) {
|
|
127
|
-
var r = e.length < 0 ? 0 :
|
|
127
|
+
var r = e.length < 0 ? 0 : Ve(e.length) | 0;
|
|
128
128
|
t = q(t, r);
|
|
129
129
|
for (var n = 0; n < r; n += 1)
|
|
130
130
|
t[n] = e[n] & 255;
|
|
@@ -139,7 +139,7 @@ function or(t, e, r, n) {
|
|
|
139
139
|
}
|
|
140
140
|
function sr(t, e) {
|
|
141
141
|
if ($(e)) {
|
|
142
|
-
var r =
|
|
142
|
+
var r = Ve(e.length) | 0;
|
|
143
143
|
return t = q(t, r), t.length === 0 || e.copy(t, 0, 0, r), t;
|
|
144
144
|
}
|
|
145
145
|
if (e) {
|
|
@@ -150,7 +150,7 @@ function sr(t, e) {
|
|
|
150
150
|
}
|
|
151
151
|
throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.");
|
|
152
152
|
}
|
|
153
|
-
function
|
|
153
|
+
function Ve(t) {
|
|
154
154
|
if (t >= _e())
|
|
155
155
|
throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + _e().toString(16) + " bytes");
|
|
156
156
|
return t | 0;
|
|
@@ -348,8 +348,8 @@ 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(
|
|
352
|
-
return o === 1 ?
|
|
351
|
+
function a(m, x) {
|
|
352
|
+
return o === 1 ? m[x] : m.readUInt16BE(x * o);
|
|
353
353
|
}
|
|
354
354
|
var u;
|
|
355
355
|
if (i) {
|
|
@@ -361,8 +361,8 @@ function Xe(t, e, r, n, i) {
|
|
|
361
361
|
h !== -1 && (u -= u - h), h = -1;
|
|
362
362
|
} else
|
|
363
363
|
for (r + f > s && (r = s - f), u = r; u >= 0; u--) {
|
|
364
|
-
for (var c = !0,
|
|
365
|
-
if (a(t, u +
|
|
364
|
+
for (var c = !0, p = 0; p < f; p++)
|
|
365
|
+
if (a(t, u + p) !== a(e, p)) {
|
|
366
366
|
c = !1;
|
|
367
367
|
break;
|
|
368
368
|
}
|
|
@@ -1126,18 +1126,18 @@ function Mr(t) {
|
|
|
1126
1126
|
}
|
|
1127
1127
|
}
|
|
1128
1128
|
}
|
|
1129
|
-
var
|
|
1129
|
+
var z = [], ne = !1, ee, me = -1;
|
|
1130
1130
|
function Br() {
|
|
1131
|
-
!ne || !ee || (ne = !1, ee.length ?
|
|
1131
|
+
!ne || !ee || (ne = !1, ee.length ? z = ee.concat(z) : me = -1, z.length && Dt());
|
|
1132
1132
|
}
|
|
1133
1133
|
function Dt() {
|
|
1134
1134
|
if (!ne) {
|
|
1135
1135
|
var t = Lt(Br);
|
|
1136
1136
|
ne = !0;
|
|
1137
|
-
for (var e =
|
|
1138
|
-
for (ee =
|
|
1137
|
+
for (var e = z.length; e; ) {
|
|
1138
|
+
for (ee = z, z = []; ++me < e; )
|
|
1139
1139
|
ee && ee[me].run();
|
|
1140
|
-
me = -1, e =
|
|
1140
|
+
me = -1, e = z.length;
|
|
1141
1141
|
}
|
|
1142
1142
|
ee = null, ne = !1, Mr(t);
|
|
1143
1143
|
}
|
|
@@ -1147,7 +1147,7 @@ function U(t) {
|
|
|
1147
1147
|
if (arguments.length > 1)
|
|
1148
1148
|
for (var r = 1; r < arguments.length; r++)
|
|
1149
1149
|
e[r - 1] = arguments[r];
|
|
1150
|
-
|
|
1150
|
+
z.push(new Nt(t, e)), z.length === 1 && !ne && Lt(Dt);
|
|
1151
1151
|
}
|
|
1152
1152
|
function Nt(t, e) {
|
|
1153
1153
|
this.fun = t, this.array = e;
|
|
@@ -1275,7 +1275,7 @@ function jr(t, e) {
|
|
|
1275
1275
|
function qr(t, e) {
|
|
1276
1276
|
return t;
|
|
1277
1277
|
}
|
|
1278
|
-
function
|
|
1278
|
+
function zr(t) {
|
|
1279
1279
|
var e = {};
|
|
1280
1280
|
return t.forEach(function(r, n) {
|
|
1281
1281
|
e[r] = !0;
|
|
@@ -1288,10 +1288,10 @@ function ye(t, e, r) {
|
|
|
1288
1288
|
var n = e.inspect(r, t);
|
|
1289
1289
|
return Ye(n) || (n = ye(t, n, r)), n;
|
|
1290
1290
|
}
|
|
1291
|
-
var i =
|
|
1291
|
+
var i = Vr(t, e);
|
|
1292
1292
|
if (i)
|
|
1293
1293
|
return i;
|
|
1294
|
-
var o = Object.keys(e), s =
|
|
1294
|
+
var o = Object.keys(e), s = zr(o);
|
|
1295
1295
|
if (t.showHidden && (o = Object.getOwnPropertyNames(e)), Le(e) && (o.indexOf("message") >= 0 || o.indexOf("description") >= 0))
|
|
1296
1296
|
return Ae(e);
|
|
1297
1297
|
if (o.length === 0) {
|
|
@@ -1316,12 +1316,12 @@ function ye(t, e, r) {
|
|
|
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
|
-
var
|
|
1320
|
-
return u ?
|
|
1321
|
-
return Pe(t, e, r, s,
|
|
1322
|
-
}), t.seen.pop(), Yr(
|
|
1319
|
+
var p;
|
|
1320
|
+
return u ? p = Jr(t, e, r, s, o) : p = o.map(function(m) {
|
|
1321
|
+
return Pe(t, e, r, s, m, u);
|
|
1322
|
+
}), t.seen.pop(), Yr(p, a, h);
|
|
1323
1323
|
}
|
|
1324
|
-
function
|
|
1324
|
+
function Vr(t, e) {
|
|
1325
1325
|
if (Q(e))
|
|
1326
1326
|
return t.stylize("undefined", "undefined");
|
|
1327
1327
|
if (Ye(e)) {
|
|
@@ -1698,27 +1698,27 @@ C.prototype.pipe = function(t, e) {
|
|
|
1698
1698
|
t.on("drain", a);
|
|
1699
1699
|
var u = !1;
|
|
1700
1700
|
function h() {
|
|
1701
|
-
E("cleanup"), t.removeListener("close", x), t.removeListener("finish",
|
|
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", h), r.removeListener("data", p), u = !0, n.awaitDrain && (!t._writableState || t._writableState.needDrain) && a();
|
|
1702
1702
|
}
|
|
1703
1703
|
var c = !1;
|
|
1704
|
-
r.on("data",
|
|
1705
|
-
function
|
|
1704
|
+
r.on("data", p);
|
|
1705
|
+
function p(I) {
|
|
1706
1706
|
E("ondata"), c = !1;
|
|
1707
1707
|
var v = t.write(I);
|
|
1708
1708
|
v === !1 && !c && ((n.pipesCount === 1 && n.pipes === t || n.pipesCount > 1 && $t(n.pipes, t) !== -1) && !u && (E("false write response, pause", r._readableState.awaitDrain), r._readableState.awaitDrain++, c = !0), r.pause());
|
|
1709
1709
|
}
|
|
1710
|
-
function
|
|
1711
|
-
E("onerror", I), S(), t.removeListener("error",
|
|
1710
|
+
function m(I) {
|
|
1711
|
+
E("onerror", I), S(), t.removeListener("error", m), rn(t, "error") === 0 && t.emit("error", I);
|
|
1712
1712
|
}
|
|
1713
|
-
tn(t, "error",
|
|
1713
|
+
tn(t, "error", m);
|
|
1714
1714
|
function x() {
|
|
1715
|
-
t.removeListener("finish",
|
|
1715
|
+
t.removeListener("finish", y), S();
|
|
1716
1716
|
}
|
|
1717
1717
|
t.once("close", x);
|
|
1718
|
-
function
|
|
1718
|
+
function y() {
|
|
1719
1719
|
E("onfinish"), t.removeListener("close", x), S();
|
|
1720
1720
|
}
|
|
1721
|
-
t.once("finish",
|
|
1721
|
+
t.once("finish", y);
|
|
1722
1722
|
function S() {
|
|
1723
1723
|
E("unpipe"), r.unpipe(t);
|
|
1724
1724
|
}
|
|
@@ -1873,7 +1873,7 @@ function He(t, e) {
|
|
|
1873
1873
|
var i = t.decodeStrings === !1;
|
|
1874
1874
|
this.decodeStrings = !i, this.defaultEncoding = t.defaultEncoding || "utf8", this.length = 0, this.writing = !1, this.corked = 0, this.sync = !0, this.bufferProcessing = !1, this.onwrite = function(o) {
|
|
1875
1875
|
Cn(e, o);
|
|
1876
|
-
}, this.writecb = null, this.writelen = 0, this.bufferedRequest = null, this.lastBufferedRequest = null, this.pendingcb = 0, this.prefinished = !1, this.errorEmitted = !1, this.bufferedRequestCount = 0, this.corkedRequestsFree = new
|
|
1876
|
+
}, this.writecb = null, this.writelen = 0, this.bufferedRequest = null, this.lastBufferedRequest = null, this.pendingcb = 0, this.prefinished = !1, this.errorEmitted = !1, this.bufferedRequestCount = 0, this.corkedRequestsFree = new Vt(this);
|
|
1877
1877
|
}
|
|
1878
1878
|
He.prototype.getBuffer = function() {
|
|
1879
1879
|
for (var e = this.bufferedRequest, r = []; e; )
|
|
@@ -1944,7 +1944,7 @@ function Cn(t, e) {
|
|
|
1944
1944
|
}
|
|
1945
1945
|
}
|
|
1946
1946
|
function it(t, e, r, n) {
|
|
1947
|
-
r || On(t, e), e.pendingcb--, n(),
|
|
1947
|
+
r || On(t, e), e.pendingcb--, n(), zt(t, e);
|
|
1948
1948
|
}
|
|
1949
1949
|
function On(t, e) {
|
|
1950
1950
|
e.length === 0 && e.needDrain && (e.needDrain = !1, t.emit("drain"));
|
|
@@ -1957,7 +1957,7 @@ function jt(t, e) {
|
|
|
1957
1957
|
o.entry = r;
|
|
1958
1958
|
for (var s = 0; r; )
|
|
1959
1959
|
i[s] = r, r = r.next, s += 1;
|
|
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
|
|
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
1963
|
var f = r.chunk, a = r.encoding, u = r.callback, h = e.objectMode ? 1 : f.length;
|
|
@@ -1982,14 +1982,14 @@ function qt(t) {
|
|
|
1982
1982
|
function ot(t, e) {
|
|
1983
1983
|
e.prefinished || (e.prefinished = !0, t.emit("prefinish"));
|
|
1984
1984
|
}
|
|
1985
|
-
function
|
|
1985
|
+
function zt(t, e) {
|
|
1986
1986
|
var r = qt(e);
|
|
1987
1987
|
return r && (e.pendingcb === 0 ? (ot(t, e), e.finished = !0, t.emit("finish")) : ot(t, e)), r;
|
|
1988
1988
|
}
|
|
1989
1989
|
function An(t, e, r) {
|
|
1990
|
-
e.ending = !0,
|
|
1990
|
+
e.ending = !0, zt(t, e), r && (e.finished ? U(r) : t.once("finish", r)), e.ended = !0, t.writable = !1;
|
|
1991
1991
|
}
|
|
1992
|
-
function
|
|
1992
|
+
function Vt(t) {
|
|
1993
1993
|
var e = this;
|
|
1994
1994
|
this.next = null, this.entry = null, this.finish = function(r) {
|
|
1995
1995
|
var n = e.entry;
|
|
@@ -2073,17 +2073,17 @@ function fe(t) {
|
|
|
2073
2073
|
fe.prototype._transform = function(t, e, r) {
|
|
2074
2074
|
r(null, t);
|
|
2075
2075
|
};
|
|
2076
|
-
oe(
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
function
|
|
2076
|
+
oe(V, g);
|
|
2077
|
+
V.Readable = C;
|
|
2078
|
+
V.Writable = L;
|
|
2079
|
+
V.Duplex = B;
|
|
2080
|
+
V.Transform = k;
|
|
2081
|
+
V.PassThrough = fe;
|
|
2082
|
+
V.Stream = V;
|
|
2083
|
+
function V() {
|
|
2084
2084
|
g.call(this);
|
|
2085
2085
|
}
|
|
2086
|
-
|
|
2086
|
+
V.prototype.pipe = function(t, e) {
|
|
2087
2087
|
var r = this;
|
|
2088
2088
|
function n(h) {
|
|
2089
2089
|
t.writable && t.write(h) === !1 && r.pause && r.pause();
|
|
@@ -2113,9 +2113,9 @@ z.prototype.pipe = function(t, e) {
|
|
|
2113
2113
|
const Jt = function(t) {
|
|
2114
2114
|
return typeof t == "object" && t !== null && !Array.isArray(t);
|
|
2115
2115
|
};
|
|
2116
|
-
class
|
|
2116
|
+
class w extends Error {
|
|
2117
2117
|
constructor(e, r, n, ...i) {
|
|
2118
|
-
Array.isArray(r) && (r = r.join(" ").trim()), super(r), Error.captureStackTrace !== void 0 && Error.captureStackTrace(this,
|
|
2118
|
+
Array.isArray(r) && (r = r.join(" ").trim()), super(r), Error.captureStackTrace !== void 0 && Error.captureStackTrace(this, w), this.code = e;
|
|
2119
2119
|
for (const o of i)
|
|
2120
2120
|
for (const s in o) {
|
|
2121
2121
|
const f = o[s];
|
|
@@ -2133,14 +2133,14 @@ const Yt = function(t) {
|
|
|
2133
2133
|
e[r] = { name: i };
|
|
2134
2134
|
else if (Jt(i)) {
|
|
2135
2135
|
if (typeof i.name != "string")
|
|
2136
|
-
throw new
|
|
2136
|
+
throw new w("CSV_OPTION_COLUMNS_MISSING_NAME", [
|
|
2137
2137
|
"Option columns missing name:",
|
|
2138
2138
|
`property "name" is required at position ${r}`,
|
|
2139
2139
|
"when column is an object literal"
|
|
2140
2140
|
]);
|
|
2141
2141
|
e[r] = i;
|
|
2142
2142
|
} else
|
|
2143
|
-
throw new
|
|
2143
|
+
throw new w("CSV_INVALID_COLUMN_DEFINITION", [
|
|
2144
2144
|
"Invalid column definition:",
|
|
2145
2145
|
"expect a string or a literal object,",
|
|
2146
2146
|
`got ${JSON.stringify(i)} at position ${r}`
|
|
@@ -2246,7 +2246,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2246
2246
|
else if (e.encoding === null || e.encoding === !1)
|
|
2247
2247
|
e.encoding = null;
|
|
2248
2248
|
else if (typeof e.encoding != "string" && e.encoding !== null)
|
|
2249
|
-
throw new
|
|
2249
|
+
throw new w(
|
|
2250
2250
|
"CSV_INVALID_OPTION_ENCODING",
|
|
2251
2251
|
[
|
|
2252
2252
|
"Invalid option encoding:",
|
|
@@ -2258,7 +2258,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2258
2258
|
if (e.bom === void 0 || e.bom === null || e.bom === !1)
|
|
2259
2259
|
e.bom = !1;
|
|
2260
2260
|
else if (e.bom !== !0)
|
|
2261
|
-
throw new
|
|
2261
|
+
throw new w(
|
|
2262
2262
|
"CSV_INVALID_OPTION_BOM",
|
|
2263
2263
|
[
|
|
2264
2264
|
"Invalid option bom:",
|
|
@@ -2272,7 +2272,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2272
2272
|
else if (typeof e.cast == "function")
|
|
2273
2273
|
e.cast_function = e.cast, e.cast = !0;
|
|
2274
2274
|
else if (e.cast !== !0)
|
|
2275
|
-
throw new
|
|
2275
|
+
throw new w(
|
|
2276
2276
|
"CSV_INVALID_OPTION_CAST",
|
|
2277
2277
|
[
|
|
2278
2278
|
"Invalid option cast:",
|
|
@@ -2289,7 +2289,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2289
2289
|
return isNaN(i) ? n : new Date(i);
|
|
2290
2290
|
};
|
|
2291
2291
|
else if (typeof e.cast_date != "function")
|
|
2292
|
-
throw new
|
|
2292
|
+
throw new w(
|
|
2293
2293
|
"CSV_INVALID_OPTION_CAST_DATE",
|
|
2294
2294
|
[
|
|
2295
2295
|
"Invalid option cast_date:",
|
|
@@ -2307,7 +2307,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2307
2307
|
else if (e.columns === void 0 || e.columns === null || e.columns === !1)
|
|
2308
2308
|
e.columns = !1;
|
|
2309
2309
|
else
|
|
2310
|
-
throw new
|
|
2310
|
+
throw new w(
|
|
2311
2311
|
"CSV_INVALID_OPTION_COLUMNS",
|
|
2312
2312
|
[
|
|
2313
2313
|
"Invalid option columns:",
|
|
@@ -2320,7 +2320,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2320
2320
|
e.group_columns_by_name = !1;
|
|
2321
2321
|
else {
|
|
2322
2322
|
if (e.group_columns_by_name !== !0)
|
|
2323
|
-
throw new
|
|
2323
|
+
throw new w(
|
|
2324
2324
|
"CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME",
|
|
2325
2325
|
[
|
|
2326
2326
|
"Invalid option group_columns_by_name:",
|
|
@@ -2330,7 +2330,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2330
2330
|
e
|
|
2331
2331
|
);
|
|
2332
2332
|
if (e.columns === !1)
|
|
2333
|
-
throw new
|
|
2333
|
+
throw new w(
|
|
2334
2334
|
"CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME",
|
|
2335
2335
|
[
|
|
2336
2336
|
"Invalid option group_columns_by_name:",
|
|
@@ -2342,7 +2342,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2342
2342
|
if (e.comment === void 0 || e.comment === null || e.comment === !1 || e.comment === "")
|
|
2343
2343
|
e.comment = null;
|
|
2344
2344
|
else if (typeof e.comment == "string" && (e.comment = l.from(e.comment, e.encoding)), !D(e.comment))
|
|
2345
|
-
throw new
|
|
2345
|
+
throw new w(
|
|
2346
2346
|
"CSV_INVALID_OPTION_COMMENT",
|
|
2347
2347
|
[
|
|
2348
2348
|
"Invalid option comment:",
|
|
@@ -2354,7 +2354,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2354
2354
|
if (e.comment_no_infix === void 0 || e.comment_no_infix === null || e.comment_no_infix === !1)
|
|
2355
2355
|
e.comment_no_infix = !1;
|
|
2356
2356
|
else if (e.comment_no_infix !== !0)
|
|
2357
|
-
throw new
|
|
2357
|
+
throw new w(
|
|
2358
2358
|
"CSV_INVALID_OPTION_COMMENT",
|
|
2359
2359
|
[
|
|
2360
2360
|
"Invalid option comment_no_infix:",
|
|
@@ -2365,7 +2365,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2365
2365
|
);
|
|
2366
2366
|
const r = JSON.stringify(e.delimiter);
|
|
2367
2367
|
if (Array.isArray(e.delimiter) || (e.delimiter = [e.delimiter]), e.delimiter.length === 0)
|
|
2368
|
-
throw new
|
|
2368
|
+
throw new w(
|
|
2369
2369
|
"CSV_INVALID_OPTION_DELIMITER",
|
|
2370
2370
|
[
|
|
2371
2371
|
"Invalid option delimiter:",
|
|
@@ -2378,7 +2378,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2378
2378
|
if (n == null || n === !1)
|
|
2379
2379
|
return l.from(",", e.encoding);
|
|
2380
2380
|
if (typeof n == "string" && (n = l.from(n, e.encoding)), !D(n) || n.length === 0)
|
|
2381
|
-
throw new
|
|
2381
|
+
throw new w(
|
|
2382
2382
|
"CSV_INVALID_OPTION_DELIMITER",
|
|
2383
2383
|
[
|
|
2384
2384
|
"Invalid option delimiter:",
|
|
@@ -2419,7 +2419,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2419
2419
|
else if (typeof e.ignore_last_delimiters == "number")
|
|
2420
2420
|
e.ignore_last_delimiters = Math.floor(e.ignore_last_delimiters), e.ignore_last_delimiters === 0 && (e.ignore_last_delimiters = !1);
|
|
2421
2421
|
else if (typeof e.ignore_last_delimiters != "boolean")
|
|
2422
|
-
throw new
|
|
2422
|
+
throw new w(
|
|
2423
2423
|
"CSV_INVALID_OPTION_IGNORE_LAST_DELIMITERS",
|
|
2424
2424
|
[
|
|
2425
2425
|
"Invalid option `ignore_last_delimiters`:",
|
|
@@ -2429,7 +2429,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2429
2429
|
e
|
|
2430
2430
|
);
|
|
2431
2431
|
if (e.ignore_last_delimiters === !0 && e.columns === !1)
|
|
2432
|
-
throw new
|
|
2432
|
+
throw new w(
|
|
2433
2433
|
"CSV_IGNORE_LAST_DELIMITERS_REQUIRES_COLUMNS",
|
|
2434
2434
|
[
|
|
2435
2435
|
"The option `ignore_last_delimiters`",
|
|
@@ -2477,7 +2477,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2477
2477
|
if (e.on_record === void 0 || e.on_record === null)
|
|
2478
2478
|
e.on_record = void 0;
|
|
2479
2479
|
else if (typeof e.on_record != "function")
|
|
2480
|
-
throw new
|
|
2480
|
+
throw new w(
|
|
2481
2481
|
"CSV_INVALID_OPTION_ON_RECORD",
|
|
2482
2482
|
[
|
|
2483
2483
|
"Invalid option `on_record`:",
|
|
@@ -2506,7 +2506,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2506
2506
|
e.record_delimiter = [];
|
|
2507
2507
|
else if (typeof e.record_delimiter == "string" || D(e.record_delimiter)) {
|
|
2508
2508
|
if (e.record_delimiter.length === 0)
|
|
2509
|
-
throw new
|
|
2509
|
+
throw new w(
|
|
2510
2510
|
"CSV_INVALID_OPTION_RECORD_DELIMITER",
|
|
2511
2511
|
[
|
|
2512
2512
|
"Invalid option `record_delimiter`:",
|
|
@@ -2517,7 +2517,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2517
2517
|
);
|
|
2518
2518
|
e.record_delimiter = [e.record_delimiter];
|
|
2519
2519
|
} else if (!Array.isArray(e.record_delimiter))
|
|
2520
|
-
throw new
|
|
2520
|
+
throw new w(
|
|
2521
2521
|
"CSV_INVALID_OPTION_RECORD_DELIMITER",
|
|
2522
2522
|
[
|
|
2523
2523
|
"Invalid option `record_delimiter`:",
|
|
@@ -2528,7 +2528,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2528
2528
|
);
|
|
2529
2529
|
if (e.record_delimiter = e.record_delimiter.map(function(n, i) {
|
|
2530
2530
|
if (typeof n != "string" && !D(n))
|
|
2531
|
-
throw new
|
|
2531
|
+
throw new w(
|
|
2532
2532
|
"CSV_INVALID_OPTION_RECORD_DELIMITER",
|
|
2533
2533
|
[
|
|
2534
2534
|
"Invalid option `record_delimiter`:",
|
|
@@ -2539,7 +2539,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2539
2539
|
e
|
|
2540
2540
|
);
|
|
2541
2541
|
if (n.length === 0)
|
|
2542
|
-
throw new
|
|
2542
|
+
throw new w(
|
|
2543
2543
|
"CSV_INVALID_OPTION_RECORD_DELIMITER",
|
|
2544
2544
|
[
|
|
2545
2545
|
"Invalid option `record_delimiter`:",
|
|
@@ -2649,7 +2649,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2649
2649
|
// Buffer.from "\ufeff", 'utf16le
|
|
2650
2650
|
// Buffer.from([255, 254])
|
|
2651
2651
|
utf16le: l.from([255, 254])
|
|
2652
|
-
},
|
|
2652
|
+
}, zn = function(t = {}) {
|
|
2653
2653
|
const e = {
|
|
2654
2654
|
bytes: 0,
|
|
2655
2655
|
comment_lines: 0,
|
|
@@ -2665,7 +2665,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2665
2665
|
state: Pn(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: u, needMoreDataSize: h, recordDelimiterMaxLength: c } = this.state,
|
|
2668
|
+
const { encoding: s, escape: f, quote: a } = this.options, { quoting: u, needMoreDataSize: h, recordDelimiterMaxLength: c } = this.state, p = i - n - 1, m = Math.max(
|
|
2669
2669
|
h,
|
|
2670
2670
|
// Skip if the remaining buffer smaller than record delimiter
|
|
2671
2671
|
// If "record_delimiter" is yet to be discovered:
|
|
@@ -2680,7 +2680,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2680
2680
|
// Skip if remaining buffer can be record delimiter following the closing quote
|
|
2681
2681
|
u ? a.length + c : 0
|
|
2682
2682
|
);
|
|
2683
|
-
return
|
|
2683
|
+
return p < m;
|
|
2684
2684
|
},
|
|
2685
2685
|
// Central parser implementation
|
|
2686
2686
|
parse: function(n, i, o, s) {
|
|
@@ -2690,15 +2690,15 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2690
2690
|
encoding: u,
|
|
2691
2691
|
from_line: h,
|
|
2692
2692
|
ltrim: c,
|
|
2693
|
-
max_record_size:
|
|
2694
|
-
raw:
|
|
2693
|
+
max_record_size: p,
|
|
2694
|
+
raw: m,
|
|
2695
2695
|
relax_quotes: x,
|
|
2696
|
-
rtrim:
|
|
2696
|
+
rtrim: y,
|
|
2697
2697
|
skip_empty_lines: S,
|
|
2698
2698
|
to: I,
|
|
2699
2699
|
to_line: v
|
|
2700
2700
|
} = this.options;
|
|
2701
|
-
let { comment:
|
|
2701
|
+
let { comment: _, escape: R, quote: F, record_delimiter: Re } = this.options;
|
|
2702
2702
|
const { bomSkipped: Qt, previousBuf: ce, rawBuffer: Ht, escapeIsQuote: Gt } = this.state;
|
|
2703
2703
|
let b;
|
|
2704
2704
|
if (ce === void 0)
|
|
@@ -2727,51 +2727,51 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2727
2727
|
});
|
|
2728
2728
|
for (const A in he)
|
|
2729
2729
|
this.options[A] = he[A];
|
|
2730
|
-
({ comment:
|
|
2730
|
+
({ comment: _, escape: R, quote: F } = this.options);
|
|
2731
2731
|
break;
|
|
2732
2732
|
}
|
|
2733
2733
|
this.state.bomSkipped = !0;
|
|
2734
2734
|
}
|
|
2735
2735
|
const Ie = b.length;
|
|
2736
|
-
let
|
|
2737
|
-
for (
|
|
2736
|
+
let d;
|
|
2737
|
+
for (d = 0; d < Ie && !this.__needMoreData(d, Ie, i); d++) {
|
|
2738
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 O = b[
|
|
2747
|
-
if (
|
|
2746
|
+
const O = b[d];
|
|
2747
|
+
if (m === !0 && Ht.append(O), (O === jn || O === qn) && this.state.wasRowDelimiter === !1 && (this.state.wasRowDelimiter = !0), this.state.escaping === !0)
|
|
2748
2748
|
this.state.escaping = !1;
|
|
2749
2749
|
else {
|
|
2750
|
-
if (R !== null && this.state.quoting === !0 && this.__isEscape(b,
|
|
2750
|
+
if (R !== null && this.state.quoting === !0 && this.__isEscape(b, d, O) && d + R.length < Ie)
|
|
2751
2751
|
if (Gt) {
|
|
2752
|
-
if (this.__isQuote(b,
|
|
2753
|
-
this.state.escaping = !0,
|
|
2752
|
+
if (this.__isQuote(b, d + R.length)) {
|
|
2753
|
+
this.state.escaping = !0, d += R.length - 1;
|
|
2754
2754
|
continue;
|
|
2755
2755
|
}
|
|
2756
2756
|
} else {
|
|
2757
|
-
this.state.escaping = !0,
|
|
2757
|
+
this.state.escaping = !0, d += R.length - 1;
|
|
2758
2758
|
continue;
|
|
2759
2759
|
}
|
|
2760
|
-
if (this.state.commenting === !1 && this.__isQuote(b,
|
|
2760
|
+
if (this.state.commenting === !1 && this.__isQuote(b, d))
|
|
2761
2761
|
if (this.state.quoting === !0) {
|
|
2762
|
-
const A = b[
|
|
2762
|
+
const A = b[d + F.length], Z = y && this.__isCharTrimable(b, d + F.length), j = _ !== null && this.__compareBytes(_, b, d + F.length, A), X = this.__isDelimiter(
|
|
2763
2763
|
b,
|
|
2764
|
-
|
|
2764
|
+
d + F.length,
|
|
2765
2765
|
A
|
|
2766
|
-
), de = Re.length === 0 ? this.__autoDiscoverRecordDelimiter(b,
|
|
2767
|
-
if (R !== null && this.__isEscape(b,
|
|
2768
|
-
|
|
2766
|
+
), de = Re.length === 0 ? this.__autoDiscoverRecordDelimiter(b, d + F.length) : this.__isRecordDelimiter(A, b, d + F.length);
|
|
2767
|
+
if (R !== null && this.__isEscape(b, d, O) && this.__isQuote(b, d + R.length))
|
|
2768
|
+
d += R.length - 1;
|
|
2769
2769
|
else if (!A || X || de || j || Z) {
|
|
2770
|
-
this.state.quoting = !1, this.state.wasQuoting = !0,
|
|
2770
|
+
this.state.quoting = !1, this.state.wasQuoting = !0, d += F.length - 1;
|
|
2771
2771
|
continue;
|
|
2772
2772
|
} else if (x === !1) {
|
|
2773
2773
|
const Ge = this.__error(
|
|
2774
|
-
new
|
|
2774
|
+
new w(
|
|
2775
2775
|
"CSV_INVALID_CLOSING_QUOTE",
|
|
2776
2776
|
[
|
|
2777
2777
|
"Invalid Closing Quote:",
|
|
@@ -2786,13 +2786,13 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2786
2786
|
);
|
|
2787
2787
|
if (Ge !== void 0) return Ge;
|
|
2788
2788
|
} else
|
|
2789
|
-
this.state.quoting = !1, this.state.wasQuoting = !0, this.state.field.prepend(F),
|
|
2789
|
+
this.state.quoting = !1, this.state.wasQuoting = !0, this.state.field.prepend(F), d += F.length - 1;
|
|
2790
2790
|
} else if (this.state.field.length !== 0) {
|
|
2791
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(
|
|
2795
|
-
new
|
|
2795
|
+
new w(
|
|
2796
2796
|
"INVALID_OPENING_QUOTE",
|
|
2797
2797
|
[
|
|
2798
2798
|
"Invalid Opening Quote:",
|
|
@@ -2809,31 +2809,31 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2809
2809
|
if (j !== void 0) return j;
|
|
2810
2810
|
}
|
|
2811
2811
|
} else {
|
|
2812
|
-
this.state.quoting = !0,
|
|
2812
|
+
this.state.quoting = !0, d += F.length - 1;
|
|
2813
2813
|
continue;
|
|
2814
2814
|
}
|
|
2815
2815
|
if (this.state.quoting === !1) {
|
|
2816
2816
|
const A = this.__isRecordDelimiter(
|
|
2817
2817
|
O,
|
|
2818
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
2825
|
if (this.state.enabled === !1 && this.info.lines + (this.state.wasRowDelimiter === !0 ? 1 : 0) >= h) {
|
|
2826
|
-
this.state.enabled = !0, this.__resetField(), this.__resetRecord(),
|
|
2826
|
+
this.state.enabled = !0, this.__resetField(), this.__resetRecord(), d += A - 1;
|
|
2827
2827
|
continue;
|
|
2828
2828
|
}
|
|
2829
2829
|
if (S === !0 && this.state.wasQuoting === !1 && this.state.record.length === 0 && this.state.field.length === 0) {
|
|
2830
|
-
this.info.empty_lines++,
|
|
2830
|
+
this.info.empty_lines++, d += A - 1;
|
|
2831
2831
|
continue;
|
|
2832
2832
|
}
|
|
2833
|
-
this.info.bytes = this.state.bufBytesStart +
|
|
2833
|
+
this.info.bytes = this.state.bufBytesStart + d;
|
|
2834
2834
|
const X = this.__onField();
|
|
2835
2835
|
if (X !== void 0) return X;
|
|
2836
|
-
this.info.bytes = this.state.bufBytesStart +
|
|
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
2839
|
if (I !== -1 && this.info.records >= I) {
|
|
@@ -2841,46 +2841,46 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2841
2841
|
return;
|
|
2842
2842
|
}
|
|
2843
2843
|
}
|
|
2844
|
-
this.state.commenting = !1,
|
|
2844
|
+
this.state.commenting = !1, d += A - 1;
|
|
2845
2845
|
continue;
|
|
2846
2846
|
}
|
|
2847
2847
|
if (this.state.commenting)
|
|
2848
2848
|
continue;
|
|
2849
|
-
if (
|
|
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(b,
|
|
2853
|
+
const Z = this.__isDelimiter(b, d, O);
|
|
2854
2854
|
if (Z !== 0) {
|
|
2855
|
-
this.info.bytes = this.state.bufBytesStart +
|
|
2855
|
+
this.info.bytes = this.state.bufBytesStart + d;
|
|
2856
2856
|
const j = this.__onField();
|
|
2857
2857
|
if (j !== void 0) return j;
|
|
2858
|
-
|
|
2858
|
+
d += Z - 1;
|
|
2859
2859
|
continue;
|
|
2860
2860
|
}
|
|
2861
2861
|
}
|
|
2862
2862
|
}
|
|
2863
|
-
if (this.state.commenting === !1 &&
|
|
2863
|
+
if (this.state.commenting === !1 && p !== 0 && this.state.record_length + this.state.field.length > p)
|
|
2864
2864
|
return this.__error(
|
|
2865
|
-
new
|
|
2865
|
+
new w(
|
|
2866
2866
|
"CSV_MAX_RECORD_SIZE",
|
|
2867
2867
|
[
|
|
2868
2868
|
"Max Record Size:",
|
|
2869
2869
|
"record exceed the maximum number of tolerated bytes",
|
|
2870
|
-
`of ${
|
|
2870
|
+
`of ${p}`,
|
|
2871
2871
|
`at line ${this.info.lines}`
|
|
2872
2872
|
],
|
|
2873
2873
|
this.options,
|
|
2874
2874
|
this.__infoField()
|
|
2875
2875
|
)
|
|
2876
2876
|
);
|
|
2877
|
-
const J = c === !1 || this.state.quoting === !0 || this.state.field.length !== 0 || !this.__isCharTrimable(b,
|
|
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
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
|
-
new
|
|
2883
|
+
new w(
|
|
2884
2884
|
"CSV_NON_TRIMABLE_CHAR_AFTER_CLOSING_QUOTE",
|
|
2885
2885
|
[
|
|
2886
2886
|
"Invalid Closing Quote:",
|
|
@@ -2891,14 +2891,14 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2891
2891
|
this.__infoField()
|
|
2892
2892
|
)
|
|
2893
2893
|
);
|
|
2894
|
-
J === !1 && (
|
|
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
2900
|
const O = this.__error(
|
|
2901
|
-
new
|
|
2901
|
+
new w(
|
|
2902
2902
|
"CSV_QUOTE_NOT_CLOSED",
|
|
2903
2903
|
[
|
|
2904
2904
|
"Quote Not Closed:",
|
|
@@ -2910,14 +2910,14 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2910
2910
|
);
|
|
2911
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
|
-
this.info.bytes = this.state.bufBytesStart +
|
|
2913
|
+
this.info.bytes = this.state.bufBytesStart + d;
|
|
2914
2914
|
const O = this.__onField();
|
|
2915
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 +=
|
|
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) {
|
|
@@ -2930,21 +2930,21 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2930
2930
|
relax_column_count: u,
|
|
2931
2931
|
relax_column_count_less: h,
|
|
2932
2932
|
relax_column_count_more: c,
|
|
2933
|
-
raw:
|
|
2934
|
-
skip_records_with_empty_values:
|
|
2935
|
-
} = this.options, { enabled: x, record:
|
|
2933
|
+
raw: p,
|
|
2934
|
+
skip_records_with_empty_values: m
|
|
2935
|
+
} = this.options, { enabled: x, record: y } = this.state;
|
|
2936
2936
|
if (x === !1)
|
|
2937
2937
|
return this.__resetRecord();
|
|
2938
|
-
const S =
|
|
2938
|
+
const S = y.length;
|
|
2939
2939
|
if (i === !0) {
|
|
2940
|
-
if (
|
|
2940
|
+
if (m === !0 && ut(y)) {
|
|
2941
2941
|
this.__resetRecord();
|
|
2942
2942
|
return;
|
|
2943
2943
|
}
|
|
2944
|
-
return this.__firstLineToColumns(
|
|
2944
|
+
return this.__firstLineToColumns(y);
|
|
2945
2945
|
}
|
|
2946
2946
|
if (i === !1 && this.info.records === 0 && (this.state.expectedRecordLength = S), S !== this.state.expectedRecordLength) {
|
|
2947
|
-
const I = i === !1 ? new
|
|
2947
|
+
const I = i === !1 ? new w(
|
|
2948
2948
|
"CSV_RECORD_INCONSISTENT_FIELDS_LENGTH",
|
|
2949
2949
|
[
|
|
2950
2950
|
"Invalid Record Length:",
|
|
@@ -2954,9 +2954,9 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2954
2954
|
this.options,
|
|
2955
2955
|
this.__infoField(),
|
|
2956
2956
|
{
|
|
2957
|
-
record:
|
|
2957
|
+
record: y
|
|
2958
2958
|
}
|
|
2959
|
-
) : new
|
|
2959
|
+
) : new w(
|
|
2960
2960
|
"CSV_RECORD_INCONSISTENT_COLUMNS",
|
|
2961
2961
|
[
|
|
2962
2962
|
"Invalid Record Length:",
|
|
@@ -2967,7 +2967,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2967
2967
|
this.options,
|
|
2968
2968
|
this.__infoField(),
|
|
2969
2969
|
{
|
|
2970
|
-
record:
|
|
2970
|
+
record: y
|
|
2971
2971
|
}
|
|
2972
2972
|
);
|
|
2973
2973
|
if (u === !0 || h === !0 && S < this.state.expectedRecordLength || c === !0 && S > this.state.expectedRecordLength)
|
|
@@ -2977,7 +2977,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2977
2977
|
if (v) return v;
|
|
2978
2978
|
}
|
|
2979
2979
|
}
|
|
2980
|
-
if (
|
|
2980
|
+
if (m === !0 && ut(y)) {
|
|
2981
2981
|
this.__resetRecord();
|
|
2982
2982
|
return;
|
|
2983
2983
|
}
|
|
@@ -2989,41 +2989,41 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
2989
2989
|
const { objname: I } = this.options;
|
|
2990
2990
|
if (i !== !1) {
|
|
2991
2991
|
const v = {};
|
|
2992
|
-
for (let
|
|
2993
|
-
i[
|
|
2994
|
-
if (
|
|
2995
|
-
const
|
|
2992
|
+
for (let _ = 0, R = y.length; _ < R; _++)
|
|
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
|
+
if (p === !0 || f === !0) {
|
|
2995
|
+
const _ = Object.assign(
|
|
2996
2996
|
{ record: v },
|
|
2997
|
-
|
|
2997
|
+
p === !0 ? { raw: this.state.rawBuffer.toString(s) } : {},
|
|
2998
2998
|
f === !0 ? { info: this.__infoRecord() } : {}
|
|
2999
2999
|
), R = this.__push(
|
|
3000
|
-
I === void 0 ?
|
|
3000
|
+
I === void 0 ? _ : [v[I], _],
|
|
3001
3001
|
n
|
|
3002
3002
|
);
|
|
3003
3003
|
if (R)
|
|
3004
3004
|
return R;
|
|
3005
3005
|
} else {
|
|
3006
|
-
const
|
|
3006
|
+
const _ = this.__push(
|
|
3007
3007
|
I === void 0 ? v : [v[I], v],
|
|
3008
3008
|
n
|
|
3009
3009
|
);
|
|
3010
|
-
if (
|
|
3011
|
-
return
|
|
3010
|
+
if (_)
|
|
3011
|
+
return _;
|
|
3012
3012
|
}
|
|
3013
|
-
} else if (
|
|
3013
|
+
} else if (p === !0 || f === !0) {
|
|
3014
3014
|
const v = Object.assign(
|
|
3015
|
-
{ record:
|
|
3016
|
-
|
|
3015
|
+
{ record: y },
|
|
3016
|
+
p === !0 ? { raw: this.state.rawBuffer.toString(s) } : {},
|
|
3017
3017
|
f === !0 ? { info: this.__infoRecord() } : {}
|
|
3018
|
-
),
|
|
3019
|
-
I === void 0 ? v : [
|
|
3018
|
+
), _ = this.__push(
|
|
3019
|
+
I === void 0 ? v : [y[I], v],
|
|
3020
3020
|
n
|
|
3021
3021
|
);
|
|
3022
|
-
if (
|
|
3023
|
-
return
|
|
3022
|
+
if (_)
|
|
3023
|
+
return _;
|
|
3024
3024
|
} else {
|
|
3025
3025
|
const v = this.__push(
|
|
3026
|
-
I === void 0 ?
|
|
3026
|
+
I === void 0 ? y : [y[I], y],
|
|
3027
3027
|
n
|
|
3028
3028
|
);
|
|
3029
3029
|
if (v)
|
|
@@ -3038,7 +3038,7 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
3038
3038
|
const o = i === void 0 ? n : i.call(null, n);
|
|
3039
3039
|
if (!Array.isArray(o))
|
|
3040
3040
|
return this.__error(
|
|
3041
|
-
new
|
|
3041
|
+
new w(
|
|
3042
3042
|
"CSV_INVALID_COLUMN_MAPPING",
|
|
3043
3043
|
[
|
|
3044
3044
|
"Invalid Column Mapping:",
|
|
@@ -3250,9 +3250,9 @@ const Fn = 12, Mn = 13, Bn = 10, Un = 32, kn = 9, Pn = function(t) {
|
|
|
3250
3250
|
}
|
|
3251
3251
|
};
|
|
3252
3252
|
};
|
|
3253
|
-
class
|
|
3253
|
+
class Vn extends k {
|
|
3254
3254
|
constructor(e = {}) {
|
|
3255
|
-
super({ readableObjectMode: !0, ...e, encoding: null }), this.api =
|
|
3255
|
+
super({ readableObjectMode: !0, ...e, encoding: null }), this.api = zn({
|
|
3256
3256
|
on_skip: (r, n) => {
|
|
3257
3257
|
this.emit("skip", r, n);
|
|
3258
3258
|
},
|
|
@@ -3303,13 +3303,13 @@ const je = function() {
|
|
|
3303
3303
|
else if (r === void 0 && s === "function")
|
|
3304
3304
|
r = o;
|
|
3305
3305
|
else
|
|
3306
|
-
throw new
|
|
3306
|
+
throw new w(
|
|
3307
3307
|
"CSV_INVALID_ARGUMENT",
|
|
3308
3308
|
["Invalid argument:", `got ${JSON.stringify(o)} at index ${i}`],
|
|
3309
3309
|
e || {}
|
|
3310
3310
|
);
|
|
3311
3311
|
}
|
|
3312
|
-
const n = new
|
|
3312
|
+
const n = new Vn(e);
|
|
3313
3313
|
if (r) {
|
|
3314
3314
|
const i = e === void 0 || e.objname === void 0 ? [] : {};
|
|
3315
3315
|
n.on("readable", function() {
|
|
@@ -3411,7 +3411,7 @@ const Wt = {
|
|
|
3411
3411
|
skip_records_with_empty_values: !1,
|
|
3412
3412
|
skip_records_with_error: !1,
|
|
3413
3413
|
to: void 0,
|
|
3414
|
-
//
|
|
3414
|
+
// Assigning documented default value of 1 triggers error `TypeError: "listener" argument must be a function`.
|
|
3415
3415
|
to_line: -1,
|
|
3416
3416
|
trim: !1
|
|
3417
3417
|
}, Zn = 1e4, Xn = 4;
|
|
@@ -3421,48 +3421,29 @@ class ni {
|
|
|
3421
3421
|
return je(e);
|
|
3422
3422
|
}
|
|
3423
3423
|
/**
|
|
3424
|
-
*
|
|
3424
|
+
* Parse preview.
|
|
3425
3425
|
*/
|
|
3426
|
-
async
|
|
3427
|
-
const
|
|
3428
|
-
|
|
3429
|
-
const d = e.inferValues(c, f);
|
|
3430
|
-
a.push(d);
|
|
3431
|
-
}
|
|
3432
|
-
let u = 0;
|
|
3433
|
-
const h = a[0];
|
|
3434
|
-
if (h) {
|
|
3435
|
-
const c = h.length;
|
|
3436
|
-
for (let d = 0; d < c; d++) {
|
|
3437
|
-
const p = h[d]?.inferredValue, x = p == null ? `Column ${d}` : String(p), _ = f[d];
|
|
3438
|
-
_ != null && (_.label = { en: x });
|
|
3439
|
-
}
|
|
3440
|
-
u = 1;
|
|
3441
|
-
}
|
|
3442
|
-
for (let c = u; c < a.length; c++) {
|
|
3443
|
-
const d = a[c] ?? [];
|
|
3444
|
-
for (let p = 0; p < d.length; p++)
|
|
3445
|
-
f[p];
|
|
3446
|
-
}
|
|
3447
|
-
return { recordDelimiterId: i, valueDelimiterId: s, parsingRecords: o, inferenceRecords: a, columnConfigs: f };
|
|
3426
|
+
async parsePreview(e, r) {
|
|
3427
|
+
const n = Kn(e), { parsingRecords: i, valueDelimiterId: o } = await ei(e, r);
|
|
3428
|
+
return { parsingRecords: i, recordDelimiterId: n, valueDelimiterId: o };
|
|
3448
3429
|
}
|
|
3449
3430
|
/**
|
|
3450
3431
|
* Parse stream.
|
|
3451
3432
|
*/
|
|
3452
3433
|
async parseStream(e, r, n, i, o) {
|
|
3453
3434
|
return new Promise((s, f) => {
|
|
3454
|
-
let a, u, h, c = !1,
|
|
3455
|
-
const
|
|
3456
|
-
if (
|
|
3457
|
-
|
|
3435
|
+
let a, u, h, c = !1, p = !1;
|
|
3436
|
+
const m = () => {
|
|
3437
|
+
if (p) return;
|
|
3438
|
+
p = !0;
|
|
3458
3439
|
const S = a;
|
|
3459
3440
|
a = void 0, h = void 0, S != null && (Be(() => S.removeAllListeners()), Be(() => S.end())), Be(() => {
|
|
3460
3441
|
u?.cancel();
|
|
3461
3442
|
}), u = void 0;
|
|
3462
3443
|
};
|
|
3463
|
-
i.signal.addEventListener("abort",
|
|
3444
|
+
i.signal.addEventListener("abort", m, { once: !0 });
|
|
3464
3445
|
const x = (S) => {
|
|
3465
|
-
c || (c = !0,
|
|
3446
|
+
c || (c = !0, m(), i.signal.aborted || i.abort(S), f(S));
|
|
3466
3447
|
};
|
|
3467
3448
|
(async () => {
|
|
3468
3449
|
a = je({
|
|
@@ -3496,8 +3477,8 @@ class ni {
|
|
|
3496
3477
|
R.length > 0 && a.write(R), v = await u.read();
|
|
3497
3478
|
}
|
|
3498
3479
|
if (c) return;
|
|
3499
|
-
const
|
|
3500
|
-
|
|
3480
|
+
const _ = I.decode();
|
|
3481
|
+
_.length > 0 && a.write(_), a.end();
|
|
3501
3482
|
})().catch((S) => x(S));
|
|
3502
3483
|
});
|
|
3503
3484
|
}
|
|
@@ -3516,26 +3497,26 @@ async function ei(t, e) {
|
|
|
3516
3497
|
let f = 0, a, u = 0, h = 0;
|
|
3517
3498
|
const c = je({
|
|
3518
3499
|
...Wt,
|
|
3519
|
-
cast: (
|
|
3500
|
+
cast: (p, m) => ({ value: p, wasValueQuoted: m.quoting }),
|
|
3520
3501
|
delimiter: s,
|
|
3521
3502
|
relax_column_count: !0
|
|
3522
3503
|
});
|
|
3523
|
-
await new Promise((
|
|
3504
|
+
await new Promise((p) => {
|
|
3524
3505
|
try {
|
|
3525
|
-
const
|
|
3506
|
+
const m = [];
|
|
3526
3507
|
c.on("readable", () => {
|
|
3527
3508
|
let x;
|
|
3528
3509
|
for (; (x = c.read()) != null; ) {
|
|
3529
3510
|
u++;
|
|
3530
|
-
const
|
|
3531
|
-
a != null && (h += Math.abs(
|
|
3511
|
+
const y = x.length;
|
|
3512
|
+
a != null && (h += Math.abs(y - a)), a = y, f += y, m.push(x);
|
|
3532
3513
|
}
|
|
3533
|
-
}), c.on("error", () =>
|
|
3514
|
+
}), c.on("error", () => p()), c.on("end", () => {
|
|
3534
3515
|
const x = f / u;
|
|
3535
|
-
(!i || h <= i) && (!n || x > n) && (r = s, n = x, i = h, o = [...
|
|
3516
|
+
(!i || h <= i) && (!n || x > n) && (r = s, n = x, i = h, o = [...m]), p();
|
|
3536
3517
|
}), c.write(t), c.end();
|
|
3537
3518
|
} catch {
|
|
3538
|
-
|
|
3519
|
+
p();
|
|
3539
3520
|
}
|
|
3540
3521
|
});
|
|
3541
3522
|
} catch {
|
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
import { Options, Parser } from 'csv-parse/browser/esm';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ObjectColumnConfig, RetrieveRecordsOptions, RetrieveRecordsSummary } from '@datapos/datapos-shared/component/connector';
|
|
2
|
+
import { ParsingRecord, RecordDelimiterId, ValueDelimiterId } from '@datapos/datapos-shared/component/dataView';
|
|
3
|
+
import { RetrieveRecordsOptions, RetrieveRecordsSummary } from '@datapos/datapos-shared/component/connector';
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
5
|
+
* Parse preview configuration.
|
|
7
6
|
*/
|
|
8
|
-
interface
|
|
7
|
+
interface ParsePreviewConfig {
|
|
8
|
+
parsingRecords: ParsingRecord[];
|
|
9
9
|
recordDelimiterId: RecordDelimiterId;
|
|
10
10
|
valueDelimiterId: ValueDelimiterId;
|
|
11
|
-
parsingRecords: ParsingRecord[];
|
|
12
|
-
inferenceRecords: InferenceRecord[];
|
|
13
|
-
columnConfigs: ObjectColumnConfig[];
|
|
14
11
|
}
|
|
15
12
|
/** Tool. */
|
|
16
13
|
declare class Tool {
|
|
17
14
|
/** Build parser. */
|
|
18
15
|
buildParser(options: Options): Parser;
|
|
19
16
|
/**
|
|
20
|
-
*
|
|
17
|
+
* Parse preview.
|
|
21
18
|
*/
|
|
22
|
-
|
|
19
|
+
parsePreview(text: string, delimiters: ValueDelimiterId[]): Promise<ParsePreviewConfig>;
|
|
23
20
|
/**
|
|
24
21
|
* Parse stream.
|
|
25
22
|
*/
|
|
26
23
|
parseStream(retrieveRecordsOptions: RetrieveRecordsOptions, parseOptions: Options, url: string, abortController: AbortController, chunk: (records: ParsingRecord[]) => void): Promise<RetrieveRecordsSummary>;
|
|
27
24
|
}
|
|
28
25
|
export type { Options, Parser } from 'csv-parse/browser/esm';
|
|
29
|
-
export { Tool };
|
|
26
|
+
export { type ParsePreviewConfig, 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.121",
|
|
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.490",
|
|
30
30
|
"csv-parse": "^6.1.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"rollup-plugin-visualizer": "^6.0.5",
|
|
53
53
|
"sonda": "^0.10.1",
|
|
54
54
|
"typescript": "^5.9.3",
|
|
55
|
-
"vite": "^7.3.
|
|
55
|
+
"vite": "^7.3.1",
|
|
56
56
|
"vite-plugin-dts": "^4.5.4",
|
|
57
57
|
"vitest": "^4.0.16"
|
|
58
58
|
},
|