You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Optimization: if our concurrency and/or backpressure is bounded (so that we won't infinitely recurse),
243
-
// and we need to `await` the next `iterator` element, we first eagerly spawn more `mapNext` promises,
244
-
// so that these promises can begin `await`ing their respective `iterator` elements (if needed) and `mapper` results in parallel.
245
-
// This may entail memory usage closer to `options.backpressure` than necessary, but this space was already allocated to `pMapIterable` via
246
-
// `options.concurrency` and `options.backpressure`.
247
-
// This may also cause iteration well past the end of the `iterator`: we don't inspect the `iterator`'s response before `trySpawn`ing
248
-
// (because we are `trySpawn`ing before `await`ing the response), which will request the next `iterator` element, so we may end up spawning many promises which resolve to `done`.
249
-
// However, the time needed to `await` and ignore these `done` promises is presumed to be small relative to the time needed to perform common
250
-
// `async` operations like disk reads, network requests, etc.
251
-
// Overall, this can reduce the total time taken to process all elements.
252
-
if(backpressure!==Number.POSITIVE_INFINITY){
253
-
// Spawn if still below concurrency and backpressure limit
254
-
trySpawn();
255
-
}
239
+
letnext;
240
+
try{
241
+
next=iterator.next();
242
+
if(isPromiseLike(next)){
243
+
// Optimization: if our concurrency and/or backpressure is bounded (so that we won't infinitely recurse),
244
+
// and we need to `await` the next `iterator` element, we first eagerly spawn more `mapNext` promises,
245
+
// so that these promises can begin `await`ing their respective `iterator` elements (if needed) and `mapper` results in parallel.
246
+
// This may entail memory usage closer to `options.backpressure` than necessary, but this space was already allocated to `pMapIterable` via
247
+
// `options.concurrency` and `options.backpressure`.
248
+
// This may also cause iteration well past the end of the `iterator`: we don't inspect the `iterator`'s response before `trySpawn`ing
249
+
// (because we are `trySpawn`ing before `await`ing the response), which will request the next `iterator` element, so we may end up spawning many promises which resolve to `done`.
250
+
// However, the time needed to `await` and ignore these `done` promises is presumed to be small relative to the time needed to perform common
251
+
// `async` operations like disk reads, network requests, etc.
252
+
// Overall, this can reduce the total time taken to process all elements.
253
+
if(backpressure!==Number.POSITIVE_INFINITY){
254
+
// Spawn if still below concurrency and backpressure limit
0 commit comments