| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4b2eee5 commit 5b11042
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,7 +39,10 @@ const { | |||
| 39 | 39 | isUint8Array | |
| 40 | 40 | } = require('internal/util/types'); | |
| 41 | 41 | ||
| 42 | - const { validateString } = require('internal/validators'); | ||
| 42 | + const { | ||
| 43 | + validateString, | ||
| 44 | + validateObject, | ||
| 45 | + } = require('internal/validators'); | ||
| 43 | 46 | ||
| 44 | 47 | const { | |
| 45 | 48 | encodeInto, | |
@@ -63,12 +66,6 @@ function validateDecoder(obj) { | |||
| 63 | 66 | throw new ERR_INVALID_THIS('TextDecoder'); | |
| 64 | 67 | } | |
| 65 | 68 | ||
| 66 | - function validateArgument(prop, expected, propName, expectedName) { | ||
| 67 | - // eslint-disable-next-line valid-typeof | ||
| 68 | - if (typeof prop !== expected) | ||
| 69 | - throw new ERR_INVALID_ARG_TYPE(propName, expectedName, prop); | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | 69 | const CONVERTER_FLAGS_FLUSH = 0x1; | |
| 73 | 70 | const CONVERTER_FLAGS_FATAL = 0x2; | |
| 74 | 71 | const CONVERTER_FLAGS_IGNORE_BOM = 0x4; | |
@@ -381,7 +378,11 @@ function makeTextDecoderICU() { | |||
| 381 | 378 | class TextDecoder { | |
| 382 | 379 | constructor(encoding = 'utf-8', options = {}) { | |
| 383 | 380 | encoding = `${encoding}`; | |
| 384 | - validateArgument(options, 'object', 'options', 'Object'); | ||
| 381 | + validateObject(options, 'options', { | ||
| 382 | + nullable: true, | ||
| 383 | + allowArray: true, | ||
| 384 | + allowFunction: true, | ||
| 385 | + }); | ||
| 385 | 386 | ||
| 386 | 387 | const enc = getEncodingFromLabel(encoding); | |
| 387 | 388 | if (enc === undefined) | |
@@ -413,7 +414,11 @@ function makeTextDecoderICU() { | |||
| 413 | 414 | ['ArrayBuffer', 'ArrayBufferView'], | |
| 414 | 415 | input); | |
| 415 | 416 | } | |
| 416 | - validateArgument(options, 'object', 'options', 'Object'); | ||
| 417 | + validateObject(options, 'options', { | ||
| 418 | + nullable: true, | ||
| 419 | + allowArray: true, | ||
| 420 | + allowFunction: true, | ||
| 421 | + }); | ||
| 417 | 422 | ||
| 418 | 423 | let flags = 0; | |
| 419 | 424 | if (options !== null) | |
@@ -447,7 +452,11 @@ function makeTextDecoderJS() { | |||
| 447 | 452 | class TextDecoder { | |
| 448 | 453 | constructor(encoding = 'utf-8', options = {}) { | |
| 449 | 454 | encoding = `${encoding}`; | |
| 450 | - validateArgument(options, 'object', 'options', 'Object'); | ||
| 455 | + validateObject(options, 'options', { | ||
| 456 | + nullable: true, | ||
| 457 | + allowArray: true, | ||
| 458 | + allowFunction: true, | ||
| 459 | + }); | ||
| 451 | 460 | ||
| 452 | 461 | const enc = getEncodingFromLabel(encoding); | |
| 453 | 462 | if (enc === undefined || !hasConverter(enc)) | |
@@ -481,7 +490,11 @@ function makeTextDecoderJS() { | |||
| 481 | 490 | ['ArrayBuffer', 'ArrayBufferView'], | |
| 482 | 491 | input); | |
| 483 | 492 | } | |
| 484 | - validateArgument(options, 'object', 'options', 'Object'); | ||
| 493 | + validateObject(options, 'options', { | ||
| 494 | + nullable: true, | ||
| 495 | + allowArray: true, | ||
| 496 | + allowFunction: true, | ||
| 497 | + }); | ||
| 485 | 498 | ||
| 486 | 499 | if (this[kFlags] & CONVERTER_FLAGS_FLUSH) { | |
| 487 | 500 | this[kBOMSeen] = false; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments