Skip to content
Prev Previous commit
Next Next commit
fixup
  • Loading branch information
ronag committed Dec 27, 2021
commit 7678628bb083ea193ec25a5e043458c4d7ce81bc
12 changes: 7 additions & 5 deletions lib/internal/streams/operators.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ const {
ERR_INVALID_ARG_VALUE,
}, AbortError,
Comment thread
ronag marked this conversation as resolved.
Outdated
} = require('internal/errors');
const {
validateInteger,
validateObject,
} = require('internal/validators');

const {
MathFloor,
NumberIsInteger,
Promise,
PromiseReject,
Symbol,
Expand All @@ -30,15 +33,14 @@ async function * map(fn, options) {
throw new ERR_INVALID_ARG_TYPE('options', ['Object']);
}

validateObject(options, 'options', { nullable: true });

let concurrency = 1;
if (options?.concurrency != null) {
concurrency = MathFloor(options.concurrency);
}

if (!NumberIsInteger(concurrency)) {
throw new ERR_INVALID_ARG_TYPE(
'concurrency', ['Integer'], concurrency);
}
validateInteger(concurrency, 'concurrency', 1);

if (concurrency < 1) {
throw new ERR_INVALID_ARG_VALUE('concurrency', concurrency);
Expand Down