@datapos/datapos-tool-csv-parse 0.0.30 → 0.0.32

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.
@@ -3384,35 +3384,34 @@ class Gn {
3384
3384
  return new Promise((o, s) => {
3385
3385
  let f, u, l, h = !1;
3386
3386
  const c = (p) => {
3387
- if (console.log(1111, p), !h) {
3388
- h = !0, i.signal.aborted || i.abort(p instanceof Error ? p : new Error("Parser aborted due to an unknown error."));
3389
- try {
3390
- u?.cancel();
3391
- } catch {
3392
- }
3393
- console.log(2222, p), s(p);
3394
- }
3387
+ h || (h = !0, i.signal.aborted || i.abort(p), this.ignoreErrors(() => {
3388
+ u?.cancel();
3389
+ }), s(p));
3395
3390
  };
3396
3391
  (async () => {
3397
3392
  f = ut(e), l = this.constructRowBuffer({ chunk: r.chunk, chunkSize: r.chunkSize ?? Qn }), f.on("readable", () => {
3398
3393
  try {
3399
3394
  if (f == null || l == null) return;
3400
3395
  let g;
3401
- for (; (g = f.read()) != null; )
3396
+ for (; (g = f.read()) != null; ) {
3397
+ if (h) return;
3402
3398
  i.signal.throwIfAborted(), l.push(g);
3399
+ }
3403
3400
  } catch (g) {
3404
3401
  c(g);
3405
3402
  }
3406
3403
  }), f.on("error", (g) => c(g)), f.on("end", () => {
3407
- h || (l?.flush(), console.log(3333, this.constructSummary(f)), o(this.constructSummary(f)));
3404
+ h || (l?.flush(), o(this.constructSummary(f)));
3408
3405
  });
3409
3406
  const p = await fetch(encodeURI(n), { signal: i.signal });
3410
3407
  if (!p.ok || p.body == null)
3411
3408
  throw await Yn(p, `Failed to fetch '${n}' file.`, "datapos-connector-file-store-emulator|Connector|retrieve");
3412
3409
  u = p.body.pipeThrough(new TextDecoderStream(r.encodingId)).getReader();
3413
3410
  let I = await u.read();
3414
- for (; !I.done; )
3411
+ for (; !I.done; ) {
3412
+ if (h) return;
3415
3413
  i.signal.throwIfAborted(), await this.writeToParser(f, I.value), I = await u.read();
3414
+ }
3416
3415
  f.end();
3417
3416
  })().catch((p) => c(p));
3418
3417
  });
@@ -3449,6 +3448,13 @@ class Gn {
3449
3448
  });
3450
3449
  });
3451
3450
  }
3451
+ /** Ignore best-effort cleanup errors to keep teardown noise-free. */
3452
+ ignoreErrors(e) {
3453
+ try {
3454
+ e();
3455
+ } catch {
3456
+ }
3457
+ }
3452
3458
  }
3453
3459
  export {
3454
3460
  Gn as Tool
@@ -14,6 +14,8 @@ declare class Tool {
14
14
  private constructSummary;
15
15
  /** Write to parser. */
16
16
  private writeToParser;
17
+ /** Ignore best-effort cleanup errors to keep teardown noise-free. */
18
+ private ignoreErrors;
17
19
  }
18
20
  /** Exports */
19
21
  export type { Options as ParseOptions, Parser } from 'csv-parse/browser/esm';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datapos/datapos-tool-csv-parse",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "private": false,