@vltpkg/tar 0.0.0-8 → 0.0.0-9

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 +1 @@
1
- {"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../src/pool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAgB,MAAM,EAAE,MAAM,aAAa,CAAA;AAGlD,cAAc,aAAa,CAAA;AAE3B;;;;;;;GAOG;AACH,qBAAa,IAAI;;IACf;;;OAGG;IAEH,IAAI,EAAE,MAAM,CAAmD;IAC/D;;OAEG;IACH,OAAO,cAAoB;IAC3B;;OAEG;IACH,KAAK,EAAE,aAAa,EAAE,CAAK;IAC3B;;;OAGG;IACH,OAAO,6BAAmC;IAyC1C;;;;;;OAMG;IACG,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAU7C"}
1
+ {"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../src/pool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAgB,MAAM,EAAE,MAAM,aAAa,CAAA;AAGlD,cAAc,aAAa,CAAA;AAE3B;;;;;;;GAOG;AACH,qBAAa,IAAI;;IACf;;;OAGG;IAEH,IAAI,EAAE,MAAM,CAAmD;IAC/D;;OAEG;IACH,OAAO,cAAoB;IAC3B;;OAEG;IACH,KAAK,EAAE,aAAa,EAAE,CAAK;IAC3B;;;OAGG;IACH,OAAO,6BAAmC;IA0C1C;;;;;;OAMG;IACG,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAU7C"}
package/dist/esm/pool.js CHANGED
@@ -1,4 +1,4 @@
1
- import { error } from '@vltpkg/error-cause';
1
+ import { asError, error } from '@vltpkg/error-cause';
2
2
  import os from 'node:os';
3
3
  import { UnpackRequest } from "./unpack-request.js";
4
4
  import { isResponseOK, Worker } from "./worker.js";
@@ -45,8 +45,7 @@ export class Pool {
45
45
  /* c8 ignore start - nearly impossible in normal circumstances */
46
46
  }
47
47
  else {
48
- const message = m.error instanceof Error ? m.error.message : String(m.error);
49
- ur.reject(error(message || 'failed without error message', {
48
+ ur.reject(error(asError(m.error, 'failed without error message').message, {
50
49
  found: m,
51
50
  cause: m.error,
52
51
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"pool.js","sourceRoot":"","sources":["../../src/pool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGlD,cAAc,aAAa,CAAA;AAE3B;;;;;;;GAOG;AACH,MAAM,OAAO,IAAI;IACf;;;OAGG;IACH,oBAAoB;IACpB,IAAI,GAAW,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IAC/D;;OAEG;IACH,OAAO,GAAG,IAAI,GAAG,EAAU,CAAA;IAC3B;;OAEG;IACH,KAAK,GAAoB,EAAE,CAAA;IAC3B;;;OAGG;IACH,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAA;IAE1C,mCAAmC;IACnC,UAAU,CAAC,CAAS,EAAE,CAA6B;QACjD,MAAM,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;QAChB,sDAAsD;QACtD,0DAA0D;QAC1D,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QAC/B,oBAAoB;QACpB,IAAI,CAAC,EAAE;YAAE,OAAM;QACf,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC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C,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YAClC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAA;QACxB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACrB,CAAC;QACD,OAAO,EAAE,CAAC,OAAO,CAAA;IACnB,CAAC;CACF","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport os from 'node:os'\nimport { UnpackRequest } from './unpack-request.ts'\nimport { isResponseOK, Worker } from './worker.ts'\nimport type { ResponseError, ResponseOK } from './worker.ts'\n\nexport * from './worker.ts'\n\n/**\n * Automatically expanding/contracting set of workers to maximize parallelism\n * of unpack operations up to 1 less than the number of CPUs (or 1).\n *\n * `pool.unpack(tarData, target)` will perform the unpack operation\n * synchronously, in one of these workers, and returns a promise when the\n * worker has confirmed completion of the task.\n */\nexport class Pool {\n /**\n * Number of workers to emplly. Defaults to 1 less than the number of\n * CPUs, or 1.\n */\n /* c8 ignore next */\n jobs: number = 8 * (Math.max(os.availableParallelism(), 2) - 1)\n /**\n * Set of currently active worker threads\n */\n workers = new Set<Worker>()\n /**\n * Queue of requests awaiting an available worker\n */\n queue: UnpackRequest[] = []\n /**\n * Requests that have been assigned to a worker, but have not yet\n * been confirmed completed.\n */\n pending = new Map<number, UnpackRequest>()\n\n // handle a message from the worker\n #onMessage(w: Worker, m: ResponseError | ResponseOK) {\n const { id } = m\n // a request has been met or failed, report and either\n // pick up the next item in the queue, or terminate worker\n const ur = this.pending.get(id)\n /* c8 ignore next */\n if (!ur) return\n if (isResponseOK(m)) {\n ur.resolve()\n /* c8 ignore start - nearly impossible in normal circumstances */\n } else {\n const message =\n m.error instanceof Error ? m.error.message : String(m.error)\n ur.reject(\n error(message || 'failed without error message', {\n found: m,\n cause: m.error,\n }),\n )\n }\n /* c8 ignore stop */\n const next = this.queue.shift()\n if (!next) {\n this.workers.delete(w)\n } else {\n void w.process(next)\n }\n }\n\n // create a new worker\n #createWorker(req: UnpackRequest) {\n const w: Worker = new Worker((m: ResponseError | ResponseOK) =>\n this.#onMessage(w, m),\n )\n this.workers.add(w)\n void w.process(req)\n }\n\n /**\n * Provide the tardata to be unpacked, and the location where it's to be\n * placed. Will create a new worker up to the `jobs` value, and then start\n * pushing in the queue for workers to pick up as they become available.\n *\n * Returned promise resolves when the provided tarball has been extracted.\n */\n async unpack(tarData: Buffer, target: string) {\n const ur = new UnpackRequest(tarData, target)\n this.pending.set(ur.id, ur)\n if (this.workers.size < this.jobs) {\n this.#createWorker(ur)\n } else {\n this.queue.push(ur)\n }\n return ur.promise\n }\n}\n"]}
1
+ {"version":3,"file":"pool.js","sourceRoot":"","sources":["../../src/pool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGlD,cAAc,aAAa,CAAA;AAE3B;;;;;;;GAOG;AACH,MAAM,OAAO,IAAI;IACf;;;OAGG;IACH,oBAAoB;IACpB,IAAI,GAAW,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IAC/D;;OAEG;IACH,OAAO,GAAG,IAAI,GAAG,EAAU,CAAA;IAC3B;;OAEG;IACH,KAAK,GAAoB,EAAE,CAAA;IAC3B;;;OAGG;IACH,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAA;IAE1C,mCAAmC;IACnC,UAAU,CAAC,CAAS,EAAE,CAA6B;QACjD,MAAM,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;QAChB,sDAAsD;QACtD,0DAA0D;QAC1D,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,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AAC,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YAClC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAA;QACxB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACrB,CAAC;QACD,OAAO,EAAE,CAAC,OAAO,CAAA;IACnB,CAAC;CACF","sourcesContent":["import { asError, error } from '@vltpkg/error-cause'\nimport os from 'node:os'\nimport { UnpackRequest } from './unpack-request.ts'\nimport { isResponseOK, Worker } from './worker.ts'\nimport type { ResponseError, ResponseOK } from './worker.ts'\n\nexport * from './worker.ts'\n\n/**\n * Automatically expanding/contracting set of workers to maximize parallelism\n * of unpack operations up to 1 less than the number of CPUs (or 1).\n *\n * `pool.unpack(tarData, target)` will perform the unpack operation\n * synchronously, in one of these workers, and returns a promise when the\n * worker has confirmed completion of the task.\n */\nexport class Pool {\n /**\n * Number of workers to emplly. Defaults to 1 less than the number of\n * CPUs, or 1.\n */\n /* c8 ignore next */\n jobs: number = 8 * (Math.max(os.availableParallelism(), 2) - 1)\n /**\n * Set of currently active worker threads\n */\n workers = new Set<Worker>()\n /**\n * Queue of requests awaiting an available worker\n */\n queue: UnpackRequest[] = []\n /**\n * Requests that have been assigned to a worker, but have not yet\n * been confirmed completed.\n */\n pending = new Map<number, UnpackRequest>()\n\n // handle a message from the worker\n #onMessage(w: Worker, m: ResponseError | ResponseOK) {\n const { id } = m\n // a request has been met or failed, report and either\n // pick up the next item in the queue, or terminate worker\n const ur = this.pending.get(id)\n /* c8 ignore next */\n if (!ur) return\n if (isResponseOK(m)) {\n ur.resolve()\n /* c8 ignore start - nearly impossible in normal circumstances */\n } else {\n ur.reject(\n error(\n asError(m.error, 'failed without error message').message,\n {\n found: m,\n cause: m.error,\n },\n ),\n )\n }\n /* c8 ignore stop */\n const next = this.queue.shift()\n if (!next) {\n this.workers.delete(w)\n } else {\n void w.process(next)\n }\n }\n\n // create a new worker\n #createWorker(req: UnpackRequest) {\n const w: Worker = new Worker((m: ResponseError | ResponseOK) =>\n this.#onMessage(w, m),\n )\n this.workers.add(w)\n void w.process(req)\n }\n\n /**\n * Provide the tardata to be unpacked, and the location where it's to be\n * placed. Will create a new worker up to the `jobs` value, and then start\n * pushing in the queue for workers to pick up as they become available.\n *\n * Returned promise resolves when the provided tarball has been extracted.\n */\n async unpack(tarData: Buffer, target: string) {\n const ur = new UnpackRequest(tarData, target)\n this.pending.set(ur.id, ur)\n if (this.workers.size < this.jobs) {\n this.#createWorker(ur)\n } else {\n this.queue.push(ur)\n }\n return ur.promise\n }\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vltpkg/tar",
3
3
  "description": "An extremely limited and very fast tar extractor",
4
- "version": "0.0.0-8",
4
+ "version": "0.0.0-9",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
@@ -24,7 +24,7 @@
24
24
  "dependencies": {
25
25
  "rimraf": "^6.0.1",
26
26
  "tar": "^7.4.3",
27
- "@vltpkg/error-cause": "0.0.0-8"
27
+ "@vltpkg/error-cause": "0.0.0-9"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@eslint/js": "^9.20.0",