From aabf345a524f8aba7e0f45c0d4b8c86d5160d0cc Mon Sep 17 00:00:00 2001 From: Gar Date: Wed, 11 Dec 2024 15:05:05 -0800 Subject: [PATCH] deps: p-map@7.0.3 --- node_modules/p-map/index.js | 20 ++++++++++++++++---- node_modules/p-map/package.json | 2 +- package-lock.json | 8 ++++---- package.json | 2 +- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/node_modules/p-map/index.js b/node_modules/p-map/index.js index 2f7d91ccca4ed..10558008a7728 100644 --- a/node_modules/p-map/index.js +++ b/node_modules/p-map/index.js @@ -7,7 +7,7 @@ export default async function pMap( signal, } = {}, ) { - return new Promise((resolve, reject_) => { + return new Promise((resolve_, reject_) => { if (iterable[Symbol.iterator] === undefined && iterable[Symbol.asyncIterator] === undefined) { throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`); } @@ -30,10 +30,24 @@ export default async function pMap( let currentIndex = 0; const iterator = iterable[Symbol.iterator] === undefined ? iterable[Symbol.asyncIterator]() : iterable[Symbol.iterator](); + const signalListener = () => { + reject(signal.reason); + }; + + const cleanup = () => { + signal?.removeEventListener('abort', signalListener); + }; + + const resolve = value => { + resolve_(value); + cleanup(); + }; + const reject = reason => { isRejected = true; isResolved = true; reject_(reason); + cleanup(); }; if (signal) { @@ -41,9 +55,7 @@ export default async function pMap( reject(signal.reason); } - signal.addEventListener('abort', () => { - reject(signal.reason); - }); + signal.addEventListener('abort', signalListener, {once: true}); } const next = async () => { diff --git a/node_modules/p-map/package.json b/node_modules/p-map/package.json index ea58f599f3a03..b7b6594c855d8 100644 --- a/node_modules/p-map/package.json +++ b/node_modules/p-map/package.json @@ -1,6 +1,6 @@ { "name": "p-map", - "version": "7.0.2", + "version": "7.0.3", "description": "Map over promises concurrently", "license": "MIT", "repository": "sindresorhus/p-map", diff --git a/package-lock.json b/package-lock.json index c05f06661ca5a..245257bd7b7b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -134,7 +134,7 @@ "npm-profile": "^11.0.1", "npm-registry-fetch": "^18.0.2", "npm-user-validate": "^3.0.0", - "p-map": "^7.0.2", + "p-map": "^7.0.3", "pacote": "^21.0.0", "parse-conflict-json": "^4.0.0", "proc-log": "^5.0.0", @@ -12769,9 +12769,9 @@ } }, "node_modules/p-map": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/p-map/-/p-map-7.0.2.tgz", - "integrity": "sha512-z4cYYMMdKHzw4O5UkWJImbZynVIo0lSGTXc7bzB1e/rrDqkgGUNysK/o4bTr+0+xKvvLoTyGqYC4Fgljy9qe1Q==", + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-7.0.3.tgz", + "integrity": "sha512-VkndIv2fIB99swvQoA65bm+fsmt6UNdGeIB0oxBs+WhAhdh08QA04JXpI7rbB9r08/nkbysKoya9rtDERYOYMA==", "inBundle": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index 7b8303c52ccde..bc651e0b9090b 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,7 @@ "npm-profile": "^11.0.1", "npm-registry-fetch": "^18.0.2", "npm-user-validate": "^3.0.0", - "p-map": "^7.0.2", + "p-map": "^7.0.3", "pacote": "^21.0.0", "parse-conflict-json": "^4.0.0", "proc-log": "^5.0.0",