Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 441d9de

Browse filesBrowse files
deokjinkimjuanarbol
authored andcommitted
stream: refactor to use validateFunction
PR-URL: #46007 Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 0bdf2db commit 441d9de
Copy full SHA for 441d9de

File tree

Expand file treeCollapse file tree

2 files changed

+7
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-5
lines changed
Open diff view settings
Collapse file

‎lib/internal/webstreams/adapters.js‎

Copy file name to clipboardExpand all lines: lib/internal/webstreams/adapters.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const {
6464

6565
const {
6666
validateBoolean,
67+
validateFunction,
6768
validateObject,
6869
} = require('internal/validators');
6970

@@ -924,8 +925,7 @@ function newReadableStreamFromStreamBase(streamBase, strategy, options = kEmptyO
924925
if (typeof streamBase.onread === 'function')
925926
throw new ERR_INVALID_STATE('StreamBase already has a consumer');
926927

927-
if (typeof ondone !== 'function')
928-
throw new ERR_INVALID_ARG_TYPE('options.ondone', 'Function', ondone);
928+
validateFunction(ondone, 'options.ondone');
929929

930930
let controller;
931931

Collapse file

‎lib/internal/webstreams/util.js‎

Copy file name to clipboardExpand all lines: lib/internal/webstreams/util.js
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const {
1919

2020
const {
2121
codes: {
22-
ERR_INVALID_ARG_TYPE,
2322
ERR_INVALID_ARG_VALUE,
2423
ERR_OPERATION_FAILED,
2524
},
@@ -48,6 +47,10 @@ const {
4847
const assert = require('internal/assert');
4948
const { isArrayBufferDetached } = require('internal/util');
5049

50+
const {
51+
validateFunction,
52+
} = require('internal/validators');
53+
5154
const kState = Symbol('kState');
5255
const kType = Symbol('kType');
5356

@@ -78,8 +81,7 @@ function extractHighWaterMark(value, defaultHWM) {
7881

7982
function extractSizeAlgorithm(size) {
8083
if (size === undefined) return () => 1;
81-
if (typeof size !== 'function')
82-
throw new ERR_INVALID_ARG_TYPE('strategy.size', 'Function', size);
84+
validateFunction(size, 'strategy.size');
8385
return size;
8486
}
8587

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.