| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0bdf2db commit 441d9de
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -64,6 +64,7 @@ const { | |||
| 64 | 64 | ||
| 65 | 65 | const { | |
| 66 | 66 | validateBoolean, | |
| 67 | + validateFunction, | ||
| 67 | 68 | validateObject, | |
| 68 | 69 | } = require('internal/validators'); | |
| 69 | 70 | ||
@@ -924,8 +925,7 @@ function newReadableStreamFromStreamBase(streamBase, strategy, options = kEmptyO | |||
| 924 | 925 | if (typeof streamBase.onread === 'function') | |
| 925 | 926 | throw new ERR_INVALID_STATE('StreamBase already has a consumer'); | |
| 926 | 927 | ||
| 927 | - if (typeof ondone !== 'function') | ||
| 928 | - throw new ERR_INVALID_ARG_TYPE('options.ondone', 'Function', ondone); | ||
| 928 | + validateFunction(ondone, 'options.ondone'); | ||
| 929 | 929 | ||
| 930 | 930 | let controller; | |
| 931 | 931 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,6 @@ const { | |||
| 19 | 19 | ||
| 20 | 20 | const { | |
| 21 | 21 | codes: { | |
| 22 | - ERR_INVALID_ARG_TYPE, | ||
| 23 | 22 | ERR_INVALID_ARG_VALUE, | |
| 24 | 23 | ERR_OPERATION_FAILED, | |
| 25 | 24 | }, | |
@@ -48,6 +47,10 @@ const { | |||
| 48 | 47 | const assert = require('internal/assert'); | |
| 49 | 48 | const { isArrayBufferDetached } = require('internal/util'); | |
| 50 | 49 | ||
| 50 | + const { | ||
| 51 | + validateFunction, | ||
| 52 | + } = require('internal/validators'); | ||
| 53 | + | ||
| 51 | 54 | const kState = Symbol('kState'); | |
| 52 | 55 | const kType = Symbol('kType'); | |
| 53 | 56 | ||
@@ -78,8 +81,7 @@ function extractHighWaterMark(value, defaultHWM) { | |||
| 78 | 81 | ||
| 79 | 82 | function extractSizeAlgorithm(size) { | |
| 80 | 83 | 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'); | ||
| 83 | 85 | return size; | |
| 84 | 86 | } | |
| 85 | 87 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments