@datapos/datapos-tool-csv-parse 0.0.39 → 0.0.40

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 Qe(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, l = (1 << f) - 1, u = l >> 1, h = -7, c = r ? i - 1 : 0, m = r ? -1 : 1, w = t[e + c];
35
- for (c += m, o = w & (1 << -h) - 1, w >>= -h, h += f; h > 0; o = o * 256 + t[e + c], c += m, h -= 8)
34
+ var o, s, f = i * 8 - n - 1, l = (1 << f) - 1, u = l >> 1, h = -7, c = r ? i - 1 : 0, g = r ? -1 : 1, y = t[e + c];
35
+ for (c += g, o = y & (1 << -h) - 1, y >>= -h, h += f; h > 0; o = o * 256 + t[e + c], c += g, h -= 8)
36
36
  ;
37
- for (s = o & (1 << -h) - 1, o >>= -h, h += n; h > 0; s = s * 256 + t[e + c], c += m, h -= 8)
37
+ for (s = o & (1 << -h) - 1, o >>= -h, h += n; h > 0; s = s * 256 + t[e + c], c += g, h -= 8)
38
38
  ;
39
39
  if (o === 0)
40
40
  o = 1 - u;
41
41
  else {
42
42
  if (o === l)
43
- return s ? NaN : (w ? -1 : 1) * (1 / 0);
43
+ return s ? NaN : (y ? -1 : 1) * (1 / 0);
44
44
  s = s + Math.pow(2, n), o = o - u;
45
45
  }
46
- return (w ? -1 : 1) * s * Math.pow(2, o - n);
46
+ return (y ? -1 : 1) * s * Math.pow(2, o - n);
47
47
  }
48
48
  function ht(t, e, r, n, i, o) {
49
- var s, f, l, u = o * 8 - i - 1, h = (1 << u) - 1, c = h >> 1, m = i === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, w = n ? 0 : o - 1, O = n ? 1 : -1, E = 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 * (l = Math.pow(2, -s)) < 1 && (s--, l *= 2), s + c >= 1 ? e += m / l : e += m * Math.pow(2, 1 - c), e * l >= 2 && (s++, l /= 2), s + c >= h ? (f = 0, s = h) : s + c >= 1 ? (f = (e * l - 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 + w] = f & 255, w += O, f /= 256, i -= 8)
49
+ var s, f, l, u = o * 8 - i - 1, h = (1 << u) - 1, c = h >> 1, g = i === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, y = n ? 0 : o - 1, O = n ? 1 : -1, E = 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 * (l = Math.pow(2, -s)) < 1 && (s--, l *= 2), s + c >= 1 ? e += g / l : e += g * Math.pow(2, 1 - c), e * l >= 2 && (s++, l /= 2), s + c >= h ? (f = 0, s = h) : s + c >= 1 ? (f = (e * l - 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 + y] = f & 255, y += O, f /= 256, i -= 8)
51
51
  ;
52
- for (s = s << i | f, u += i; u > 0; t[r + w] = s & 255, w += O, s /= 256, u -= 8)
52
+ for (s = s << i | f, u += i; u > 0; t[r + y] = s & 255, y += O, s /= 256, u -= 8)
53
53
  ;
54
- t[r + w - O] |= E * 128;
54
+ t[r + y - O] |= E * 128;
55
55
  }
56
56
  var Kt = {}.toString, ct = Array.isArray || function(t) {
57
57
  return Kt.call(t) == "[object Array]";
@@ -348,8 +348,8 @@ function Ge(t, e, r, n, i) {
348
348
  return -1;
349
349
  o = 2, s /= 2, f /= 2, r /= 2;
350
350
  }
351
- function l(w, O) {
352
- return o === 1 ? w[O] : w.readUInt16BE(O * o);
351
+ function l(y, O) {
352
+ return o === 1 ? y[O] : y.readUInt16BE(O * o);
353
353
  }
354
354
  var u;
355
355
  if (i) {
@@ -361,8 +361,8 @@ function Ge(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, m = 0; m < f; m++)
365
- if (l(t, u + m) !== l(e, m)) {
364
+ for (var c = !0, g = 0; g < f; g++)
365
+ if (l(t, u + g) !== l(e, g)) {
366
366
  c = !1;
367
367
  break;
368
368
  }
@@ -1316,10 +1316,10 @@ 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 m;
1320
- return u ? m = zr(t, e, r, s, o) : m = o.map(function(w) {
1321
- return ke(t, e, r, s, w, u);
1322
- }), t.seen.pop(), Vr(m, l, h);
1319
+ var g;
1320
+ return u ? g = zr(t, e, r, s, o) : g = o.map(function(y) {
1321
+ return ke(t, e, r, s, y, u);
1322
+ }), t.seen.pop(), Vr(g, l, h);
1323
1323
  }
1324
1324
  function qr(t, e) {
1325
1325
  if (H(e))
@@ -1698,19 +1698,19 @@ R.prototype.pipe = function(t, e) {
1698
1698
  t.on("drain", l);
1699
1699
  var u = !1;
1700
1700
  function h() {
1701
- b("cleanup"), t.removeListener("close", O), t.removeListener("finish", E), t.removeListener("drain", l), t.removeListener("error", w), t.removeListener("unpipe", s), r.removeListener("end", f), r.removeListener("end", h), r.removeListener("data", m), u = !0, n.awaitDrain && (!t._writableState || t._writableState.needDrain) && l();
1701
+ b("cleanup"), t.removeListener("close", O), t.removeListener("finish", E), t.removeListener("drain", l), t.removeListener("error", y), t.removeListener("unpipe", s), r.removeListener("end", f), r.removeListener("end", h), r.removeListener("data", g), u = !0, n.awaitDrain && (!t._writableState || t._writableState.needDrain) && l();
1702
1702
  }
1703
1703
  var c = !1;
1704
- r.on("data", m);
1705
- function m(S) {
1704
+ r.on("data", g);
1705
+ function g(S) {
1706
1706
  b("ondata"), c = !1;
1707
- var g = t.write(S);
1708
- g === !1 && !c && ((n.pipesCount === 1 && n.pipes === t || n.pipesCount > 1 && Pt(n.pipes, t) !== -1) && !u && (b("false write response, pause", r._readableState.awaitDrain), r._readableState.awaitDrain++, c = !0), r.pause());
1707
+ var m = t.write(S);
1708
+ m === !1 && !c && ((n.pipesCount === 1 && n.pipes === t || n.pipesCount > 1 && Pt(n.pipes, t) !== -1) && !u && (b("false write response, pause", r._readableState.awaitDrain), r._readableState.awaitDrain++, c = !0), r.pause());
1709
1709
  }
1710
- function w(S) {
1711
- b("onerror", S), x(), t.removeListener("error", w), en(t, "error") === 0 && t.emit("error", S);
1710
+ function y(S) {
1711
+ b("onerror", S), x(), t.removeListener("error", y), en(t, "error") === 0 && t.emit("error", S);
1712
1712
  }
1713
- Kr(t, "error", w);
1713
+ Kr(t, "error", y);
1714
1714
  function O() {
1715
1715
  t.removeListener("finish", E), x();
1716
1716
  }
@@ -2113,9 +2113,9 @@ V.prototype.pipe = function(t, e) {
2113
2113
  const Vt = function(t) {
2114
2114
  return typeof t == "object" && t !== null && !Array.isArray(t);
2115
2115
  };
2116
- class _ extends Error {
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, _), this.code = e;
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 Jt = function(t) {
2133
2133
  e[r] = { name: i };
2134
2134
  else if (Vt(i)) {
2135
2135
  if (typeof i.name != "string")
2136
- throw new _("CSV_OPTION_COLUMNS_MISSING_NAME", [
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 _("CSV_INVALID_COLUMN_DEFINITION", [
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 Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = 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 Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = 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 Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = 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 Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = 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 Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = 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 Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = 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 Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = 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 Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = 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 = a.from(e.comment, e.encoding)), !N(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 Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = 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 Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = 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 Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2378
2378
  if (n == null || n === !1)
2379
2379
  return a.from(",", e.encoding);
2380
2380
  if (typeof n == "string" && (n = a.from(n, e.encoding)), !N(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 Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = 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 Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = 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 Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = 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 Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2506
2506
  e.record_delimiter = [];
2507
2507
  else if (typeof e.record_delimiter == "string" || N(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 Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = 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 Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2528
2528
  );
2529
2529
  if (e.record_delimiter = e.record_delimiter.map(function(n, i) {
2530
2530
  if (typeof n != "string" && !N(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 Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = 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`:",
@@ -2665,7 +2665,7 @@ const Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2665
2665
  state: Un(r),
2666
2666
  __needMoreData: function(n, i, o) {
2667
2667
  if (o) return !1;
2668
- const { encoding: s, escape: f, quote: l } = this.options, { quoting: u, needMoreDataSize: h, recordDelimiterMaxLength: c } = this.state, m = i - n - 1, w = Math.max(
2668
+ const { encoding: s, escape: f, quote: l } = this.options, { quoting: u, needMoreDataSize: h, recordDelimiterMaxLength: c } = this.state, g = i - n - 1, y = 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 Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2680
2680
  // Skip if remaining buffer can be record delimiter following the closing quote
2681
2681
  u ? l.length + c : 0
2682
2682
  );
2683
- return m < w;
2683
+ return g < y;
2684
2684
  },
2685
2685
  // Central parser implementation
2686
2686
  parse: function(n, i, o, s) {
@@ -2690,15 +2690,15 @@ const Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2690
2690
  encoding: u,
2691
2691
  from_line: h,
2692
2692
  ltrim: c,
2693
- max_record_size: m,
2694
- raw: w,
2693
+ max_record_size: g,
2694
+ raw: y,
2695
2695
  relax_quotes: O,
2696
2696
  rtrim: E,
2697
2697
  skip_empty_lines: x,
2698
2698
  to: S,
2699
- to_line: g
2699
+ to_line: m
2700
2700
  } = this.options;
2701
- let { comment: y, escape: L, quote: U, record_delimiter: Re } = this.options;
2701
+ let { comment: _, escape: L, quote: U, record_delimiter: Re } = this.options;
2702
2702
  const { bomSkipped: Yt, previousBuf: he, rawBuffer: Wt, escapeIsQuote: Ht } = this.state;
2703
2703
  let v;
2704
2704
  if (he === void 0)
@@ -2727,7 +2727,7 @@ const Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2727
2727
  });
2728
2728
  for (const C in ce)
2729
2729
  this.options[C] = ce[C];
2730
- ({ comment: y, escape: L, quote: U } = this.options);
2730
+ ({ comment: _, escape: L, quote: U } = this.options);
2731
2731
  break;
2732
2732
  }
2733
2733
  this.state.bomSkipped = !0;
@@ -2735,7 +2735,7 @@ const Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2735
2735
  const Ie = v.length;
2736
2736
  let d;
2737
2737
  for (d = 0; d < Ie && !this.__needMoreData(d, Ie, i); d++) {
2738
- if (this.state.wasRowDelimiter === !0 && (this.info.lines++, this.state.wasRowDelimiter = !1), g !== -1 && this.info.lines > g) {
2738
+ if (this.state.wasRowDelimiter === !0 && (this.info.lines++, this.state.wasRowDelimiter = !1), m !== -1 && this.info.lines > m) {
2739
2739
  this.state.stop = !0, s();
2740
2740
  return;
2741
2741
  }
@@ -2744,7 +2744,7 @@ const Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2744
2744
  d
2745
2745
  ) && (Re = this.options.record_delimiter);
2746
2746
  const I = v[d];
2747
- if (w === !0 && Wt.append(I), (I === Pn || I === $n) && this.state.wasRowDelimiter === !1 && (this.state.wasRowDelimiter = !0), this.state.escaping === !0)
2747
+ if (y === !0 && Wt.append(I), (I === Pn || I === $n) && this.state.wasRowDelimiter === !1 && (this.state.wasRowDelimiter = !0), this.state.escaping === !0)
2748
2748
  this.state.escaping = !1;
2749
2749
  else {
2750
2750
  if (L !== null && this.state.quoting === !0 && this.__isEscape(v, d, I) && d + L.length < Ie)
@@ -2759,7 +2759,7 @@ const Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2759
2759
  }
2760
2760
  if (this.state.commenting === !1 && this.__isQuote(v, d))
2761
2761
  if (this.state.quoting === !0) {
2762
- const C = v[d + U.length], Z = E && this.__isCharTrimable(v, d + U.length), j = y !== null && this.__compareBytes(y, v, d + U.length, C), X = this.__isDelimiter(
2762
+ const C = v[d + U.length], Z = E && this.__isCharTrimable(v, d + U.length), j = _ !== null && this.__compareBytes(_, v, d + U.length, C), X = this.__isDelimiter(
2763
2763
  v,
2764
2764
  d + U.length,
2765
2765
  C
@@ -2771,7 +2771,7 @@ const Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2771
2771
  continue;
2772
2772
  } else if (O === !1) {
2773
2773
  const He = this.__error(
2774
- new _(
2774
+ new w(
2775
2775
  "CSV_INVALID_CLOSING_QUOTE",
2776
2776
  [
2777
2777
  "Invalid Closing Quote:",
@@ -2792,7 +2792,7 @@ const Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2792
2792
  const C = 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:",
@@ -2846,7 +2846,7 @@ const Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2846
2846
  }
2847
2847
  if (this.state.commenting)
2848
2848
  continue;
2849
- if (y !== null && (l === !1 || this.state.record.length === 0 && this.state.field.length === 0) && this.__compareBytes(y, v, d, I) !== 0) {
2849
+ if (_ !== null && (l === !1 || this.state.record.length === 0 && this.state.field.length === 0) && this.__compareBytes(_, v, d, I) !== 0) {
2850
2850
  this.state.commenting = !0;
2851
2851
  continue;
2852
2852
  }
@@ -2860,14 +2860,14 @@ const Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2860
2860
  }
2861
2861
  }
2862
2862
  }
2863
- if (this.state.commenting === !1 && m !== 0 && this.state.record_length + this.state.field.length > m)
2863
+ if (this.state.commenting === !1 && g !== 0 && this.state.record_length + this.state.field.length > g)
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 ${m}`,
2870
+ `of ${g}`,
2871
2871
  `at line ${this.info.lines}`
2872
2872
  ],
2873
2873
  this.options,
@@ -2880,7 +2880,7 @@ const Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2880
2880
  else {
2881
2881
  if (E === !0 && !this.__isCharTrimable(v, 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:",
@@ -2898,7 +2898,7 @@ const Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2898
2898
  if (i === !0)
2899
2899
  if (this.state.quoting === !0) {
2900
2900
  const I = this.__error(
2901
- new _(
2901
+ new w(
2902
2902
  "CSV_QUOTE_NOT_CLOSED",
2903
2903
  [
2904
2904
  "Quote Not Closed:",
@@ -2930,21 +2930,21 @@ const Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2930
2930
  relax_column_count: u,
2931
2931
  relax_column_count_less: h,
2932
2932
  relax_column_count_more: c,
2933
- raw: m,
2934
- skip_records_with_empty_values: w
2933
+ raw: g,
2934
+ skip_records_with_empty_values: y
2935
2935
  } = this.options, { enabled: O, record: E } = this.state;
2936
2936
  if (O === !1)
2937
2937
  return this.__resetRecord();
2938
2938
  const x = E.length;
2939
2939
  if (i === !0) {
2940
- if (w === !0 && at(E)) {
2940
+ if (y === !0 && at(E)) {
2941
2941
  this.__resetRecord();
2942
2942
  return;
2943
2943
  }
2944
2944
  return this.__firstLineToColumns(E);
2945
2945
  }
2946
2946
  if (i === !1 && this.info.records === 0 && (this.state.expectedRecordLength = x), x !== this.state.expectedRecordLength) {
2947
- const S = i === !1 ? new _(
2947
+ const S = i === !1 ? new w(
2948
2948
  "CSV_RECORD_INCONSISTENT_FIELDS_LENGTH",
2949
2949
  [
2950
2950
  "Invalid Record Length:",
@@ -2956,7 +2956,7 @@ const Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2956
2956
  {
2957
2957
  record: E
2958
2958
  }
2959
- ) : new _(
2959
+ ) : new w(
2960
2960
  "CSV_RECORD_INCONSISTENT_COLUMNS",
2961
2961
  [
2962
2962
  "Invalid Record Length:",
@@ -2973,11 +2973,11 @@ const Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2973
2973
  if (u === !0 || h === !0 && x < this.state.expectedRecordLength || c === !0 && x > this.state.expectedRecordLength)
2974
2974
  this.info.invalid_field_length++, this.state.error = S;
2975
2975
  else {
2976
- const g = this.__error(S);
2977
- if (g) return g;
2976
+ const m = this.__error(S);
2977
+ if (m) return m;
2978
2978
  }
2979
2979
  }
2980
- if (w === !0 && at(E)) {
2980
+ if (y === !0 && at(E)) {
2981
2981
  this.__resetRecord();
2982
2982
  return;
2983
2983
  }
@@ -2988,46 +2988,46 @@ const Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = function(t) {
2988
2988
  if (this.info.records++, l === 1 || this.info.records >= l) {
2989
2989
  const { objname: S } = this.options;
2990
2990
  if (i !== !1) {
2991
- const g = {};
2992
- for (let y = 0, L = E.length; y < L; y++)
2993
- i[y] === void 0 || i[y].disabled || (o === !0 && g[i[y].name] !== void 0 ? Array.isArray(g[i[y].name]) ? g[i[y].name] = g[i[y].name].concat(E[y]) : g[i[y].name] = [g[i[y].name], E[y]] : g[i[y].name] = E[y]);
2994
- if (m === !0 || f === !0) {
2995
- const y = Object.assign(
2996
- { record: g },
2997
- m === !0 ? { raw: this.state.rawBuffer.toString(s) } : {},
2991
+ const m = {};
2992
+ for (let _ = 0, L = E.length; _ < L; _++)
2993
+ i[_] === void 0 || i[_].disabled || (o === !0 && m[i[_].name] !== void 0 ? Array.isArray(m[i[_].name]) ? m[i[_].name] = m[i[_].name].concat(E[_]) : m[i[_].name] = [m[i[_].name], E[_]] : m[i[_].name] = E[_]);
2994
+ if (g === !0 || f === !0) {
2995
+ const _ = Object.assign(
2996
+ { record: m },
2997
+ g === !0 ? { raw: this.state.rawBuffer.toString(s) } : {},
2998
2998
  f === !0 ? { info: this.__infoRecord() } : {}
2999
2999
  ), L = this.__push(
3000
- S === void 0 ? y : [g[S], y],
3000
+ S === void 0 ? _ : [m[S], _],
3001
3001
  n
3002
3002
  );
3003
3003
  if (L)
3004
3004
  return L;
3005
3005
  } else {
3006
- const y = this.__push(
3007
- S === void 0 ? g : [g[S], g],
3006
+ const _ = this.__push(
3007
+ S === void 0 ? m : [m[S], m],
3008
3008
  n
3009
3009
  );
3010
- if (y)
3011
- return y;
3010
+ if (_)
3011
+ return _;
3012
3012
  }
3013
- } else if (m === !0 || f === !0) {
3014
- const g = Object.assign(
3013
+ } else if (g === !0 || f === !0) {
3014
+ const m = Object.assign(
3015
3015
  { record: E },
3016
- m === !0 ? { raw: this.state.rawBuffer.toString(s) } : {},
3016
+ g === !0 ? { raw: this.state.rawBuffer.toString(s) } : {},
3017
3017
  f === !0 ? { info: this.__infoRecord() } : {}
3018
- ), y = this.__push(
3019
- S === void 0 ? g : [E[S], g],
3018
+ ), _ = this.__push(
3019
+ S === void 0 ? m : [E[S], m],
3020
3020
  n
3021
3021
  );
3022
- if (y)
3023
- return y;
3022
+ if (_)
3023
+ return _;
3024
3024
  } else {
3025
- const g = this.__push(
3025
+ const m = this.__push(
3026
3026
  S === void 0 ? E : [E[S], E],
3027
3027
  n
3028
3028
  );
3029
- if (g)
3030
- return g;
3029
+ if (m)
3030
+ return m;
3031
3031
  }
3032
3032
  }
3033
3033
  this.__resetRecord();
@@ -3038,7 +3038,7 @@ const Nn = 12, Dn = 13, Fn = 10, Mn = 32, Bn = 9, Un = 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:",
@@ -3303,7 +3303,7 @@ const lt = 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 || {}
@@ -3382,31 +3382,33 @@ class Gn {
3382
3382
  /** Parse stream. */
3383
3383
  async parseStream(e, r, n, i) {
3384
3384
  return new Promise((o, s) => {
3385
- let f, l, u, h = !1, c = 0, m = !1;
3386
- const w = () => {
3387
- if (m) return;
3388
- m = !0;
3385
+ let f, l, u, h = !1, c = 0, g = !1;
3386
+ const y = () => {
3387
+ if (g) return;
3388
+ g = !0;
3389
3389
  const x = f;
3390
3390
  f = void 0, u = void 0, x != null && (this.ignoreErrors(() => x.removeAllListeners()), this.ignoreErrors(() => x.end())), this.ignoreErrors(() => {
3391
3391
  l?.cancel();
3392
3392
  }), l = void 0;
3393
3393
  }, O = (x) => {
3394
- h || (console.log("handleError 1"), h = !0, console.log("handleError 2"), w(), i.signal.aborted || i.abort(x), console.log("handleError 3"), console.log("handleError 4"), s(x), console.log("handleError 5"));
3394
+ h || (console.log("handleError 1"), h = !0, console.log("handleError 2"), y(), i.signal.aborted || i.abort(x), console.log("handleError 3"), console.log("handleError 4"), s(x), console.log("handleError 5"));
3395
3395
  };
3396
- i.signal.addEventListener("abort", w, { once: !0 }), (async () => {
3397
- f = lt(e), u = this.constructRowBuffer({ chunk: r.chunk, chunkSize: r.chunkSize ?? Qn }), f.on("readable", () => {
3396
+ i.signal.addEventListener("abort", y, { once: !0 }), (async () => {
3397
+ f = lt(e), u = this.constructRowBuffer({ chunk: () => {
3398
+ }, chunkSize: r.chunkSize ?? Qn }), f.on("readable", () => {
3398
3399
  try {
3399
- if (console.log(2222, c), f == null || u == null) return;
3400
- let g;
3401
- for (; (g = f.read()) != null; ) {
3400
+ const m = c;
3401
+ if (f == null || u == null) return;
3402
+ let _;
3403
+ for (; (_ = f.read()) != null; ) {
3402
3404
  if (c++, h) return;
3403
- i.signal.throwIfAborted(), u.push(g);
3405
+ i.signal.throwIfAborted(), u.push(_);
3404
3406
  }
3405
- console.log(3333, c);
3406
- } catch (g) {
3407
- O(g);
3407
+ console.log(3333, c - m);
3408
+ } catch (m) {
3409
+ O(m);
3408
3410
  }
3409
- }), f.on("error", (g) => O(g)), f.on("end", () => {
3411
+ }), f.on("error", (m) => O(m)), f.on("end", () => {
3410
3412
  h || (u?.flush(), o(this.constructSummary(f)));
3411
3413
  });
3412
3414
  const x = await fetch(encodeURI(n), { signal: i.signal });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datapos/datapos-tool-csv-parse",
3
- "version": "0.0.39",
3
+ "version": "0.0.40",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "private": false,