File tree Expand file tree Collapse file tree 4 files changed +13
-9
lines changed
Expand file tree Collapse file tree 4 files changed +13
-9
lines changed 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 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" ,
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" : {
Original file line number Diff line number Diff line change 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" ,
You can’t perform that action at this time.
0 commit comments