@datapos/datapos-tool-csv-parse 0.0.77 → 0.0.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,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, 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)
34
+ var o, s, f = i * 8 - n - 1, a = (1 << f) - 1, l = a >> 1, c = -7, h = r ? i - 1 : 0, p = r ? -1 : 1, m = t[e + h];
35
+ for (h += p, o = m & (1 << -c) - 1, m >>= -c, c += f; c > 0; o = o * 256 + t[e + h], h += p, c -= 8)
36
36
  ;
37
- for (s = o & (1 << -h) - 1, o >>= -h, h += n; h > 0; s = s * 256 + t[e + c], c += p, h -= 8)
37
+ for (s = o & (1 << -c) - 1, o >>= -c, c += n; c > 0; s = s * 256 + t[e + h], h += p, c -= 8)
38
38
  ;
39
39
  if (o === 0)
40
40
  o = 1 - l;
41
41
  else {
42
42
  if (o === a)
43
- return s ? NaN : (g ? -1 : 1) * (1 / 0);
43
+ return s ? NaN : (m ? -1 : 1) * (1 / 0);
44
44
  s = s + Math.pow(2, n), o = o - l;
45
45
  }
46
- return (g ? -1 : 1) * s * Math.pow(2, o - n);
46
+ return (m ? -1 : 1) * s * Math.pow(2, o - n);
47
47
  }
48
48
  function ht(t, e, r, n, i, o) {
49
- var s, f, a, l = o * 8 - i - 1, 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)
49
+ var s, f, a, l = o * 8 - i - 1, c = (1 << l) - 1, h = c >> 1, p = i === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, m = n ? 0 : o - 1, x = n ? 1 : -1, y = e < 0 || e === 0 && 1 / e < 0 ? 1 : 0;
50
+ for (e = Math.abs(e), isNaN(e) || e === 1 / 0 ? (f = isNaN(e) ? 1 : 0, s = c) : (s = Math.floor(Math.log(e) / Math.LN2), e * (a = Math.pow(2, -s)) < 1 && (s--, a *= 2), s + h >= 1 ? e += p / a : e += p * Math.pow(2, 1 - h), e * a >= 2 && (s++, a /= 2), s + h >= c ? (f = 0, s = c) : s + h >= 1 ? (f = (e * a - 1) * Math.pow(2, i), s = s + h) : (f = e * Math.pow(2, h - 1) * Math.pow(2, i), s = 0)); i >= 8; t[r + m] = f & 255, m += x, f /= 256, i -= 8)
51
51
  ;
52
- for (s = s << i | f, l += i; l > 0; t[r + g] = s & 255, g += x, s /= 256, l -= 8)
52
+ for (s = s << i | f, l += i; l > 0; t[r + m] = s & 255, m += x, s /= 256, l -= 8)
53
53
  ;
54
- t[r + g - x] |= y * 128;
54
+ t[r + m - 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), h = e.slice(r, n), c = 0; c < a; ++c)
324
- if (l[c] !== h[c]) {
325
- s = l[c], f = h[c];
323
+ for (var s = o - i, f = n - r, a = Math.min(s, f), l = this.slice(i, o), c = e.slice(r, n), h = 0; h < a; ++h)
324
+ if (l[h] !== c[h]) {
325
+ s = l[h], f = c[h];
326
326
  break;
327
327
  }
328
328
  return s < f ? -1 : f < s ? 1 : 0;
@@ -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, x) {
352
- return o === 1 ? g[x] : g.readUInt16BE(x * o);
351
+ function a(m, x) {
352
+ return o === 1 ? m[x] : m.readUInt16BE(x * o);
353
353
  }
354
354
  var l;
355
355
  if (i) {
356
- var h = -1;
356
+ var c = -1;
357
357
  for (l = r; l < s; l++)
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;
358
+ if (a(t, l) === a(e, c === -1 ? 0 : l - c)) {
359
+ if (c === -1 && (c = l), l - c + 1 === f) return c * o;
360
360
  } else
361
- h !== -1 && (l -= l - h), h = -1;
361
+ c !== -1 && (l -= l - c), c = -1;
362
362
  } else
363
363
  for (r + f > s && (r = s - f), l = r; l >= 0; l--) {
364
- for (var c = !0, p = 0; p < f; p++)
364
+ for (var h = !0, p = 0; p < f; p++)
365
365
  if (a(t, l + p) !== a(e, p)) {
366
- c = !1;
366
+ h = !1;
367
367
  break;
368
368
  }
369
- if (c) return l;
369
+ if (h) return l;
370
370
  }
371
371
  return -1;
372
372
  }
@@ -461,19 +461,19 @@ function yt(t, e, r) {
461
461
  for (var n = [], i = e; i < r; ) {
462
462
  var o = t[i], s = null, f = o > 239 ? 4 : o > 223 ? 3 : o > 191 ? 2 : 1;
463
463
  if (i + f <= r) {
464
- var a, l, h, c;
464
+ var a, l, c, h;
465
465
  switch (f) {
466
466
  case 1:
467
467
  o < 128 && (s = o);
468
468
  break;
469
469
  case 2:
470
- a = t[i + 1], (a & 192) === 128 && (c = (o & 31) << 6 | a & 63, c > 127 && (s = c));
470
+ a = t[i + 1], (a & 192) === 128 && (h = (o & 31) << 6 | a & 63, h > 127 && (s = h));
471
471
  break;
472
472
  case 3:
473
- a = t[i + 1], l = t[i + 2], (a & 192) === 128 && (l & 192) === 128 && (c = (o & 15) << 12 | (a & 63) << 6 | l & 63, c > 2047 && (c < 55296 || c > 57343) && (s = c));
473
+ a = t[i + 1], l = t[i + 2], (a & 192) === 128 && (l & 192) === 128 && (h = (o & 15) << 12 | (a & 63) << 6 | l & 63, h > 2047 && (h < 55296 || h > 57343) && (s = h));
474
474
  break;
475
475
  case 4:
476
- a = t[i + 1], l = t[i + 2], 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));
476
+ a = t[i + 1], l = t[i + 2], c = t[i + 3], (a & 192) === 128 && (l & 192) === 128 && (c & 192) === 128 && (h = (o & 15) << 18 | (a & 63) << 12 | (l & 63) << 6 | c & 63, h > 65535 && h < 1114112 && (s = h));
477
477
  }
478
478
  }
479
479
  s === null ? (s = 65533, f = 1) : s > 65535 && (s -= 65536, n.push(s >>> 10 & 1023 | 55296), s = 56320 | s & 1023), n.push(s), i += f;
@@ -859,27 +859,27 @@ var Ce;
859
859
  function H() {
860
860
  }
861
861
  H.prototype = /* @__PURE__ */ Object.create(null);
862
- function m() {
863
- m.init.call(this);
864
- }
865
- m.EventEmitter = m;
866
- m.usingDomains = !1;
867
- m.prototype.domain = void 0;
868
- m.prototype._events = void 0;
869
- m.prototype._maxListeners = void 0;
870
- m.defaultMaxListeners = 10;
871
- m.init = function() {
872
- this.domain = null, m.usingDomains && Ce.active && !(this instanceof Ce.Domain) && (this.domain = Ce.active), (!this._events || this._events === Object.getPrototypeOf(this)._events) && (this._events = new H(), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
873
- };
874
- m.prototype.setMaxListeners = function(e) {
862
+ function g() {
863
+ g.init.call(this);
864
+ }
865
+ g.EventEmitter = g;
866
+ g.usingDomains = !1;
867
+ g.prototype.domain = void 0;
868
+ g.prototype._events = void 0;
869
+ g.prototype._maxListeners = void 0;
870
+ g.defaultMaxListeners = 10;
871
+ g.init = function() {
872
+ this.domain = null, g.usingDomains && Ce.active && !(this instanceof Ce.Domain) && (this.domain = Ce.active), (!this._events || this._events === Object.getPrototypeOf(this)._events) && (this._events = new H(), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
873
+ };
874
+ g.prototype.setMaxListeners = function(e) {
875
875
  if (typeof e != "number" || e < 0 || isNaN(e))
876
876
  throw new TypeError('"n" argument must be a positive number');
877
877
  return this._maxListeners = e, this;
878
878
  };
879
879
  function Rt(t) {
880
- return t._maxListeners === void 0 ? m.defaultMaxListeners : t._maxListeners;
880
+ return t._maxListeners === void 0 ? g.defaultMaxListeners : t._maxListeners;
881
881
  }
882
- m.prototype.getMaxListeners = function() {
882
+ g.prototype.getMaxListeners = function() {
883
883
  return Rt(this);
884
884
  };
885
885
  function Ir(t, e, r) {
@@ -917,7 +917,7 @@ function Tr(t, e, r, n) {
917
917
  for (var i = t.length, o = ae(t, i), s = 0; s < i; ++s)
918
918
  o[s].apply(r, n);
919
919
  }
920
- m.prototype.emit = function(e) {
920
+ g.prototype.emit = function(e) {
921
921
  var r, n, i, o, s, f, a, l = e === "error";
922
922
  if (f = this._events, f)
923
923
  l = l && f.error == null;
@@ -929,33 +929,33 @@ m.prototype.emit = function(e) {
929
929
  else {
930
930
  if (r instanceof Error)
931
931
  throw r;
932
- var h = new Error('Uncaught, unspecified "error" event. (' + r + ")");
933
- throw h.context = r, h;
932
+ var c = new Error('Uncaught, unspecified "error" event. (' + r + ")");
933
+ throw c.context = r, c;
934
934
  }
935
935
  return !1;
936
936
  }
937
937
  if (n = f[e], !n)
938
938
  return !1;
939
- var c = typeof n == "function";
939
+ var h = typeof n == "function";
940
940
  switch (i = arguments.length, i) {
941
941
  // fast cases
942
942
  case 1:
943
- Ir(n, c, this);
943
+ Ir(n, h, this);
944
944
  break;
945
945
  case 2:
946
- Cr(n, c, this, arguments[1]);
946
+ Cr(n, h, this, arguments[1]);
947
947
  break;
948
948
  case 3:
949
- Or(n, c, this, arguments[1], arguments[2]);
949
+ Or(n, h, this, arguments[1], arguments[2]);
950
950
  break;
951
951
  case 4:
952
- Ar(n, c, this, arguments[1], arguments[2], arguments[3]);
952
+ Ar(n, h, this, arguments[1], arguments[2], arguments[3]);
953
953
  break;
954
954
  // slower
955
955
  default:
956
956
  for (o = new Array(i - 1), s = 1; s < i; s++)
957
957
  o[s - 1] = arguments[s];
958
- Tr(n, c, this, o);
958
+ Tr(n, h, this, o);
959
959
  }
960
960
  return !0;
961
961
  };
@@ -979,11 +979,11 @@ function It(t, e, r, n) {
979
979
  function Lr(t) {
980
980
  typeof console.warn == "function" ? console.warn(t) : console.log(t);
981
981
  }
982
- m.prototype.addListener = function(e, r) {
982
+ g.prototype.addListener = function(e, r) {
983
983
  return It(this, e, r, !1);
984
984
  };
985
- m.prototype.on = m.prototype.addListener;
986
- m.prototype.prependListener = function(e, r) {
985
+ g.prototype.on = g.prototype.addListener;
986
+ g.prototype.prependListener = function(e, r) {
987
987
  return It(this, e, r, !0);
988
988
  };
989
989
  function Ct(t, e, r) {
@@ -993,17 +993,17 @@ function Ct(t, e, r) {
993
993
  }
994
994
  return i.listener = r, i;
995
995
  }
996
- m.prototype.once = function(e, r) {
996
+ g.prototype.once = function(e, r) {
997
997
  if (typeof r != "function")
998
998
  throw new TypeError('"listener" argument must be a function');
999
999
  return this.on(e, Ct(this, e, r)), this;
1000
1000
  };
1001
- m.prototype.prependOnceListener = function(e, r) {
1001
+ g.prototype.prependOnceListener = function(e, r) {
1002
1002
  if (typeof r != "function")
1003
1003
  throw new TypeError('"listener" argument must be a function');
1004
1004
  return this.prependListener(e, Ct(this, e, r)), this;
1005
1005
  };
1006
- m.prototype.removeListener = function(e, r) {
1006
+ g.prototype.removeListener = function(e, r) {
1007
1007
  var n, i, o, s, f;
1008
1008
  if (typeof r != "function")
1009
1009
  throw new TypeError('"listener" argument must be a function');
@@ -1031,7 +1031,7 @@ m.prototype.removeListener = function(e, r) {
1031
1031
  }
1032
1032
  return this;
1033
1033
  };
1034
- m.prototype.removeAllListeners = function(e) {
1034
+ g.prototype.removeAllListeners = function(e) {
1035
1035
  var r, n;
1036
1036
  if (n = this._events, !n)
1037
1037
  return this;
@@ -1050,14 +1050,14 @@ m.prototype.removeAllListeners = function(e) {
1050
1050
  while (r[0]);
1051
1051
  return this;
1052
1052
  };
1053
- m.prototype.listeners = function(e) {
1053
+ g.prototype.listeners = function(e) {
1054
1054
  var r, n, i = this._events;
1055
1055
  return i ? (r = i[e], r ? typeof r == "function" ? n = [r.listener || r] : n = Nr(r) : n = []) : n = [], n;
1056
1056
  };
1057
- m.listenerCount = function(t, e) {
1057
+ g.listenerCount = function(t, e) {
1058
1058
  return typeof t.listenerCount == "function" ? t.listenerCount(e) : Ot.call(t, e);
1059
1059
  };
1060
- m.prototype.listenerCount = Ot;
1060
+ g.prototype.listenerCount = Ot;
1061
1061
  function Ot(t) {
1062
1062
  var e = this._events;
1063
1063
  if (e) {
@@ -1069,7 +1069,7 @@ function Ot(t) {
1069
1069
  }
1070
1070
  return 0;
1071
1071
  }
1072
- m.prototype.eventNames = function() {
1072
+ g.prototype.eventNames = function() {
1073
1073
  return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
1074
1074
  };
1075
1075
  function Dr(t, e) {
@@ -1306,20 +1306,20 @@ function ye(t, e, r) {
1306
1306
  if (Le(e))
1307
1307
  return Ae(e);
1308
1308
  }
1309
- var a = "", l = !1, h = ["{", "}"];
1310
- if (Yr(e) && (l = !0, h = ["[", "]"]), De(e)) {
1311
- var c = e.name ? ": " + e.name : "";
1312
- a = " [Function" + c + "]";
1309
+ var a = "", l = !1, c = ["{", "}"];
1310
+ if (Yr(e) && (l = !0, c = ["[", "]"]), De(e)) {
1311
+ var h = e.name ? ": " + e.name : "";
1312
+ a = " [Function" + h + "]";
1313
1313
  }
1314
1314
  if (Te(e) && (a = " " + RegExp.prototype.toString.call(e)), et(e) && (a = " " + Date.prototype.toUTCString.call(e)), Le(e) && (a = " " + Ae(e)), o.length === 0 && (!l || e.length == 0))
1315
- return h[0] + a + h[1];
1315
+ return c[0] + a + c[1];
1316
1316
  if (r < 0)
1317
1317
  return Te(e) ? t.stylize(RegExp.prototype.toString.call(e), "regexp") : t.stylize("[Object]", "special");
1318
1318
  t.seen.push(e);
1319
1319
  var p;
1320
- return l ? p = Vr(t, e, r, s, o) : p = o.map(function(g) {
1321
- return Pe(t, e, r, s, g, l);
1322
- }), t.seen.pop(), Jr(p, a, h);
1320
+ return l ? p = Vr(t, e, r, s, o) : p = o.map(function(m) {
1321
+ return Pe(t, e, r, s, m, l);
1322
+ }), t.seen.pop(), Jr(p, a, c);
1323
1323
  }
1324
1324
  function zr(t, e) {
1325
1325
  if (Q(e))
@@ -1567,7 +1567,7 @@ function Kr(t) {
1567
1567
  }
1568
1568
  C.ReadableState = Ut;
1569
1569
  var E = Pr("stream");
1570
- oe(C, m);
1570
+ oe(C, g);
1571
1571
  function en(t, e, r) {
1572
1572
  if (typeof t.prependListener == "function")
1573
1573
  return t.prependListener(e, r);
@@ -1583,7 +1583,7 @@ function Ut(t, e) {
1583
1583
  }
1584
1584
  function C(t) {
1585
1585
  if (!(this instanceof C)) return new C(t);
1586
- this._readableState = new Ut(t, this), this.readable = !0, t && typeof t.read == "function" && (this._read = t.read), m.call(this);
1586
+ this._readableState = new Ut(t, this), this.readable = !0, t && typeof t.read == "function" && (this._read = t.read), g.call(this);
1587
1587
  }
1588
1588
  C.prototype.push = function(t, e) {
1589
1589
  var r = this._readableState;
@@ -1686,10 +1686,10 @@ C.prototype.pipe = function(t, e) {
1686
1686
  break;
1687
1687
  }
1688
1688
  n.pipesCount += 1, E("pipe count=%d opts=%j", n.pipesCount, e);
1689
- var i = !e || e.end !== !1, o = i ? f : h;
1689
+ var i = !e || e.end !== !1, o = i ? f : c;
1690
1690
  n.endEmitted ? B(o) : r.once("end", o), t.on("unpipe", s);
1691
1691
  function s(R) {
1692
- E("onunpipe"), R === r && h();
1692
+ E("onunpipe"), R === r && c();
1693
1693
  }
1694
1694
  function f() {
1695
1695
  E("onend"), t.end();
@@ -1697,20 +1697,20 @@ C.prototype.pipe = function(t, e) {
1697
1697
  var a = un(r);
1698
1698
  t.on("drain", a);
1699
1699
  var l = !1;
1700
- function 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();
1700
+ function c() {
1701
+ E("cleanup"), t.removeListener("close", x), t.removeListener("finish", y), t.removeListener("drain", a), t.removeListener("error", m), t.removeListener("unpipe", s), r.removeListener("end", f), r.removeListener("end", c), r.removeListener("data", p), l = !0, n.awaitDrain && (!t._writableState || t._writableState.needDrain) && a();
1702
1702
  }
1703
- var c = !1;
1703
+ var h = !1;
1704
1704
  r.on("data", p);
1705
1705
  function p(R) {
1706
- E("ondata"), c = !1;
1706
+ E("ondata"), h = !1;
1707
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());
1708
+ v === !1 && !h && ((n.pipesCount === 1 && n.pipes === t || n.pipesCount > 1 && $t(n.pipes, t) !== -1) && !l && (E("false write response, pause", r._readableState.awaitDrain), r._readableState.awaitDrain++, h = !0), r.pause());
1709
1709
  }
1710
- function g(R) {
1711
- E("onerror", R), S(), t.removeListener("error", g), tn(t, "error") === 0 && t.emit("error", R);
1710
+ function m(R) {
1711
+ E("onerror", R), S(), t.removeListener("error", m), tn(t, "error") === 0 && t.emit("error", R);
1712
1712
  }
1713
- en(t, "error", g);
1713
+ en(t, "error", m);
1714
1714
  function x() {
1715
1715
  t.removeListener("finish", y), S();
1716
1716
  }
@@ -1746,7 +1746,7 @@ C.prototype.unpipe = function(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
- var r = m.prototype.on.call(this, t, e);
1749
+ var r = g.prototype.on.call(this, t, e);
1750
1750
  if (t === "data")
1751
1751
  this._readableState.flowing !== !1 && this.resume();
1752
1752
  else if (t === "readable") {
@@ -1856,7 +1856,7 @@ function $t(t, e) {
1856
1856
  return -1;
1857
1857
  }
1858
1858
  L.WritableState = He;
1859
- oe(L, m);
1859
+ oe(L, g);
1860
1860
  function wn() {
1861
1861
  }
1862
1862
  function yn(t, e, r) {
@@ -1882,7 +1882,7 @@ He.prototype.getBuffer = function() {
1882
1882
  };
1883
1883
  function L(t) {
1884
1884
  if (!(this instanceof L) && !(this instanceof M)) return new L(t);
1885
- this._writableState = new He(t, this), this.writable = !0, t && (typeof t.write == "function" && (this._write = t.write), typeof t.writev == "function" && (this._writev = t.writev)), m.call(this);
1885
+ this._writableState = new He(t, this), this.writable = !0, t && (typeof t.write == "function" && (this._write = t.write), typeof t.writev == "function" && (this._writev = t.writev)), g.call(this);
1886
1886
  }
1887
1887
  L.prototype.pipe = function() {
1888
1888
  this.emit("error", new Error("Cannot pipe, not readable"));
@@ -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, h = e.objectMode ? 1 : f.length;
1964
- if ($e(t, e, !1, h, f, a, l), r = r.next, e.writing)
1963
+ var f = r.chunk, a = r.encoding, l = r.callback, c = e.objectMode ? 1 : f.length;
1964
+ if ($e(t, e, !1, c, f, a, l), r = r.next, e.writing)
1965
1965
  break;
1966
1966
  }
1967
1967
  r === null && (e.lastBufferedRequest = null);
@@ -2073,7 +2073,7 @@ function fe(t) {
2073
2073
  fe.prototype._transform = function(t, e, r) {
2074
2074
  r(null, t);
2075
2075
  };
2076
- oe(V, m);
2076
+ oe(V, g);
2077
2077
  V.Readable = C;
2078
2078
  V.Writable = L;
2079
2079
  V.Duplex = M;
@@ -2081,12 +2081,12 @@ V.Transform = k;
2081
2081
  V.PassThrough = fe;
2082
2082
  V.Stream = V;
2083
2083
  function V() {
2084
- m.call(this);
2084
+ g.call(this);
2085
2085
  }
2086
2086
  V.prototype.pipe = function(t, e) {
2087
2087
  var r = this;
2088
- function n(h) {
2089
- t.writable && t.write(h) === !1 && r.pause && r.pause();
2088
+ function n(c) {
2089
+ t.writable && t.write(c) === !1 && r.pause && r.pause();
2090
2090
  }
2091
2091
  r.on("data", n);
2092
2092
  function i() {
@@ -2100,9 +2100,9 @@ V.prototype.pipe = function(t, e) {
2100
2100
  function f() {
2101
2101
  o || (o = !0, typeof t.destroy == "function" && t.destroy());
2102
2102
  }
2103
- function a(h) {
2104
- if (l(), m.listenerCount(this, "error") === 0)
2105
- throw h;
2103
+ function a(c) {
2104
+ if (l(), g.listenerCount(this, "error") === 0)
2105
+ throw c;
2106
2106
  }
2107
2107
  r.on("error", a), t.on("error", a);
2108
2108
  function l() {
@@ -2665,22 +2665,22 @@ 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: h, recordDelimiterMaxLength: c } = this.state, p = i - n - 1, g = Math.max(
2669
- h,
2668
+ const { encoding: s, escape: f, quote: a } = this.options, { quoting: l, needMoreDataSize: c, recordDelimiterMaxLength: h } = this.state, p = i - n - 1, m = Math.max(
2669
+ c,
2670
2670
  // Skip if the remaining buffer smaller than record delimiter
2671
2671
  // If "record_delimiter" is yet to be discovered:
2672
2672
  // 1. It is equals to `[]` and "recordDelimiterMaxLength" equals `0`
2673
2673
  // 2. We set the length to windows line ending in the current encoding
2674
2674
  // Note, that encoding is known from user or bom discovery at that point
2675
2675
  // recordDelimiterMaxLength,
2676
- c === 0 ? u.from(`\r
2677
- `, s).length : c,
2676
+ h === 0 ? u.from(`\r
2677
+ `, s).length : h,
2678
2678
  // Skip if remaining buffer can be an escaped quote
2679
2679
  l ? (f === null ? 0 : f.length) + a.length : 0,
2680
2680
  // Skip if remaining buffer can be record delimiter following the closing quote
2681
- l ? a.length + c : 0
2681
+ l ? a.length + h : 0
2682
2682
  );
2683
- return p < g;
2683
+ return p < m;
2684
2684
  },
2685
2685
  // Central parser implementation
2686
2686
  parse: function(n, i, o, s) {
@@ -2688,10 +2688,10 @@ 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: h,
2692
- ltrim: c,
2691
+ from_line: c,
2692
+ ltrim: h,
2693
2693
  max_record_size: p,
2694
- raw: g,
2694
+ raw: m,
2695
2695
  relax_quotes: x,
2696
2696
  rtrim: y,
2697
2697
  skip_empty_lines: S,
@@ -2744,7 +2744,7 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
2744
2744
  d
2745
2745
  ) && (Re = this.options.record_delimiter);
2746
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)
2747
+ if (m === !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
2750
  if (I !== null && this.state.quoting === !0 && this.__isEscape(b, d, O) && d + I.length < Ie)
@@ -2822,7 +2822,7 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
2822
2822
  if (this.state.commenting && this.state.wasQuoting === !1 && this.state.record.length === 0 && this.state.field.length === 0)
2823
2823
  this.info.comment_lines++;
2824
2824
  else {
2825
- if (this.state.enabled === !1 && this.info.lines + (this.state.wasRowDelimiter === !0 ? 1 : 0) >= h) {
2825
+ if (this.state.enabled === !1 && this.info.lines + (this.state.wasRowDelimiter === !0 ? 1 : 0) >= c) {
2826
2826
  this.state.enabled = !0, this.__resetField(), this.__resetRecord(), d += A - 1;
2827
2827
  continue;
2828
2828
  }
@@ -2874,7 +2874,7 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
2874
2874
  this.__infoField()
2875
2875
  )
2876
2876
  );
2877
- const J = c === !1 || this.state.quoting === !0 || this.state.field.length !== 0 || !this.__isCharTrimable(b, d), he = y === !1 || this.state.wasQuoting === !1;
2877
+ const J = h === !1 || this.state.quoting === !0 || this.state.field.length !== 0 || !this.__isCharTrimable(b, d), he = y === !1 || this.state.wasQuoting === !1;
2878
2878
  if (J === !0 && he === !0)
2879
2879
  this.state.field.append(O);
2880
2880
  else {
@@ -2928,16 +2928,16 @@ 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: h,
2932
- relax_column_count_more: c,
2931
+ relax_column_count_less: c,
2932
+ relax_column_count_more: h,
2933
2933
  raw: p,
2934
- skip_records_with_empty_values: g
2934
+ skip_records_with_empty_values: m
2935
2935
  } = this.options, { enabled: x, record: y } = this.state;
2936
2936
  if (x === !1)
2937
2937
  return this.__resetRecord();
2938
2938
  const S = y.length;
2939
2939
  if (i === !0) {
2940
- if (g === !0 && lt(y)) {
2940
+ if (m === !0 && lt(y)) {
2941
2941
  this.__resetRecord();
2942
2942
  return;
2943
2943
  }
@@ -2970,14 +2970,14 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
2970
2970
  record: y
2971
2971
  }
2972
2972
  );
2973
- if (l === !0 || h === !0 && S < this.state.expectedRecordLength || c === !0 && S > this.state.expectedRecordLength)
2973
+ if (l === !0 || c === !0 && S < this.state.expectedRecordLength || h === !0 && S > this.state.expectedRecordLength)
2974
2974
  this.info.invalid_field_length++, this.state.error = R;
2975
2975
  else {
2976
2976
  const v = this.__error(R);
2977
2977
  if (v) return v;
2978
2978
  }
2979
2979
  }
2980
- if (g === !0 && lt(y)) {
2980
+ if (m === !0 && lt(y)) {
2981
2981
  this.__resetRecord();
2982
2982
  return;
2983
2983
  }
@@ -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 [h, c] = this.__cast(l);
3072
- if (h !== void 0) return h;
3073
- l = c;
3071
+ const [c, h] = this.__cast(l);
3072
+ if (c !== void 0) return c;
3073
+ l = h;
3074
3074
  }
3075
3075
  this.state.record.push(l), s !== 0 && typeof l == "string" && (this.state.record_length += l.length), this.__resetField();
3076
3076
  },
@@ -3116,10 +3116,10 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
3116
3116
  return ((s, f) => {
3117
3117
  const { timchars: a } = this.state;
3118
3118
  e: for (let l = 0; l < a.length; l++) {
3119
- const 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;
3119
+ const c = a[l];
3120
+ for (let h = 0; h < c.length; h++)
3121
+ if (c[h] !== s[f + h]) continue e;
3122
+ return c.length;
3123
3123
  }
3124
3124
  return 0;
3125
3125
  })(n, i);
@@ -3149,8 +3149,8 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
3149
3149
  e: for (let a = 0; a < s.length; a++) {
3150
3150
  const l = s[a];
3151
3151
  if (l[0] === o) {
3152
- for (let h = 1; h < l.length; h++)
3153
- if (l[h] !== n[i + h]) continue e;
3152
+ for (let c = 1; c < l.length; c++)
3153
+ if (l[c] !== n[i + c]) continue e;
3154
3154
  return l.length;
3155
3155
  }
3156
3156
  }
@@ -3159,10 +3159,10 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
3159
3159
  __isRecordDelimiter: function(n, i, o) {
3160
3160
  const { record_delimiter: s } = this.options, f = s.length;
3161
3161
  e: for (let a = 0; a < f; a++) {
3162
- const l = s[a], h = l.length;
3162
+ const l = s[a], c = l.length;
3163
3163
  if (l[0] === n) {
3164
- for (let c = 1; c < h; c++)
3165
- if (l[c] !== i[o + c])
3164
+ for (let h = 1; h < c; h++)
3165
+ if (l[h] !== i[o + h])
3166
3166
  continue e;
3167
3167
  return l.length;
3168
3168
  }
@@ -3388,12 +3388,18 @@ class ri {
3388
3388
  /**
3389
3389
  * Determine schema configuration.
3390
3390
  */
3391
- async determineSchemaConfig(e, r) {
3392
- const n = Xn(e), { records: i, valueDelimiterId: o } = await Kn(e, r);
3393
- return console.log("records", i), {
3394
- recordDelimiterId: n,
3395
- records: i,
3396
- valueDelimiterId: o
3391
+ async determineSchemaConfig(e, r, n) {
3392
+ const i = Xn(r), { records: o, valueDelimiterId: s } = await Kn(r, n);
3393
+ console.log(3333, o);
3394
+ const f = [], a = [];
3395
+ for (const l of o) {
3396
+ const c = e.parseRecord(a, l, !0);
3397
+ console.log(4444, c);
3398
+ }
3399
+ return {
3400
+ recordDelimiterId: i,
3401
+ records: f,
3402
+ valueDelimiterId: s
3397
3403
  };
3398
3404
  }
3399
3405
  /**
@@ -3401,33 +3407,33 @@ class ri {
3401
3407
  */
3402
3408
  async parseStream(e, r, n, i, o) {
3403
3409
  return new Promise((s, f) => {
3404
- let a, l, h, c = !1, p = !1;
3405
- const g = () => {
3410
+ let a, l, c, h = !1, p = !1;
3411
+ const m = () => {
3406
3412
  if (p) return;
3407
3413
  p = !0;
3408
3414
  const S = a;
3409
- a = void 0, h = void 0, S != null && (Be(() => S.removeAllListeners()), Be(() => S.end())), Be(() => {
3415
+ a = void 0, c = void 0, S != null && (Be(() => S.removeAllListeners()), Be(() => S.end())), Be(() => {
3410
3416
  l?.cancel();
3411
3417
  }), l = void 0;
3412
3418
  };
3413
- i.signal.addEventListener("abort", g, { once: !0 });
3419
+ i.signal.addEventListener("abort", m, { once: !0 });
3414
3420
  const x = (S) => {
3415
- c || (c = !0, g(), i.signal.aborted || i.abort(S), f(S));
3421
+ h || (h = !0, m(), i.signal.aborted || i.abort(S), f(S));
3416
3422
  };
3417
3423
  (async () => {
3418
- a = je(r), h = ei({ chunk: o, chunkSize: e.chunkSize ?? Gn }), a.on("readable", () => {
3424
+ a = je(r), c = ei({ chunk: o, chunkSize: e.chunkSize ?? Gn }), a.on("readable", () => {
3419
3425
  try {
3420
- if (a == null || h == null) return;
3426
+ if (a == null || c == null) return;
3421
3427
  let I;
3422
3428
  for (; (I = a.read()) != null; ) {
3423
- if (c) return;
3424
- i.signal.throwIfAborted(), h.push(I);
3429
+ if (h) return;
3430
+ i.signal.throwIfAborted(), c.push(I);
3425
3431
  }
3426
3432
  } catch (I) {
3427
3433
  x(I);
3428
3434
  }
3429
3435
  }), a.on("error", (I) => x(I)), a.on("end", () => {
3430
- c || (h?.flush(), s(ti(a)));
3436
+ h || (c?.flush(), s(ti(a)));
3431
3437
  });
3432
3438
  const S = await fetch(encodeURI(n), { signal: i.signal });
3433
3439
  if (!S.ok || S.body == null)
@@ -3436,12 +3442,12 @@ class ri {
3436
3442
  const R = new TextDecoder(e.encodingId);
3437
3443
  let v = await l.read();
3438
3444
  for (; !v.done; ) {
3439
- if (c) return;
3445
+ if (h) return;
3440
3446
  i.signal.throwIfAborted();
3441
3447
  const I = R.decode(v.value, { stream: !0 });
3442
3448
  I.length > 0 && a.write(I), v = await l.read();
3443
3449
  }
3444
- if (c) return;
3450
+ if (h) return;
3445
3451
  const _ = R.decode();
3446
3452
  _.length > 0 && a.write(_), a.end();
3447
3453
  })().catch((S) => x(S));
@@ -3459,22 +3465,26 @@ async function Kn(t, e) {
3459
3465
  let r, n, i, o = [];
3460
3466
  for (const s of e)
3461
3467
  try {
3462
- let f = 0, a, l = 0, h = 0;
3463
- const c = je({ delimiter: s, relax_column_count: !0 });
3468
+ let f = 0, a, l = 0, c = 0;
3469
+ const h = je({
3470
+ cast: (p, m) => ({ value: p, isQuoted: m.quoting }),
3471
+ delimiter: s,
3472
+ relax_column_count: !0
3473
+ });
3464
3474
  await new Promise((p) => {
3465
3475
  try {
3466
- const g = [];
3467
- c.on("readable", () => {
3476
+ const m = [];
3477
+ h.on("readable", () => {
3468
3478
  let x;
3469
- for (; (x = c.read()) != null; ) {
3479
+ for (; (x = h.read()) != null; ) {
3470
3480
  l++;
3471
3481
  const y = x.length;
3472
- a != null && (h += Math.abs(y - a)), a = y, f += y, g.push(x);
3482
+ a != null && (c += Math.abs(y - a)), a = y, f += y, m.push(x);
3473
3483
  }
3474
- }), c.on("error", () => p()), c.on("end", () => {
3484
+ }), h.on("error", () => p()), h.on("end", () => {
3475
3485
  const x = f / l;
3476
- console.log(1111, f, l, x), (!i || h <= i) && (!n || x > n) && (r = s, n = x, i = h, o = [...g]), p();
3477
- }), c.write(t), c.end();
3486
+ console.log(1111, f, l, x), (!i || c <= i) && (!n || x > n) && (r = s, n = x, i = c, o = [...m]), p();
3487
+ }), h.write(t), h.end();
3478
3488
  } catch {
3479
3489
  p();
3480
3490
  }
@@ -1,16 +1,14 @@
1
1
  import { Options as ParseOptions, Parser } from 'csv-parse/browser/esm';
2
- import { RecordDelimiterId, ValueDelimiterId } from '@datapos/datapos-shared/component/dataView';
2
+ import { EngineUtilities } from '@datapos/datapos-shared/engine';
3
3
  import { RetrieveRecordsOptions, RetrieveRecordsSummary } from '@datapos/datapos-shared/component/connector';
4
- /**
5
- * Parse record and parsed record buffer.
6
- */
7
- type ParsedRecord = string[];
4
+ import { RecordDelimiterId, ValueDelimiterId } from '@datapos/datapos-shared/component/dataView';
5
+ type StreamParsedRecord = string[];
8
6
  /**
9
7
  * Schema configuration.
10
8
  */
11
9
  interface SchemaConfig {
12
10
  recordDelimiterId: RecordDelimiterId;
13
- records: ParsedRecord[];
11
+ records: StreamParsedRecord[];
14
12
  valueDelimiterId: ValueDelimiterId;
15
13
  }
16
14
  /** Tool. */
@@ -20,11 +18,11 @@ declare class Tool {
20
18
  /**
21
19
  * Determine schema configuration.
22
20
  */
23
- determineSchemaConfig(text: string, delimiters: ValueDelimiterId[]): Promise<SchemaConfig>;
21
+ determineSchemaConfig(engineUtilities: EngineUtilities, text: string, delimiters: ValueDelimiterId[]): Promise<SchemaConfig>;
24
22
  /**
25
23
  * Parse stream.
26
24
  */
27
25
  parseStream(retrieveRecordsOptions: RetrieveRecordsOptions, parseOptions: ParseOptions, url: string, abortController: AbortController, chunk: (records: (string[] | Record<string, unknown>)[]) => void): Promise<RetrieveRecordsSummary>;
28
26
  }
29
27
  export type { Options as ParseOptions, Parser } from 'csv-parse/browser/esm';
30
- export { type ParsedRecord, type SchemaConfig, Tool };
28
+ export { type StreamParsedRecord, type SchemaConfig, Tool };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datapos/datapos-tool-csv-parse",
3
- "version": "0.0.77",
3
+ "version": "0.0.78",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "private": false,