File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff line change 137137 "npm-profile": "^11.0.1",
138138 "npm-registry-fetch": "^18.0.2",
139139 "npm-user-validate": "^3.0.0",
140- "p-map": "^7.0.3 ",
140+ "p-map": "^7.0.4 ",
141141 "pacote": "^19.0.1",
142142 "parse-conflict-json": "^4.0.0",
143143 "proc-log": "^5.0.0",
1147911479 }
1148011480 },
1148111481 "node_modules/p-map": {
11482- "version": "7.0.3 ",
11483- "resolved": "https://registry.npmjs.org/p-map/-/p-map-7.0.3 .tgz",
11484- "integrity": "sha512-VkndIv2fIB99swvQoA65bm+fsmt6UNdGeIB0oxBs+WhAhdh08QA04JXpI7rbB9r08/nkbysKoya9rtDERYOYMA ==",
11482+ "version": "7.0.4 ",
11483+ "resolved": "https://registry.npmjs.org/p-map/-/p-map-7.0.4 .tgz",
11484+ "integrity": "sha512-tkAQEw8ysMzmkhgw8k+1U/iPhWNhykKnSk4Rd5zLoPJCuJaGRPo6YposrZgaxHKzDHdDWWZvE/Sk7hsL2X/CpQ ==",
1148511485 "inBundle": true,
1148611486 "license": "MIT",
1148711487 "engines": {
Original file line number Diff line number Diff line change 102102 "npm-profile" : " ^11.0.1" ,
103103 "npm-registry-fetch" : " ^18.0.2" ,
104104 "npm-user-validate" : " ^3.0.0" ,
105- "p-map" : " ^7.0.3 " ,
105+ "p-map" : " ^7.0.4 " ,
106106 "pacote" : " ^19.0.1" ,
107107 "parse-conflict-json" : " ^4.0.0" ,
108108 "proc-log" : " ^5.0.0" ,
You can’t perform that action at this time.
0 commit comments