Skip to content

Commit 4ac5c7b

Browse files
committed
1 parent 79d4bf8 commit 4ac5c7b

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

node_modules/p-map/index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,31 +203,32 @@ export function pMapIterable(
203203
const iterator = iterable[Symbol.asyncIterator] === undefined ? iterable[Symbol.iterator]() : iterable[Symbol.asyncIterator]();
204204

205205
const promises = [];
206-
let runningMappersCount = 0;
206+
let pendingPromisesCount = 0;
207207
let isDone = false;
208208
let index = 0;
209209

210210
function trySpawn() {
211-
if (isDone || !(runningMappersCount < concurrency && promises.length < backpressure)) {
211+
if (isDone || !(pendingPromisesCount < concurrency && promises.length < backpressure)) {
212212
return;
213213
}
214214

215+
pendingPromisesCount++;
216+
215217
const promise = (async () => {
216218
const {done, value} = await iterator.next();
217219

218220
if (done) {
221+
pendingPromisesCount--;
219222
return {done: true};
220223
}
221224

222-
runningMappersCount++;
223-
224225
// Spawn if still below concurrency and backpressure limit
225226
trySpawn();
226227

227228
try {
228229
const returnValue = await mapper(await value, index++);
229230

230-
runningMappersCount--;
231+
pendingPromisesCount--;
231232

232233
if (returnValue === pMapSkip) {
233234
const index = promises.indexOf(promise);
@@ -242,6 +243,7 @@ export function pMapIterable(
242243

243244
return {done: false, value: returnValue};
244245
} catch (error) {
246+
pendingPromisesCount--;
245247
isDone = true;
246248
return {error};
247249
}

node_modules/p-map/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "p-map",
3-
"version": "7.0.3",
3+
"version": "7.0.4",
44
"description": "Map over promises concurrently",
55
"license": "MIT",
66
"repository": "sindresorhus/p-map",

package-lock.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
"npm-profile": "^12.0.1",
135135
"npm-registry-fetch": "^19.1.1",
136136
"npm-user-validate": "^4.0.0",
137-
"p-map": "^7.0.3",
137+
"p-map": "^7.0.4",
138138
"pacote": "^21.0.4",
139139
"parse-conflict-json": "^5.0.1",
140140
"proc-log": "^6.0.0",
@@ -9105,7 +9105,9 @@
91059105
}
91069106
},
91079107
"node_modules/p-map": {
9108-
"version": "7.0.3",
9108+
"version": "7.0.4",
9109+
"resolved": "https://registry.npmjs.org/p-map/-/p-map-7.0.4.tgz",
9110+
"integrity": "sha512-tkAQEw8ysMzmkhgw8k+1U/iPhWNhykKnSk4Rd5zLoPJCuJaGRPo6YposrZgaxHKzDHdDWWZvE/Sk7hsL2X/CpQ==",
91099111
"inBundle": true,
91109112
"license": "MIT",
91119113
"engines": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
"npm-profile": "^12.0.1",
102102
"npm-registry-fetch": "^19.1.1",
103103
"npm-user-validate": "^4.0.0",
104-
"p-map": "^7.0.3",
104+
"p-map": "^7.0.4",
105105
"pacote": "^21.0.4",
106106
"parse-conflict-json": "^5.0.1",
107107
"proc-log": "^6.0.0",

0 commit comments

Comments
 (0)