@datapos/datapos-tool-csv-parse 0.0.52 → 0.0.54

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.
@@ -1,4 +1,4 @@
1
- var ie = typeof global < "u" ? global : typeof self < "u" ? self : typeof window < "u" ? window : {}, P = [], F = [], Qt = typeof Uint8Array < "u" ? Uint8Array : Array, $e = !1;
1
+ var ie = typeof global < "u" ? global : typeof self < "u" ? self : typeof window < "u" ? window : {}, P = [], F = [], Ht = typeof Uint8Array < "u" ? Uint8Array : Array, $e = !1;
2
2
  function lt() {
3
3
  $e = !0;
4
4
  for (var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", e = 0, r = t.length; e < r; ++e)
@@ -10,7 +10,7 @@ function Gt(t) {
10
10
  var e, r, n, i, o, s, f = t.length;
11
11
  if (f % 4 > 0)
12
12
  throw new Error("Invalid string. Length must be a multiple of 4");
13
- o = t[f - 2] === "=" ? 2 : t[f - 1] === "=" ? 1 : 0, s = new Qt(f * 3 / 4 - o), n = o > 0 ? f - 4 : f;
13
+ o = t[f - 2] === "=" ? 2 : t[f - 1] === "=" ? 1 : 0, s = new Ht(f * 3 / 4 - o), n = o > 0 ? f - 4 : f;
14
14
  var u = 0;
15
15
  for (e = 0, r = 0; e < n; e += 4, r += 3)
16
16
  i = F[t.charCodeAt(e)] << 18 | F[t.charCodeAt(e + 1)] << 12 | F[t.charCodeAt(e + 2)] << 6 | F[t.charCodeAt(e + 3)], s[u++] = i >> 16 & 255, s[u++] = i >> 8 & 255, s[u++] = i & 255;
@@ -24,7 +24,7 @@ function Xt(t, e, r) {
24
24
  n = (t[o] << 16) + (t[o + 1] << 8) + t[o + 2], i.push(Zt(n));
25
25
  return i.join("");
26
26
  }
27
- function Qe(t) {
27
+ function He(t) {
28
28
  $e || lt();
29
29
  for (var e, r = t.length, n = r % 3, i = "", o = [], s = 16383, f = 0, u = r - n; f < u; f += s)
30
30
  o.push(Xt(t, f, f + s > u ? u : f + s));
@@ -454,7 +454,7 @@ a.prototype.toJSON = function() {
454
454
  };
455
455
  };
456
456
  function hr(t, e, r) {
457
- return e === 0 && r === t.length ? Qe(t) : Qe(t.slice(e, r));
457
+ return e === 0 && r === t.length ? He(t) : He(t.slice(e, r));
458
458
  }
459
459
  function wt(t, e, r) {
460
460
  r = Math.min(t.length, r);
@@ -856,9 +856,9 @@ function Sr(t) {
856
856
  return typeof t.readFloatLE == "function" && typeof t.slice == "function" && xt(t.slice(0, 0));
857
857
  }
858
858
  var Oe;
859
- function Q() {
859
+ function H() {
860
860
  }
861
- Q.prototype = /* @__PURE__ */ Object.create(null);
861
+ H.prototype = /* @__PURE__ */ Object.create(null);
862
862
  function p() {
863
863
  p.init.call(this);
864
864
  }
@@ -869,7 +869,7 @@ p.prototype._events = void 0;
869
869
  p.prototype._maxListeners = void 0;
870
870
  p.defaultMaxListeners = 10;
871
871
  p.init = function() {
872
- this.domain = null, p.usingDomains && Oe.active && !(this instanceof Oe.Domain) && (this.domain = Oe.active), (!this._events || this._events === Object.getPrototypeOf(this)._events) && (this._events = new Q(), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
872
+ this.domain = null, p.usingDomains && Oe.active && !(this instanceof Oe.Domain) && (this.domain = Oe.active), (!this._events || this._events === Object.getPrototypeOf(this)._events) && (this._events = new H(), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
873
873
  };
874
874
  p.prototype.setMaxListeners = function(e) {
875
875
  if (typeof e != "number" || e < 0 || isNaN(e))
@@ -967,7 +967,7 @@ function Rt(t, e, r, n) {
967
967
  "newListener",
968
968
  e,
969
969
  r.listener ? r.listener : r
970
- ), o = t._events), s = o[e]) : (o = t._events = new Q(), t._eventsCount = 0), !s)
970
+ ), o = t._events), s = o[e]) : (o = t._events = new H(), t._eventsCount = 0), !s)
971
971
  s = o[e] = r, ++t._eventsCount;
972
972
  else if (typeof s == "function" ? s = o[e] = n ? [r, s] : [s, r] : n ? s.unshift(r) : s.push(r), !s.warned && (i = St(t), i && i > 0 && s.length > i)) {
973
973
  s.warned = !0;
@@ -1012,7 +1012,7 @@ p.prototype.removeListener = function(e, r) {
1012
1012
  if (n = i[e], !n)
1013
1013
  return this;
1014
1014
  if (n === r || n.listener && n.listener === r)
1015
- --this._eventsCount === 0 ? this._events = new Q() : (delete i[e], i.removeListener && this.emit("removeListener", e, n.listener || r));
1015
+ --this._eventsCount === 0 ? this._events = new H() : (delete i[e], i.removeListener && this.emit("removeListener", e, n.listener || r));
1016
1016
  else if (typeof n != "function") {
1017
1017
  for (o = -1, s = n.length; s-- > 0; )
1018
1018
  if (n[s] === r || n[s].listener && n[s].listener === r) {
@@ -1023,7 +1023,7 @@ p.prototype.removeListener = function(e, r) {
1023
1023
  return this;
1024
1024
  if (n.length === 1) {
1025
1025
  if (n[0] = void 0, --this._eventsCount === 0)
1026
- return this._events = new Q(), this;
1026
+ return this._events = new H(), this;
1027
1027
  delete i[e];
1028
1028
  } else
1029
1029
  Lr(n, o);
@@ -1036,11 +1036,11 @@ p.prototype.removeAllListeners = function(e) {
1036
1036
  if (n = this._events, !n)
1037
1037
  return this;
1038
1038
  if (!n.removeListener)
1039
- return arguments.length === 0 ? (this._events = new Q(), this._eventsCount = 0) : n[e] && (--this._eventsCount === 0 ? this._events = new Q() : delete n[e]), this;
1039
+ return arguments.length === 0 ? (this._events = new H(), this._eventsCount = 0) : n[e] && (--this._eventsCount === 0 ? this._events = new H() : delete n[e]), this;
1040
1040
  if (arguments.length === 0) {
1041
1041
  for (var i = Object.keys(n), o = 0, s; o < i.length; ++o)
1042
1042
  s = i[o], s !== "removeListener" && this.removeAllListeners(s);
1043
- return this.removeAllListeners("removeListener"), this._events = new Q(), this._eventsCount = 0, this;
1043
+ return this.removeAllListeners("removeListener"), this._events = new H(), this._eventsCount = 0, this;
1044
1044
  }
1045
1045
  if (r = n[e], typeof r == "function")
1046
1046
  this.removeListener(e, r);
@@ -1204,7 +1204,7 @@ function Ur(t) {
1204
1204
  return o;
1205
1205
  }
1206
1206
  function Dt(t, e) {
1207
- if (H(ie.process))
1207
+ if (Q(ie.process))
1208
1208
  return function() {
1209
1209
  return Dt(t, e).apply(this, arguments);
1210
1210
  };
@@ -1223,7 +1223,7 @@ function Dt(t, e) {
1223
1223
  }
1224
1224
  var pe = {}, Ce;
1225
1225
  function kr(t) {
1226
- if (H(Ce) && (Ce = me.env.NODE_DEBUG || ""), t = t.toUpperCase(), !pe[t])
1226
+ if (Q(Ce) && (Ce = me.env.NODE_DEBUG || ""), t = t.toUpperCase(), !pe[t])
1227
1227
  if (new RegExp("\\b" + t + "\\b", "i").test(Ce)) {
1228
1228
  var e = 0;
1229
1229
  pe[t] = function() {
@@ -1240,7 +1240,7 @@ function G(t, e) {
1240
1240
  seen: [],
1241
1241
  stylize: $r
1242
1242
  };
1243
- return arguments.length >= 3 && (r.depth = arguments[2]), arguments.length >= 4 && (r.colors = arguments[3]), Ft(e) ? r.showHidden = e : e && Wr(r, e), H(r.showHidden) && (r.showHidden = !1), H(r.depth) && (r.depth = 2), H(r.colors) && (r.colors = !1), H(r.customInspect) && (r.customInspect = !0), r.colors && (r.stylize = Pr), ye(r, t, r.depth);
1243
+ return arguments.length >= 3 && (r.depth = arguments[2]), arguments.length >= 4 && (r.colors = arguments[3]), Ft(e) ? r.showHidden = e : e && Wr(r, e), Q(r.showHidden) && (r.showHidden = !1), Q(r.depth) && (r.depth = 2), Q(r.colors) && (r.colors = !1), Q(r.customInspect) && (r.customInspect = !0), r.colors && (r.stylize = Pr), ye(r, t, r.depth);
1244
1244
  }
1245
1245
  G.colors = {
1246
1246
  bold: [1, 22],
@@ -1322,7 +1322,7 @@ function ye(t, e, r) {
1322
1322
  }), t.seen.pop(), Vr(g, u, h);
1323
1323
  }
1324
1324
  function qr(t, e) {
1325
- if (H(e))
1325
+ if (Q(e))
1326
1326
  return t.stylize("undefined", "undefined");
1327
1327
  if (Ve(e)) {
1328
1328
  var r = "'" + JSON.stringify(e).replace(/^"|"$/g, "").replace(/'/g, "\\'").replace(/\\"/g, '"') + "'";
@@ -1371,7 +1371,7 @@ function ke(t, e, r, n, i, o) {
1371
1371
  `).map(function(l) {
1372
1372
  return " " + l;
1373
1373
  }).join(`
1374
- `))) : f = t.stylize("[Circular]", "special")), H(s)) {
1374
+ `))) : f = t.stylize("[Circular]", "special")), Q(s)) {
1375
1375
  if (o && i.match(/^\d+$/))
1376
1376
  return f;
1377
1377
  s = JSON.stringify("" + i), s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/) ? (s = s.substr(1, s.length - 2), s = t.stylize(s, "name")) : (s = s.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'"), s = t.stylize(s, "string"));
@@ -1402,7 +1402,7 @@ function Yr(t) {
1402
1402
  function Ve(t) {
1403
1403
  return typeof t == "string";
1404
1404
  }
1405
- function H(t) {
1405
+ function Q(t) {
1406
1406
  return t === void 0;
1407
1407
  }
1408
1408
  function Te(t) {
@@ -1465,7 +1465,7 @@ te.prototype.concat = function(t) {
1465
1465
  r.data.copy(e, n), n += r.data.length, r = r.next;
1466
1466
  return e;
1467
1467
  };
1468
- var Hr = a.isEncoding || function(t) {
1468
+ var Qr = a.isEncoding || function(t) {
1469
1469
  switch (t && t.toLowerCase()) {
1470
1470
  case "hex":
1471
1471
  case "utf8":
@@ -1483,12 +1483,12 @@ var Hr = a.isEncoding || function(t) {
1483
1483
  return !1;
1484
1484
  }
1485
1485
  };
1486
- function Qr(t) {
1487
- if (t && !Hr(t))
1486
+ function Hr(t) {
1487
+ if (t && !Qr(t))
1488
1488
  throw new Error("Unknown encoding: " + t);
1489
1489
  }
1490
1490
  function le(t) {
1491
- switch (this.encoding = (t || "utf8").toLowerCase().replace(/[-_]/, ""), Qr(t), this.encoding) {
1491
+ switch (this.encoding = (t || "utf8").toLowerCase().replace(/[-_]/, ""), Hr(t), this.encoding) {
1492
1492
  case "utf8":
1493
1493
  this.surrogateSize = 3;
1494
1494
  break;
@@ -2699,7 +2699,7 @@ const Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2699
2699
  to_line: w
2700
2700
  } = this.options;
2701
2701
  let { comment: m, escape: R, quote: U, record_delimiter: Re } = this.options;
2702
- const { bomSkipped: Yt, previousBuf: he, rawBuffer: Wt, escapeIsQuote: Ht } = this.state;
2702
+ const { bomSkipped: Yt, previousBuf: he, rawBuffer: Wt, escapeIsQuote: Qt } = this.state;
2703
2703
  let v;
2704
2704
  if (he === void 0)
2705
2705
  if (n === void 0) {
@@ -2748,7 +2748,7 @@ const Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2748
2748
  this.state.escaping = !1;
2749
2749
  else {
2750
2750
  if (R !== null && this.state.quoting === !0 && this.__isEscape(v, d, O) && d + R.length < Ie)
2751
- if (Ht) {
2751
+ if (Qt) {
2752
2752
  if (this.__isQuote(v, d + R.length)) {
2753
2753
  this.state.escaping = !0, d += R.length - 1;
2754
2754
  continue;
@@ -2770,7 +2770,7 @@ const Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2770
2770
  this.state.quoting = !1, this.state.wasQuoting = !0, d += U.length - 1;
2771
2771
  continue;
2772
2772
  } else if (C === !1) {
2773
- const He = this.__error(
2773
+ const Qe = this.__error(
2774
2774
  new _(
2775
2775
  "CSV_INVALID_CLOSING_QUOTE",
2776
2776
  [
@@ -2784,7 +2784,7 @@ const Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2784
2784
  this.__infoField()
2785
2785
  )
2786
2786
  );
2787
- if (He !== void 0) return He;
2787
+ if (Qe !== void 0) return Qe;
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) {
@@ -3343,7 +3343,7 @@ class Jn extends Vn {
3343
3343
  body;
3344
3344
  /** Sanitized HTTP response body. */
3345
3345
  constructor(e, r, n, i) {
3346
- super(e, r, i), this.name = new.target.name, this.body = Hn(n ?? void 0);
3346
+ super(e, r, i), this.name = new.target.name, this.body = Qn(n ?? void 0);
3347
3347
  }
3348
3348
  }
3349
3349
  async function Yn(t, e, r) {
@@ -3369,12 +3369,12 @@ function Wn(t) {
3369
3369
  }
3370
3370
  return new Error("Unknown error");
3371
3371
  }
3372
- function Hn(t) {
3372
+ function Qn(t) {
3373
3373
  if (!(t == null || t === ""))
3374
3374
  return t.length > 2048 ? `${t.slice(0, 2048)}... [truncated]` : t;
3375
3375
  }
3376
- const Qn = 65536;
3377
- class Gn {
3376
+ const Hn = 1e4, Gn = 4;
3377
+ class Zn {
3378
3378
  /** Build parser. */
3379
3379
  buildParser(e) {
3380
3380
  return ut(e);
@@ -3394,7 +3394,7 @@ class Gn {
3394
3394
  c || (c = !0, y(), i.signal.aborted || i.abort(x), f(x));
3395
3395
  };
3396
3396
  i.signal.addEventListener("abort", y, { once: !0 }), (async () => {
3397
- u = ut(e), h = this.constructRowBuffer({ chunk: o, chunkSize: r.chunkSize ?? Qn }), u.on("readable", () => {
3397
+ u = ut(e), h = this.constructRowBuffer({ chunk: o, chunkSize: r.chunkSize ?? Hn }), u.on("readable", () => {
3398
3398
  try {
3399
3399
  if (u == null || h == null) return;
3400
3400
  let R;
@@ -3422,7 +3422,7 @@ class Gn {
3422
3422
  }
3423
3423
  if (c) return;
3424
3424
  const m = S.decode();
3425
- m.length > 0 && u.write(m), !c && u.end();
3425
+ m.length > 0 && u.write(m), u.end();
3426
3426
  })().catch((x) => C(x));
3427
3427
  });
3428
3428
  }
@@ -3431,13 +3431,23 @@ class Gn {
3431
3431
  }
3432
3432
  /** Construct row buffer. */
3433
3433
  constructRowBuffer(e) {
3434
- let r = [];
3435
- const n = () => {
3436
- r.length !== 0 && (e.chunk(r), r = []);
3434
+ const r = Math.max(1, Math.floor(e.chunkSize)), n = [];
3435
+ let i = u(), o = 0;
3436
+ const s = () => {
3437
+ if (o === 0) return;
3438
+ const l = i;
3439
+ l.length = o, i = u(), o = 0, e.chunk(l), n.length < Gn && n.push(l);
3437
3440
  };
3438
- return { flush: n, push: (o) => {
3439
- r.push(o), r.length >= e.chunkSize && n();
3441
+ return { flush: s, push: (l) => {
3442
+ i[o++] = l, o >= r && s();
3440
3443
  } };
3444
+ function u() {
3445
+ const l = n.pop();
3446
+ if (l != null)
3447
+ return l.length = 0, l;
3448
+ const h = new Array(r);
3449
+ return h.length = 0, h;
3450
+ }
3441
3451
  }
3442
3452
  /** Construct summary. */
3443
3453
  constructSummary(e) {
@@ -3459,5 +3469,5 @@ class Gn {
3459
3469
  }
3460
3470
  }
3461
3471
  export {
3462
- Gn as Tool
3472
+ Zn as Tool
3463
3473
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datapos/datapos-tool-csv-parse",
3
- "version": "0.0.52",
3
+ "version": "0.0.54",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "private": false,