| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8f5f48a commit b5182f0
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,6 +33,7 @@ const { | |||
| 33 | 33 | } = require('internal/errors'); | |
| 34 | 34 | const { | |
| 35 | 35 | validateAbortSignal, | |
| 36 | + validateArray, | ||
| 36 | 37 | validateInteger, | |
| 37 | 38 | validateObject, | |
| 38 | 39 | } = require('internal/validators'); | |
@@ -559,9 +560,7 @@ class BroadcastWriter { | |||
| 559 | 560 | } | |
| 560 | 561 | ||
| 561 | 562 | writev(chunks, options) { | |
| 562 | - if (!ArrayIsArray(chunks)) { | ||
| 563 | - throw new ERR_INVALID_ARG_TYPE('chunks', 'Array', chunks); | ||
| 564 | - } | ||
| 563 | + validateArray(chunks, 'chunks'); | ||
| 565 | 564 | const signal = getWriterSignal(options); | |
| 566 | 565 | // Fast path: no signal, writer open, buffer has space | |
| 567 | 566 | if (this.#canUseWriteFastPath(signal)) { | |
@@ -620,9 +619,7 @@ class BroadcastWriter { | |||
| 620 | 619 | } | |
| 621 | 620 | ||
| 622 | 621 | writevSync(chunks) { | |
| 623 | - if (!ArrayIsArray(chunks)) { | ||
| 624 | - throw new ERR_INVALID_ARG_TYPE('chunks', 'Array', chunks); | ||
| 625 | - } | ||
| 622 | + validateArray(chunks, 'chunks'); | ||
| 626 | 623 | if (this.#isClosedOrAborted()) return false; | |
| 627 | 624 | if (!this.#broadcast[kCanWrite]()) return false; | |
| 628 | 625 | const converted = convertChunks(chunks); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,7 +12,6 @@ | |||
| 12 | 12 | // toWritable(writer) -- stream/iter Writer -> classic Writable | |
| 13 | 13 | ||
| 14 | 14 | const { | |
| 15 | - ArrayIsArray, | ||
| 16 | 15 | ArrayPrototypePush, | |
| 17 | 16 | NumberMAX_SAFE_INTEGER, | |
| 18 | 17 | Promise, | |
@@ -41,6 +40,7 @@ const { | |||
| 41 | 40 | } = require('internal/errors'); | |
| 42 | 41 | ||
| 43 | 42 | const { | |
| 43 | + validateArray, | ||
| 44 | 44 | validateInteger, | |
| 45 | 45 | validateObject, | |
| 46 | 46 | } = require('internal/validators'); | |
@@ -619,9 +619,7 @@ function fromWritable(writable, options = kNullPrototype) { | |||
| 619 | 619 | }, | |
| 620 | 620 | ||
| 621 | 621 | writev(chunks, options) { | |
| 622 | - if (!ArrayIsArray(chunks)) { | ||
| 623 | - throw new ERR_INVALID_ARG_TYPE('chunks', 'Array', chunks); | ||
| 624 | - } | ||
| 622 | + validateArray(chunks, 'chunks'); | ||
| 625 | 623 | getWriterSignal(options); | |
| 626 | 624 | if (!isWritable()) { | |
| 627 | 625 | return PromiseReject(new ERR_STREAM_WRITE_AFTER_END()); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,6 @@ | |||
| 6 | 6 | // with built-in backpressure. | |
| 7 | 7 | ||
| 8 | 8 | const { | |
| 9 | - ArrayIsArray, | ||
| 10 | 9 | ArrayPrototypePush, | |
| 11 | 10 | PromisePrototypeThen, | |
| 12 | 11 | PromiseReject, | |
@@ -21,13 +20,13 @@ const { | |||
| 21 | 20 | ||
| 22 | 21 | const { | |
| 23 | 22 | codes: { | |
| 24 | - ERR_INVALID_ARG_TYPE, | ||
| 25 | 23 | ERR_INVALID_STATE, | |
| 26 | 24 | }, | |
| 27 | 25 | } = require('internal/errors'); | |
| 28 | 26 | const { lazyDOMException } = require('internal/util'); | |
| 29 | 27 | const { | |
| 30 | 28 | validateAbortSignal, | |
| 29 | + validateArray, | ||
| 31 | 30 | validateInteger, | |
| 32 | 31 | } = require('internal/validators'); | |
| 33 | 32 | ||
@@ -629,9 +628,7 @@ class PushWriter { | |||
| 629 | 628 | } | |
| 630 | 629 | ||
| 631 | 630 | writev(chunks, options) { | |
| 632 | - if (!ArrayIsArray(chunks)) { | ||
| 633 | - throw new ERR_INVALID_ARG_TYPE('chunks', 'Array', chunks); | ||
| 634 | - } | ||
| 631 | + validateArray(chunks, 'chunks'); | ||
| 635 | 632 | const signal = getWriterSignal(options); | |
| 636 | 633 | if (!signal && this.#queue.canWriteSync()) { | |
| 637 | 634 | const bytes = convertChunks(chunks); | |
@@ -648,9 +645,7 @@ class PushWriter { | |||
| 648 | 645 | } | |
| 649 | 646 | ||
| 650 | 647 | writevSync(chunks) { | |
| 651 | - if (!ArrayIsArray(chunks)) { | ||
| 652 | - throw new ERR_INVALID_ARG_TYPE('chunks', 'Array', chunks); | ||
| 653 | - } | ||
| 648 | + validateArray(chunks, 'chunks'); | ||
| 654 | 649 | const bytes = convertChunks(chunks); | |
| 655 | 650 | return this.#queue.writeSync(bytes); | |
| 656 | 651 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,6 +26,7 @@ const { | |||
| 26 | 26 | } = require('internal/util/types'); | |
| 27 | 27 | ||
| 28 | 28 | const { | |
| 29 | + validateArray, | ||
| 29 | 30 | validateBuffer, | |
| 30 | 31 | validateInt32, | |
| 31 | 32 | validateObject, | |
@@ -212,10 +213,7 @@ function configSecureContext(context, options = kEmptyObject, name = 'options') | |||
| 212 | 213 | } | |
| 213 | 214 | ||
| 214 | 215 | if (certificateCompression != null) { | |
| 215 | - if (!ArrayIsArray(certificateCompression)) { | ||
| 216 | - throw new ERR_INVALID_ARG_TYPE( | ||
| 217 | - `${name}.certificateCompression`, 'Array', certificateCompression); | ||
| 218 | - } | ||
| 216 | + validateArray(certificateCompression, `${name}.certificateCompression`); | ||
| 219 | 217 | ||
| 220 | 218 | if (certificateCompression.length > 0) { | |
| 221 | 219 | // Pack length + algorithm IDs into a single Uint32 for a cheap | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -70,7 +70,7 @@ const { canonicalizeIP } = internalBinding('cares_wrap'); | |||
| 70 | 70 | const tlsCommon = require('internal/tls/common'); | |
| 71 | 71 | const tlsWrap = require('internal/tls/wrap'); | |
| 72 | 72 | const { domainToASCII } = require('internal/url'); | |
| 73 | - const { validateString } = require('internal/validators'); | ||
| 73 | + const { validateArray, validateString } = require('internal/validators'); | ||
| 74 | 74 | ||
| 75 | 75 | const { | |
| 76 | 76 | namespace: { | |
@@ -206,9 +206,7 @@ function getCACertificates(type = 'default') { | |||
| 206 | 206 | exports.getCACertificates = getCACertificates; | |
| 207 | 207 | ||
| 208 | 208 | function setDefaultCACertificates(certs) { | |
| 209 | - if (!ArrayIsArray(certs)) { | ||
| 210 | - throw new ERR_INVALID_ARG_TYPE('certs', 'Array', certs); | ||
| 211 | - } | ||
| 209 | + validateArray(certs, 'certs'); | ||
| 212 | 210 | ||
| 213 | 211 | // Verify that all elements in the array are strings | |
| 214 | 212 | for (let i = 0; i < certs.length; i++) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments