@dpuse/dpuse-tool-adaltas-csv-parser 1.0.107 → 1.0.112

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/README.md CHANGED
@@ -3,8 +3,8 @@
3
3
  <!-- OPENING_START -->
4
4
 
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)
6
- [![DPUse version](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.dpuse.app%2Fconfigs%2Fdpuse-tool-adaltas-csv-parser&query=%24.data.version&prefix=v&label=DPUse&color=f6821f)](https://github.com/dpuse/dpuse-tool-adaltas-csv-parser/releases/latest)
7
- [![npm version](https://img.shields.io/npm/v/@dpuse/dpuse-tool-adaltas-csv-parser?color=cb3837&label=npm)](https://www.npmjs.com/package/@dpuse/dpuse-tool-adaltas-csv-parser)
6
+ [![DPUse version](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.dpuse.app%2Fconfigs%2Fdpuse-tool-adaltas-csv-parser&query=%24.data.version&prefix=v&label=DPUse&color=blue)](https://github.com/dpuse/dpuse-tool-adaltas-csv-parser/releases/latest)
7
+ [![npm version](https://img.shields.io/npm/v/@dpuse/dpuse-tool-adaltas-csv-parser?label=npm)](https://www.npmjs.com/package/@dpuse/dpuse-tool-adaltas-csv-parser)
8
8
  [![CI](https://github.com/dpuse/dpuse-tool-adaltas-csv-parser/actions/workflows/ci.yml/badge.svg)](https://github.com/dpuse/dpuse-tool-adaltas-csv-parser/actions/workflows/ci.yml)
9
9
 
10
10
  ...
@@ -61,7 +61,7 @@ License data is updated each time `npm run document` is run, using [license-chec
61
61
 
62
62
  | Dependency | Version | License(s) | Document |
63
63
  | :----------------------------------------------------------- | :-----: | :--------- | :-------------------------------------------------------------------- |
64
- | [@dpuse/dpuse-shared](https://github.com/dpuse/dpuse-shared) | 1.0.113 | MIT | [LICENSE](licenses/downloads/@dpuse/dpuse-shared@1.0.113-LICENSE.txt) |
64
+ | [@dpuse/dpuse-shared](https://github.com/dpuse/dpuse-shared) | 1.0.132 | MIT | [LICENSE](licenses/downloads/@dpuse/dpuse-shared@1.0.132-LICENSE.txt) |
65
65
  | [csv-parse](https://github.com/adaltas/node-csv) | 7.0.3 | MIT | [LICENSE](licenses/downloads/csv-parse@7.0.3-LICENSE.txt) |
66
66
  | [valibot](https://github.com/open-circle/valibot) | 1.5.0 | MIT | [LICENSE](licenses/downloads/valibot@1.5.0-LICENSE.txt) |
67
67
 
@@ -69,8 +69,8 @@ License data is updated each time `npm run document` is run, using [license-chec
69
69
 
70
70
  The dependency tree below shows how each package in the table above is reached — direct and transitive — along with its installed version, release date, and update status. A package that does not ship itself, such as one whose parts are bundled separately, is left out and what ships beneath it is shown in its place. Packages flagged ❗ have a newer version available; ⚠️ indicates a package that hasn't been updated in the last 6 months or longer. Neither flag necessarily indicates a problem: we let new releases stabilise before upgrading, and some packages are mature and stable (have limited or no dependencies), so they require no active development.
71
71
 
72
- - **[@dpuse/dpuse-shared](https://github.com/dpuse/dpuse-shared)** 1.0.113 — this month: 2026-10-05 → latest: 1.0.116 — this month: 2026-10-06 ❗
73
- - **[valibot](https://github.com/open-circle/valibot)** 1.5.0 — this month: 2026-09-09
72
+ - **[@dpuse/dpuse-shared](https://github.com/dpuse/dpuse-shared)** 1.0.132 — this month: 2026-10-23
73
+ - **[valibot](https://github.com/open-circle/valibot)** 1.5.0 — 1 mth ago: 2026-09-09
74
74
  - **[csv-parse](https://github.com/adaltas/node-csv)** 7.0.3 — this month: 2026-09-25
75
75
 
76
76
  <!-- DEPENDENCY_LICENSES_END -->
@@ -83,13 +83,13 @@ This report is updated with each release, from the bundle the release builds, us
83
83
 
84
84
  _Note: Sonda's Vite reports currently exclude CSS files, since Vite does not generate source maps for CSS._
85
85
 
86
- | Chunk/Module/File | Composition |
87
- | :-------------------------------------------------------------------- | :-------------------------------------------- |
88
- | **dist/dpuse-tool-adaltas-csv-parser.es.js** | 125.2 kB · gzip 31.3 kB · 100.0% of the build |
89
- | &nbsp;&nbsp;&nbsp;&nbsp;csv-parse → dist/esm/index.js | `████████████████░░░░` 79.3% · 99.3 kB |
90
- | &nbsp;&nbsp;&nbsp;&nbsp;@dpuse/dpuse-shared → dist/dpuse-shared.es.js | `██░░░░░░░░░░░░░░░░░░` 12.0% · 15.0 kB |
91
- | &nbsp;&nbsp;&nbsp;&nbsp;src → index.ts | `█░░░░░░░░░░░░░░░░░░░` 2.9% · 3.7 kB |
92
- | &nbsp;&nbsp;&nbsp;&nbsp;(bundler output, whitespace & JSON) | `█░░░░░░░░░░░░░░░░░░░` 5.8% · 7.3 kB |
86
+ | Chunk/Module/File | Composition |
87
+ | :-------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------- |
88
+ | **dist/dpuse-tool-adaltas-csv-parser.es.js** | 125.7&nbsp;kB&nbsp;·&nbsp;gzip&nbsp;31.6&nbsp;kB&nbsp;·&nbsp;100.0%&nbsp;of&nbsp;the&nbsp;build |
89
+ | &nbsp;&nbsp;&nbsp;&nbsp;csv-parse → dist/esm/index.js | `████████████████░░░░`&nbsp;78.9%&nbsp;·&nbsp;99.2&nbsp;kB |
90
+ | &nbsp;&nbsp;&nbsp;&nbsp;@dpuse/dpuse-shared → dist/dpuse-shared.es.js | `██░░░░░░░░░░░░░░░░░░`&nbsp;12.0%&nbsp;·&nbsp;15.1&nbsp;kB |
91
+ | &nbsp;&nbsp;&nbsp;&nbsp;src → index.ts | `█░░░░░░░░░░░░░░░░░░░`&nbsp;3.4%&nbsp;·&nbsp;4.2&nbsp;kB |
92
+ | &nbsp;&nbsp;&nbsp;&nbsp;(bundler output, whitespace & JSON) | `█░░░░░░░░░░░░░░░░░░░`&nbsp;5.7%&nbsp;·&nbsp;7.2&nbsp;kB |
93
93
 
94
94
  Bars show each row's share of its output file.
95
95
 
@@ -105,10 +105,11 @@ This section is updated each time `npm run document` is run. Settings come from
105
105
 
106
106
  ### Testing
107
107
 
108
- | Check | Status | What it does |
109
- | :------------------- | :----- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
110
- | Unit tests | ✅ On | [Vitest](https://vitest.dev) runs the unit tests. Part of the [CI workflow](https://github.com/dpuse/dpuse-tool-adaltas-csv-parser/actions/workflows/ci.yml) on every push and pull request to `main`. |
111
- | Property-based tests | ❌ Off | [fast-check](https://fast-check.dev) runs many random inputs per test to find edge cases, alongside the unit tests. |
108
+ | Check | Status | What it does |
109
+ | :------------------- | :----- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
110
+ | Unit tests | ✅ On | [Vitest](https://vitest.dev) runs the unit tests. Part of the [CI workflow](https://github.com/dpuse/dpuse-tool-adaltas-csv-parser/actions/workflows/ci.yml) on every push and pull request to `main`. |
111
+ | Property-based tests | ❌ Off | [fast-check](https://fast-check.dev) runs many random inputs per test to find edge cases, alongside the unit tests. |
112
+ | Test coverage | ✅ On | ![Coverage](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fdpuse%2Fdpuse-tool-adaltas-csv-parser%2Fmain%2Fcode-health-reports%2Fvitest%2Fbadge.json) [Vitest's V8 coverage](https://vitest.dev/guide/coverage) measures the share of source lines the unit tests run. The target is 80%. |
112
113
 
113
114
  ### Code Quality
114
115
 
@@ -1,4 +1,4 @@
1
- //#region node_modules/csv-parse/dist/esm/index.js
1
+ // node_modules/csv-parse/dist/esm/index.js
2
2
  var e = typeof global < "u" ? global : typeof self < "u" ? self : typeof window < "u" ? window : {}, t = [], n = [], r = typeof Uint8Array < "u" ? Uint8Array : Array, i = !1;
3
3
  function a() {
4
4
  i = !0;
@@ -519,7 +519,7 @@ _.prototype.writeUInt32LE = function(e, t, n) {
519
519
  E(this, e, t, n, i - 1, -i);
520
520
  }
521
521
  var a = 0, o = 1, s = 0;
522
- for (this[t] = e & 255; ++a < n && (o *= 256);) e < 0 && s === 0 && this[t + a - 1] !== 0 && (s = 1), this[t + a] = (e / o >> 0) - s & 255;
522
+ for (this[t] = e & 255; ++a < n && (o *= 256);) e < 0 && s === 0 && this[t + a - 1] !== 0 && (s = 1), this[t + a] = (e / o | 0) - s & 255;
523
523
  return t + n;
524
524
  }, _.prototype.writeIntBE = function(e, t, n, r) {
525
525
  if (e = +e, t |= 0, !r) {
@@ -527,7 +527,7 @@ _.prototype.writeUInt32LE = function(e, t, n) {
527
527
  E(this, e, t, n, i - 1, -i);
528
528
  }
529
529
  var a = n - 1, o = 1, s = 0;
530
- for (this[t + a] = e & 255; --a >= 0 && (o *= 256);) e < 0 && s === 0 && this[t + a + 1] !== 0 && (s = 1), this[t + a] = (e / o >> 0) - s & 255;
530
+ for (this[t + a] = e & 255; --a >= 0 && (o *= 256);) e < 0 && s === 0 && this[t + a + 1] !== 0 && (s = 1), this[t + a] = (e / o | 0) - s & 255;
531
531
  return t + n;
532
532
  }, _.prototype.writeInt8 = function(e, t, n) {
533
533
  return e = +e, t |= 0, n || E(this, e, t, 1, 127, -128), _.TYPED_ARRAY_SUPPORT || (e = Math.floor(e)), e < 0 && (e = 255 + e + 1), this[t] = e & 255, t + 1;
@@ -606,11 +606,7 @@ function je(e, t) {
606
606
  for (var n, r = e.length, i = null, a = [], o = 0; o < r; ++o) {
607
607
  if (n = e.charCodeAt(o), n > 55295 && n < 57344) {
608
608
  if (!i) {
609
- if (n > 56319) {
610
- (t -= 3) > -1 && a.push(239, 191, 189);
611
- continue;
612
- }
613
- if (o + 1 === r) {
609
+ if (n > 56319 || o + 1 === r) {
614
610
  (t -= 3) > -1 && a.push(239, 191, 189);
615
611
  continue;
616
612
  }
@@ -673,7 +669,7 @@ function k() {
673
669
  k.init.call(this);
674
670
  }
675
671
  k.EventEmitter = k, k.usingDomains = !1, k.prototype.domain = void 0, k.prototype._events = void 0, k.prototype._maxListeners = void 0, k.defaultMaxListeners = 10, k.init = function() {
676
- this.domain = null, k.usingDomains && ze.active && !(this instanceof ze.Domain) && (this.domain = ze.active), (!this._events || this._events === Object.getPrototypeOf(this)._events) && (this._events = new O(), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
672
+ this.domain = null, k.usingDomains && ze.active && !(this instanceof ze.Domain) && (this.domain = ze.active), this._events && this._events !== Object.getPrototypeOf(this)._events || (this._events = new O(), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
677
673
  }, k.prototype.setMaxListeners = function(e) {
678
674
  if (typeof e != "number" || e < 0 || isNaN(e)) throw TypeError("\"n\" argument must be a positive number");
679
675
  return this._maxListeners = e, this;
@@ -1180,12 +1176,11 @@ Bt.prototype.write = function(e) {
1180
1176
  if (e.copy(this.charBuffer, this.charReceived, 0, n), this.charReceived += n, this.charReceived < this.charLength) return "";
1181
1177
  e = e.slice(n, e.length), t = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
1182
1178
  var r = t.charCodeAt(t.length - 1);
1183
- if (r >= 55296 && r <= 56319) {
1184
- this.charLength += this.surrogateSize, t = "";
1185
- continue;
1179
+ if (r >= 55296 && r <= 56319) this.charLength += this.surrogateSize, t = "";
1180
+ else {
1181
+ if (this.charReceived = this.charLength = 0, e.length === 0) return t;
1182
+ break;
1186
1183
  }
1187
- if (this.charReceived = this.charLength = 0, e.length === 0) return t;
1188
- break;
1189
1184
  }
1190
1185
  this.detectIncompleteChar(e);
1191
1186
  var i = e.length;
@@ -1385,7 +1380,7 @@ function an(e) {
1385
1380
  V.prototype.unpipe = function(e) {
1386
1381
  var t = this._readableState;
1387
1382
  if (t.pipesCount === 0) return this;
1388
- if (t.pipesCount === 1) return e && e !== t.pipes ? this : (e ||= t.pipes, t.pipes = null, t.pipesCount = 0, t.flowing = !1, e && e.emit("unpipe", this), this);
1383
+ if (t.pipesCount === 1) return e && e !== t.pipes || (e ||= t.pipes, t.pipes = null, t.pipesCount = 0, t.flowing = !1, e && e.emit("unpipe", this)), this;
1389
1384
  if (!e) {
1390
1385
  var n = t.pipes, r = t.pipesCount;
1391
1386
  t.pipes = null, t.pipesCount = 0, t.flowing = !1;
@@ -1393,7 +1388,7 @@ V.prototype.unpipe = function(e) {
1393
1388
  return this;
1394
1389
  }
1395
1390
  var a = _n(t.pipes, e);
1396
- return a === -1 ? this : (t.pipes.splice(a, 1), --t.pipesCount, t.pipesCount === 1 && (t.pipes = t.pipes[0]), e.emit("unpipe", this), this);
1391
+ return a === -1 || (t.pipes.splice(a, 1), --t.pipesCount, t.pipesCount === 1 && (t.pipes = t.pipes[0]), e.emit("unpipe", this)), this;
1397
1392
  }, V.prototype.on = function(e, t) {
1398
1393
  var n = k.prototype.on.call(this, e, t);
1399
1394
  if (e === "data") this._readableState.flowing !== !1 && this.resume();
@@ -1541,7 +1536,7 @@ H.prototype.write = function(e, t, n) {
1541
1536
  e.corked++;
1542
1537
  }, H.prototype.uncork = function() {
1543
1538
  var e = this._writableState;
1544
- e.corked && (e.corked--, !e.writing && !e.corked && !e.finished && !e.bufferProcessing && e.bufferedRequest && jn(this, e));
1539
+ e.corked && (e.corked--, e.writing || e.corked || e.finished || e.bufferProcessing || !e.bufferedRequest || jn(this, e));
1545
1540
  }, H.prototype.setDefaultEncoding = function(e) {
1546
1541
  if (typeof e == "string" && (e = e.toLowerCase()), !([
1547
1542
  "hex",
@@ -1723,7 +1718,7 @@ G.prototype.pipe = function(e, t) {
1723
1718
  function i() {
1724
1719
  n.readable && n.resume && n.resume();
1725
1720
  }
1726
- e.on("drain", i), !e._isStdio && (!t || t.end !== !1) && (n.on("end", o), n.on("close", s));
1721
+ e.on("drain", i), e._isStdio || t && t.end === !1 || (n.on("end", o), n.on("close", s));
1727
1722
  var a = !1;
1728
1723
  function o() {
1729
1724
  a || (a = !0, e.end());
@@ -2343,40 +2338,36 @@ var Kn = function(e) {
2343
2338
  if (t) return t;
2344
2339
  }
2345
2340
  }
2346
- if (u === !0 && er(f)) {
2347
- this.__resetRecord();
2348
- return;
2349
- }
2350
- if (this.state.recordHasError === !0) {
2351
- this.__resetRecord(), this.state.recordHasError = !1;
2352
- return;
2353
- }
2354
- if (this.info.records++, a === 1 || this.info.records >= a) {
2355
- let { objname: a } = this.options;
2356
- if (t !== !1) {
2357
- let o = {};
2358
- for (let e = 0, r = f.length; e < r; e++) t[e] === void 0 || t[e].disabled || (n === !0 && Object.hasOwn(o, t[e].name) ? Array.isArray(o[t[e].name]) ? o[t[e].name] = o[t[e].name].concat(f[e]) : o[t[e].name] = [o[t[e].name], f[e]] : Object.defineProperty(o, t[e].name, {
2359
- value: f[e],
2360
- enumerable: !0,
2361
- writable: !0,
2362
- configurable: !0
2363
- }));
2364
- if (l === !0 || i === !0) {
2365
- let t = Object.assign({ record: o }, l === !0 ? { raw: this.state.rawBuffer.toString(r) } : {}, i === !0 ? { info: this.__infoRecord() } : {}), n = this.__push(a === void 0 ? t : [o[a], t], e);
2341
+ if (u === !0 && er(f)) this.__resetRecord();
2342
+ else if (this.state.recordHasError === !0) this.__resetRecord(), this.state.recordHasError = !1;
2343
+ else {
2344
+ if (this.info.records++, a === 1 || this.info.records >= a) {
2345
+ let { objname: a } = this.options;
2346
+ if (t !== !1) {
2347
+ let o = {};
2348
+ for (let e = 0, r = f.length; e < r; e++) t[e] === void 0 || t[e].disabled || (n === !0 && Object.hasOwn(o, t[e].name) ? Array.isArray(o[t[e].name]) ? o[t[e].name] = o[t[e].name].concat(f[e]) : o[t[e].name] = [o[t[e].name], f[e]] : Object.defineProperty(o, t[e].name, {
2349
+ value: f[e],
2350
+ enumerable: !0,
2351
+ writable: !0,
2352
+ configurable: !0
2353
+ }));
2354
+ if (l === !0 || i === !0) {
2355
+ let t = Object.assign({ record: o }, l === !0 ? { raw: this.state.rawBuffer.toString(r) } : {}, i === !0 ? { info: this.__infoRecord() } : {}), n = this.__push(a === void 0 ? t : [o[a], t], e);
2356
+ if (n) return n;
2357
+ } else {
2358
+ let t = this.__push(a === void 0 ? o : [o[a], o], e);
2359
+ if (t) return t;
2360
+ }
2361
+ } else if (l === !0 || i === !0) {
2362
+ let t = Object.assign({ record: f }, l === !0 ? { raw: this.state.rawBuffer.toString(r) } : {}, i === !0 ? { info: this.__infoRecord() } : {}), n = this.__push(a === void 0 ? t : [f[a], t], e);
2366
2363
  if (n) return n;
2367
2364
  } else {
2368
- let t = this.__push(a === void 0 ? o : [o[a], o], e);
2365
+ let t = this.__push(a === void 0 ? f : [f[a], f], e);
2369
2366
  if (t) return t;
2370
2367
  }
2371
- } else if (l === !0 || i === !0) {
2372
- let t = Object.assign({ record: f }, l === !0 ? { raw: this.state.rawBuffer.toString(r) } : {}, i === !0 ? { info: this.__infoRecord() } : {}), n = this.__push(a === void 0 ? t : [f[a], t], e);
2373
- if (n) return n;
2374
- } else {
2375
- let t = this.__push(a === void 0 ? f : [f[a], f], e);
2376
- if (t) return t;
2377
2368
  }
2369
+ this.__resetRecord();
2378
2370
  }
2379
- this.__resetRecord();
2380
2371
  },
2381
2372
  __firstLineToColumns: function(e) {
2382
2373
  let { firstLineToHeaders: t } = this.state;
@@ -2520,9 +2511,7 @@ var Kn = function(e) {
2520
2511
  } catch (e) {
2521
2512
  return e;
2522
2513
  }
2523
- return;
2524
- }
2525
- return i;
2514
+ } else return i;
2526
2515
  },
2527
2516
  __infoDataSet: function() {
2528
2517
  return {
@@ -2609,8 +2598,7 @@ var Kn = function(e) {
2609
2598
  }
2610
2599
  return r;
2611
2600
  };
2612
- //#endregion
2613
- //#region node_modules/@dpuse/dpuse-shared/dist/dpuse-shared.es.js
2601
+ // node_modules/@dpuse/dpuse-shared/dist/dpuse-shared.es.js
2614
2602
  function J(e) {
2615
2603
  return new Map(Object.entries(e));
2616
2604
  }
@@ -2912,7 +2900,7 @@ var Tr = {
2912
2900
  status: /* @__PURE__ */ Z(Cr),
2913
2901
  statusId: /* @__PURE__ */ Z(Sr)
2914
2902
  };
2915
- ({ ...Tr }), J({ en: "Data Positioning Events" }), J({ en: "Delimited Text" }), J({ en: "JSON" }), J({ en: "SPSS" }), J({ en: "XLSX" }), J({ en: "XML" }), J({ en: "Newline" }), J({ en: "Carriage Return" }), J({ en: "Carriage Return/Newline" }), J({ en: "Colon" }), J({ en: "Comma" }), J({ en: "Exclamation Mark" }), J({ en: "Record Separator" }), J({ en: "Semicolon" }), J({ en: "Space" }), J({ en: "Tab" }), J({ en: "Underscore" }), J({ en: "Unit Separator" }), J({ en: "Vertical Bar" }), $([
2903
+ ({ ...Tr }), J({ en: "Data Positioning Events" }), J({ en: "Delimited Text" }), J({ en: "JSON" }), J({ en: "JSON Lines" }), J({ en: "Markdown" }), J({ en: "SPSS" }), J({ en: "Plain Text" }), J({ en: "XLSX" }), J({ en: "XML" }), J({ en: "Newline" }), J({ en: "Carriage Return" }), J({ en: "Carriage Return/Newline" }), J({ en: "Colon" }), J({ en: "Comma" }), J({ en: "Exclamation Mark" }), J({ en: "Record Separator" }), J({ en: "Semicolon" }), J({ en: "Space" }), J({ en: "Tab" }), J({ en: "Underscore" }), J({ en: "Unit Separator" }), J({ en: "Vertical Bar" }), $([
2916
2904
  "app",
2917
2905
  "engine",
2918
2906
  "connector",
@@ -2948,6 +2936,10 @@ var Er = {
2948
2936
  "curatedDataset",
2949
2937
  "database",
2950
2938
  "fileStore"
2939
+ ]), $([
2940
+ "apiEndpoint",
2941
+ "file",
2942
+ "table"
2951
2943
  ]), $([
2952
2944
  "bidirectional",
2953
2945
  "destination",
@@ -2958,11 +2950,7 @@ var Er = {
2958
2950
  "disabled",
2959
2951
  "oAuth2",
2960
2952
  "none"
2961
- ]), { ...Er }, $(["list"]), { ...Er }, $([
2962
- "list",
2963
- "render",
2964
- "setColorMode"
2965
- ]), { ...Er };
2953
+ ]), { ...Er }, $(["list"]), { ...Er };
2966
2954
  var Dr = 2048, Or = class extends Error {
2967
2955
  data;
2968
2956
  locator;
@@ -3003,6 +2991,11 @@ function Mr(e) {
3003
2991
  function Nr(e) {
3004
2992
  if (e != null && e !== "") return e.length > Dr ? `${e.slice(0, Dr)}... [truncated]` : e;
3005
2993
  }
2994
+ $([
2995
+ "list",
2996
+ "render",
2997
+ "setColorMode"
2998
+ ]), { ...Er };
3006
2999
  var Pr = {
3007
3000
  ascii: {
3008
3001
  id: "ascii",
@@ -3441,8 +3434,7 @@ function Fr(e) {
3441
3434
  function Ir(e) {
3442
3435
  return Fr(e) ? Pr[e].decoderId ?? e : e;
3443
3436
  }
3444
- //#endregion
3445
- //#region src/index.ts
3437
+ // src/index.ts
3446
3438
  var Lr = {
3447
3439
  bom: !1,
3448
3440
  cast_date: !1,
@@ -3573,42 +3565,58 @@ function Ur(e) {
3573
3565
  return t >= n && t >= r ? "\r\n" : n >= t && n >= r ? "\n" : r >= t && r >= n ? "\r" : "\n";
3574
3566
  }
3575
3567
  async function Wr(e, t) {
3576
- let n, r, i, a = [];
3577
- for (let o of t) try {
3578
- let t = 0, s, c = 0, l = 0, u = ar({
3568
+ let n, r, i, a = [], o, s = !1;
3569
+ for (let c of t) {
3570
+ let { error: t, records: l } = await Gr(e, c);
3571
+ if (t != null) {
3572
+ o ??= t;
3573
+ continue;
3574
+ }
3575
+ if (s = !0, l.length === 0) continue;
3576
+ let { averageValueCount: u, sumOfValueCountDiffs: d } = Kr(l);
3577
+ (!i || d <= i) && (!r || u > r) && (n = c, r = u, i = d, a = l);
3578
+ }
3579
+ if (!s && o != null) throw o;
3580
+ return {
3581
+ parsedRecords: a,
3582
+ valueDelimiterId: n != null && qr(a) ? n : void 0
3583
+ };
3584
+ }
3585
+ function Gr(e, t) {
3586
+ return new Promise((n) => {
3587
+ let r = [], i = ar({
3579
3588
  ...Lr,
3580
3589
  cast: (e, t) => ({
3581
3590
  value: e,
3582
3591
  wasValueQuoted: t.quoting
3583
3592
  }),
3584
- delimiter: o,
3593
+ delimiter: t,
3585
3594
  relax_column_count: !0
3586
3595
  });
3587
- await new Promise((d) => {
3588
- try {
3589
- let f = [];
3590
- u.on("readable", () => {
3591
- let e;
3592
- for (; (e = u.read()) != null;) {
3593
- c++;
3594
- let n = e.length;
3595
- s != null && (l += Math.abs(n - s)), s = n, t += n, f.push(e);
3596
- }
3597
- }), u.on("error", () => {
3598
- d();
3599
- }), u.on("end", () => {
3600
- let e = t / c;
3601
- (!i || l <= i) && (!r || e > r) && (n = o, r = e, i = l, a = [...f]), d();
3602
- }), u.write(e), u.end();
3603
- } catch {
3604
- d();
3605
- }
3606
- });
3607
- } catch {}
3596
+ i.on("data", (e) => {
3597
+ r.push(e);
3598
+ }), i.on("error", (e) => {
3599
+ n(e.code === "CSV_QUOTE_NOT_CLOSED" ? { records: r } : {
3600
+ error: e,
3601
+ records: r
3602
+ });
3603
+ }), i.on("end", () => {
3604
+ n({ records: r });
3605
+ }), i.write(e), i.end();
3606
+ });
3607
+ }
3608
+ function Kr(e) {
3609
+ let t = 0, n = 0, r;
3610
+ for (let i of e) r != null && (n += Math.abs(i.length - r)), r = i.length, t += i.length;
3608
3611
  return {
3609
- parsedRecords: a,
3610
- valueDelimiterId: n ?? ","
3612
+ averageValueCount: t / e.length,
3613
+ sumOfValueCountDiffs: n
3611
3614
  };
3612
3615
  }
3613
- //#endregion
3616
+ function qr(e) {
3617
+ let t = /* @__PURE__ */ new Map();
3618
+ for (let n of e) t.set(n.length, (t.get(n.length) ?? 0) + 1);
3619
+ let [n = 0, r = 0] = [...t].toSorted((e, t) => t[1] - e[1])[0] ?? [];
3620
+ return n > 1 && r * 2 > e.length;
3621
+ }
3614
3622
  export { Br as Tool };