Skip to content

Commit

Permalink
stream: use synchronous error validation on iteration helpers
Browse files Browse the repository at this point in the history
 is no longer a generator function,
instead it returns a called generator so that validation can be
synchronous and not wait for the first iteration

Fixes: nodejs#41648
  • Loading branch information
iMoses committed Jan 26, 2022
1 parent 09b324a commit 9d34df8
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/internal/streams/operators.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ function map(fn, options) {

validateInteger(concurrency, 'concurrency', 1);

const stream = this;

return async function* map() {
const ac = new AbortController();
const stream = this;
const queue = [];
const signal = ac.signal;
const signalOpt = { signal };
Expand Down Expand Up @@ -157,7 +156,7 @@ function map(fn, options) {
resume = null;
}
}
}();
}.call(this);
}

async function some(fn, options) {
Expand Down Expand Up @@ -238,7 +237,7 @@ function flatMap(fn, options) {
for await (const val of values) {
yield* val;
}
}();
}.call(this);
}

function toIntegerOrInfinity(number) {
Expand Down

0 comments on commit 9d34df8

Please sign in to comment.