| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6fa62b7 commit fbd8ede
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,6 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | - ArrayFrom, | ||
| 5 | 4 | MathMax, | |
| 6 | 5 | MathMin, | |
| 7 | 6 | ObjectDefineProperties, | |
@@ -15,7 +14,6 @@ const { | |||
| 15 | 14 | StringPrototypeSplit, | |
| 16 | 15 | StringPrototypeToLowerCase, | |
| 17 | 16 | Symbol, | |
| 18 | - SymbolIterator, | ||
| 19 | 17 | SymbolToStringTag, | |
| 20 | 18 | Uint8Array, | |
| 21 | 19 | } = primordials; | |
@@ -54,12 +52,15 @@ const { | |||
| 54 | 52 | lazyDOMException, | |
| 55 | 53 | } = require('internal/util'); | |
| 56 | 54 | const { inspect } = require('internal/util/inspect'); | |
| 57 | - const { convertToInt } = require('internal/webidl'); | ||
| 55 | + const { | ||
| 56 | + converters, | ||
| 57 | + convertToInt, | ||
| 58 | + createSequenceConverter, | ||
| 59 | + } = require('internal/webidl'); | ||
| 58 | 60 | ||
| 59 | 61 | const { | |
| 60 | 62 | codes: { | |
| 61 | 63 | ERR_BUFFER_TOO_LARGE, | |
| 62 | - ERR_INVALID_ARG_TYPE, | ||
| 63 | 64 | ERR_INVALID_ARG_VALUE, | |
| 64 | 65 | ERR_INVALID_STATE, | |
| 65 | 66 | ERR_INVALID_THIS, | |
@@ -112,7 +113,6 @@ function getSource(source, endings) { | |||
| 112 | 113 | if (isAnyArrayBuffer(source)) { | |
| 113 | 114 | source = new Uint8Array(source); | |
| 114 | 115 | } else if (!isArrayBufferView(source)) { | |
| 115 | - source = `${source}`; | ||
| 116 | 116 | if (endings === 'native') | |
| 117 | 117 | source = RegExpPrototypeSymbolReplace(/\n|\r\n/g, source, EOL); | |
| 118 | 118 | source = enc.encode(source); | |
@@ -126,6 +126,13 @@ function getSource(source, endings) { | |||
| 126 | 126 | return [byteLength, new Uint8Array(slice)]; | |
| 127 | 127 | } | |
| 128 | 128 | ||
| 129 | + const sourcesConverter = createSequenceConverter((source, opts = kEmptyObject) => { | ||
| 130 | + if (isBlob(source) || isAnyArrayBuffer(source) || isArrayBufferView(source)) { | ||
| 131 | + return source; | ||
| 132 | + } | ||
| 133 | + return converters.DOMString(source, opts); | ||
| 134 | + }); | ||
| 135 | + | ||
| 129 | 136 | class Blob { | |
| 130 | 137 | /** | |
| 131 | 138 | * @typedef {string|ArrayBuffer|ArrayBufferView|Blob} SourcePart | |
@@ -142,11 +149,8 @@ class Blob { | |||
| 142 | 149 | constructor(sources = [], options) { | |
| 143 | 150 | markTransferMode(this, true, false); | |
| 144 | 151 | ||
| 145 | - if (sources === null || | ||
| 146 | - typeof sources[SymbolIterator] !== 'function' || | ||
| 147 | - typeof sources === 'string') { | ||
| 148 | - throw new ERR_INVALID_ARG_TYPE('sources', 'a sequence', sources); | ||
| 149 | - } | ||
| 152 | + const sources_ = sourcesConverter(sources); | ||
| 153 | + | ||
| 150 | 154 | validateDictionary(options, 'options'); | |
| 151 | 155 | let { | |
| 152 | 156 | endings = 'transparent', | |
@@ -158,11 +162,11 @@ class Blob { | |||
| 158 | 162 | throw new ERR_INVALID_ARG_VALUE('options.endings', endings); | |
| 159 | 163 | ||
| 160 | 164 | let length = 0; | |
| 161 | - const sources_ = ArrayFrom(sources, (source) => { | ||
| 162 | - const { 0: len, 1: src } = getSource(source, endings); | ||
| 165 | + for (let i = 0; i < sources_.length; ++i) { | ||
| 166 | + const { 0: len, 1: src } = getSource(sources_[i], endings); | ||
| 163 | 167 | length += len; | |
| 164 | - return src; | ||
| 165 | - }); | ||
| 168 | + sources_[i] = src; | ||
| 169 | + } | ||
| 166 | 170 | ||
| 167 | 171 | if (length > kMaxLength) | |
| 168 | 172 | throw new ERR_BUFFER_TOO_LARGE(kMaxLength); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,14 +25,6 @@ module.exports = { | |||
| 25 | 25 | }, | |
| 26 | 26 | 'Blob-constructor.any.js': { | |
| 27 | 27 | fail: { | |
| 28 | - expected: [ | ||
| 29 | - 'blobParts not an object: boolean with Boolean.prototype[Symbol.iterator]', | ||
| 30 | - 'blobParts not an object: number with Number.prototype[Symbol.iterator]', | ||
| 31 | - 'blobParts not an object: BigInt with BigInt.prototype[Symbol.iterator]', | ||
| 32 | - 'blobParts not an object: Symbol with Symbol.prototype[Symbol.iterator]', | ||
| 33 | - 'Getters and value conversions should happen in order until an exception is thrown.', | ||
| 34 | - 'Arguments should be evaluated from left to right.', | ||
| 35 | - ], | ||
| 36 | 28 | flaky: [ | |
| 37 | 29 | 'Passing typed arrays as elements of the blobParts array should work.', | |
| 38 | 30 | 'Passing a Float16Array as element of the blobParts array should work.', | |
| Back | FazBrowse Home | New Git URL |
0 commit comments