mirror of https://github.com/nodejs/node.git
stream: refactor to use `validateFunction`
PR-URL: https://github.com/nodejs/node/pull/46007 Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
This commit is contained in:
parent
e2dd139da0
commit
979ec87665
|
@ -64,6 +64,7 @@ const {
|
|||
|
||||
const {
|
||||
validateBoolean,
|
||||
validateFunction,
|
||||
validateObject,
|
||||
} = require('internal/validators');
|
||||
|
||||
|
@ -924,8 +925,7 @@ function newReadableStreamFromStreamBase(streamBase, strategy, options = kEmptyO
|
|||
if (typeof streamBase.onread === 'function')
|
||||
throw new ERR_INVALID_STATE('StreamBase already has a consumer');
|
||||
|
||||
if (typeof ondone !== 'function')
|
||||
throw new ERR_INVALID_ARG_TYPE('options.ondone', 'Function', ondone);
|
||||
validateFunction(ondone, 'options.ondone');
|
||||
|
||||
let controller;
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ const {
|
|||
|
||||
const {
|
||||
codes: {
|
||||
ERR_INVALID_ARG_TYPE,
|
||||
ERR_INVALID_ARG_VALUE,
|
||||
ERR_OPERATION_FAILED,
|
||||
},
|
||||
|
@ -48,6 +47,10 @@ const {
|
|||
const assert = require('internal/assert');
|
||||
const { isArrayBufferDetached } = require('internal/util');
|
||||
|
||||
const {
|
||||
validateFunction,
|
||||
} = require('internal/validators');
|
||||
|
||||
const kState = Symbol('kState');
|
||||
const kType = Symbol('kType');
|
||||
|
||||
|
@ -78,8 +81,7 @@ function extractHighWaterMark(value, defaultHWM) {
|
|||
|
||||
function extractSizeAlgorithm(size) {
|
||||
if (size === undefined) return () => 1;
|
||||
if (typeof size !== 'function')
|
||||
throw new ERR_INVALID_ARG_TYPE('strategy.size', 'Function', size);
|
||||
validateFunction(size, 'strategy.size');
|
||||
return size;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue