diff options
Diffstat (limited to 'ext/fetch')
-rw-r--r-- | ext/fetch/20_headers.js | 7 | ||||
-rw-r--r-- | ext/fetch/21_formdata.js | 34 | ||||
-rw-r--r-- | ext/fetch/22_body.js | 105 | ||||
-rw-r--r-- | ext/fetch/22_http_client.js | 2 | ||||
-rw-r--r-- | ext/fetch/23_request.js | 36 | ||||
-rw-r--r-- | ext/fetch/23_response.js | 26 | ||||
-rw-r--r-- | ext/fetch/26_fetch.js | 46 |
7 files changed, 80 insertions, 176 deletions
diff --git a/ext/fetch/20_headers.js b/ext/fetch/20_headers.js index 94f68df42..b1299fb1b 100644 --- a/ext/fetch/20_headers.js +++ b/ext/fetch/20_headers.js @@ -263,7 +263,7 @@ * @param {string} value */ append(name, value) { - webidl.assertBranded(this, HeadersPrototype); + webidl.assertBranded(this, Headers); const prefix = "Failed to execute 'append' on 'Headers'"; webidl.requiredArguments(arguments.length, 2, { prefix }); name = webidl.converters["ByteString"](name, { @@ -354,7 +354,7 @@ * @param {string} value */ set(name, value) { - webidl.assertBranded(this, HeadersPrototype); + webidl.assertBranded(this, Headers); const prefix = "Failed to execute 'set' on 'Headers'"; webidl.requiredArguments(arguments.length, 2, { prefix }); name = webidl.converters["ByteString"](name, { @@ -411,7 +411,6 @@ webidl.mixinPairIterable("Headers", Headers, _iterableHeaders, 0, 1); webidl.configurePrototype(Headers); - const HeadersPrototype = Headers.prototype; webidl.converters["HeadersInit"] = (V, opts) => { // Union for (sequence<sequence<ByteString>> or record<ByteString, ByteString>) @@ -429,7 +428,7 @@ }; webidl.converters["Headers"] = webidl.createInterfaceConverter( "Headers", - Headers.prototype, + Headers, ); /** diff --git a/ext/fetch/21_formdata.js b/ext/fetch/21_formdata.js index a134fe5f7..cc338de72 100644 --- a/ext/fetch/21_formdata.js +++ b/ext/fetch/21_formdata.js @@ -13,8 +13,7 @@ ((window) => { const core = window.Deno.core; const webidl = globalThis.__bootstrap.webidl; - const { Blob, BlobPrototype, File, FilePrototype } = - globalThis.__bootstrap.file; + const { Blob, File } = globalThis.__bootstrap.file; const { ArrayPrototypeMap, ArrayPrototypePush, @@ -26,7 +25,6 @@ MapPrototypeGet, MapPrototypeSet, MathRandom, - ObjectPrototypeIsPrototypeOf, Symbol, StringFromCharCode, StringPrototypeTrim, @@ -50,16 +48,10 @@ * @returns {FormDataEntry} */ function createEntry(name, value, filename) { - if ( - ObjectPrototypeIsPrototypeOf(BlobPrototype, value) && - !ObjectPrototypeIsPrototypeOf(FilePrototype, value) - ) { + if (value instanceof Blob && !(value instanceof File)) { value = new File([value], "blob", { type: value.type }); } - if ( - ObjectPrototypeIsPrototypeOf(FilePrototype, value) && - filename !== undefined - ) { + if (value instanceof File && filename !== undefined) { value = new File([value], filename, { type: value.type, lastModified: value.lastModified, @@ -97,7 +89,7 @@ * @returns {void} */ append(name, valueOrBlobValue, filename) { - webidl.assertBranded(this, FormDataPrototype); + webidl.assertBranded(this, FormData); const prefix = "Failed to execute 'append' on 'FormData'"; webidl.requiredArguments(arguments.length, 2, { prefix }); @@ -105,7 +97,7 @@ prefix, context: "Argument 1", }); - if (ObjectPrototypeIsPrototypeOf(BlobPrototype, valueOrBlobValue)) { + if (valueOrBlobValue instanceof Blob) { valueOrBlobValue = webidl.converters["Blob"](valueOrBlobValue, { prefix, context: "Argument 2", @@ -133,7 +125,7 @@ * @returns {void} */ delete(name) { - webidl.assertBranded(this, FormDataPrototype); + webidl.assertBranded(this, FormData); const prefix = "Failed to execute 'name' on 'FormData'"; webidl.requiredArguments(arguments.length, 1, { prefix }); @@ -156,7 +148,7 @@ * @returns {FormDataEntryValue | null} */ get(name) { - webidl.assertBranded(this, FormDataPrototype); + webidl.assertBranded(this, FormData); const prefix = "Failed to execute 'get' on 'FormData'"; webidl.requiredArguments(arguments.length, 1, { prefix }); @@ -176,7 +168,7 @@ * @returns {FormDataEntryValue[]} */ getAll(name) { - webidl.assertBranded(this, FormDataPrototype); + webidl.assertBranded(this, FormData); const prefix = "Failed to execute 'getAll' on 'FormData'"; webidl.requiredArguments(arguments.length, 1, { prefix }); @@ -197,7 +189,7 @@ * @returns {boolean} */ has(name) { - webidl.assertBranded(this, FormDataPrototype); + webidl.assertBranded(this, FormData); const prefix = "Failed to execute 'has' on 'FormData'"; webidl.requiredArguments(arguments.length, 1, { prefix }); @@ -219,7 +211,7 @@ * @returns {void} */ set(name, valueOrBlobValue, filename) { - webidl.assertBranded(this, FormDataPrototype); + webidl.assertBranded(this, FormData); const prefix = "Failed to execute 'set' on 'FormData'"; webidl.requiredArguments(arguments.length, 2, { prefix }); @@ -227,7 +219,7 @@ prefix, context: "Argument 1", }); - if (ObjectPrototypeIsPrototypeOf(BlobPrototype, valueOrBlobValue)) { + if (valueOrBlobValue instanceof Blob) { valueOrBlobValue = webidl.converters["Blob"](valueOrBlobValue, { prefix, context: "Argument 2", @@ -269,7 +261,6 @@ webidl.mixinPairIterable("FormData", FormData, entryList, "name", "value"); webidl.configurePrototype(FormData); - const FormDataPrototype = FormData.prototype; const escape = (str, isFilename) => StringPrototypeReplace( @@ -500,11 +491,10 @@ } webidl.converters["FormData"] = webidl - .createInterfaceConverter("FormData", FormDataPrototype); + .createInterfaceConverter("FormData", FormData); globalThis.__bootstrap.formData = { FormData, - FormDataPrototype, formDataToBlob, parseFormData, formDataFromEntries, diff --git a/ext/fetch/22_body.js b/ext/fetch/22_body.js index f33097033..acfd06b0f 100644 --- a/ext/fetch/22_body.js +++ b/ext/fetch/22_body.js @@ -16,35 +16,23 @@ const core = window.Deno.core; const webidl = globalThis.__bootstrap.webidl; const { parseUrlEncoded } = globalThis.__bootstrap.url; - const { URLSearchParamsPrototype } = globalThis.__bootstrap.url; - const { - parseFormData, - formDataFromEntries, - formDataToBlob, - FormDataPrototype, - } = globalThis.__bootstrap.formData; + const { parseFormData, formDataFromEntries, formDataToBlob } = + globalThis.__bootstrap.formData; const mimesniff = globalThis.__bootstrap.mimesniff; - const { BlobPrototype } = globalThis.__bootstrap.file; - const { - isReadableStreamDisturbed, - errorReadableStream, - createProxy, - ReadableStreamPrototype, - } = globalThis.__bootstrap.streams; + const { isReadableStreamDisturbed, errorReadableStream, createProxy } = + globalThis.__bootstrap.streams; const { - ArrayBufferPrototype, + ArrayBuffer, ArrayBufferIsView, ArrayPrototypePush, ArrayPrototypeMap, JSONParse, ObjectDefineProperties, - ObjectPrototypeIsPrototypeOf, PromiseResolve, TypedArrayPrototypeSet, TypedArrayPrototypeSlice, TypeError, Uint8Array, - Uint8ArrayPrototype, } = window.__bootstrap.primordials; /** @@ -78,12 +66,7 @@ } get stream() { - if ( - !ObjectPrototypeIsPrototypeOf( - ReadableStreamPrototype, - this.streamOrStatic, - ) - ) { + if (!(this.streamOrStatic instanceof ReadableStream)) { const { body, consumed } = this.streamOrStatic; if (consumed) { this.streamOrStatic = new ReadableStream(); @@ -105,12 +88,7 @@ * @returns {boolean} */ unusable() { - if ( - ObjectPrototypeIsPrototypeOf( - ReadableStreamPrototype, - this.streamOrStatic, - ) - ) { + if (this.streamOrStatic instanceof ReadableStream) { return this.streamOrStatic.locked || isReadableStreamDisturbed(this.streamOrStatic); } @@ -121,12 +99,7 @@ * @returns {boolean} */ consumed() { - if ( - ObjectPrototypeIsPrototypeOf( - ReadableStreamPrototype, - this.streamOrStatic, - ) - ) { + if (this.streamOrStatic instanceof ReadableStream) { return isReadableStreamDisturbed(this.streamOrStatic); } return this.streamOrStatic.consumed; @@ -138,12 +111,7 @@ */ async consume() { if (this.unusable()) throw new TypeError("Body already consumed."); - if ( - ObjectPrototypeIsPrototypeOf( - ReadableStreamPrototype, - this.streamOrStatic, - ) - ) { + if (this.streamOrStatic instanceof ReadableStream) { const reader = this.stream.getReader(); /** @type {Uint8Array[]} */ const chunks = []; @@ -168,12 +136,7 @@ } cancel(error) { - if ( - ObjectPrototypeIsPrototypeOf( - ReadableStreamPrototype, - this.streamOrStatic, - ) - ) { + if (this.streamOrStatic instanceof ReadableStream) { this.streamOrStatic.cancel(error); } else { this.streamOrStatic.consumed = true; @@ -181,12 +144,7 @@ } error(error) { - if ( - ObjectPrototypeIsPrototypeOf( - ReadableStreamPrototype, - this.streamOrStatic, - ) - ) { + if (this.streamOrStatic instanceof ReadableStream) { errorReadableStream(this.streamOrStatic, error); } else { this.streamOrStatic.consumed = true; @@ -210,12 +168,7 @@ */ createProxy() { let proxyStreamOrStatic; - if ( - ObjectPrototypeIsPrototypeOf( - ReadableStreamPrototype, - this.streamOrStatic, - ) - ) { + if (this.streamOrStatic instanceof ReadableStream) { proxyStreamOrStatic = createProxy(this.streamOrStatic); } else { proxyStreamOrStatic = { ...this.streamOrStatic }; @@ -329,7 +282,7 @@ enumerable: true, }, }; - return ObjectDefineProperties(prototype, mixin); + return ObjectDefineProperties(prototype.prototype, mixin); } /** @@ -388,21 +341,18 @@ let source = null; let length = null; let contentType = null; - if (ObjectPrototypeIsPrototypeOf(BlobPrototype, object)) { + if (object instanceof Blob) { stream = object.stream(); source = object; length = object.size; if (object.type.length !== 0) { contentType = object.type; } - } else if (ObjectPrototypeIsPrototypeOf(Uint8ArrayPrototype, object)) { + } else if (object instanceof Uint8Array) { // Fast(er) path for common case of Uint8Array const copy = TypedArrayPrototypeSlice(object, 0, object.byteLength); source = copy; - } else if ( - ArrayBufferIsView(object) || - ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, object) - ) { + } else if (ArrayBufferIsView(object) || object instanceof ArrayBuffer) { const u8 = ArrayBufferIsView(object) ? new Uint8Array( object.buffer, @@ -412,28 +362,26 @@ : new Uint8Array(object); const copy = TypedArrayPrototypeSlice(u8, 0, u8.byteLength); source = copy; - } else if (ObjectPrototypeIsPrototypeOf(FormDataPrototype, object)) { + } else if (object instanceof FormData) { const res = formDataToBlob(object); stream = res.stream(); source = res; length = res.size; contentType = res.type; - } else if ( - ObjectPrototypeIsPrototypeOf(URLSearchParamsPrototype, object) - ) { + } else if (object instanceof URLSearchParams) { // TODO(@satyarohith): not sure what primordial here. source = object.toString(); contentType = "application/x-www-form-urlencoded;charset=UTF-8"; } else if (typeof object === "string") { source = object; contentType = "text/plain;charset=UTF-8"; - } else if (ObjectPrototypeIsPrototypeOf(ReadableStreamPrototype, object)) { + } else if (object instanceof ReadableStream) { stream = object; if (object.locked || isReadableStreamDisturbed(object)) { throw new TypeError("ReadableStream is locked or disturbed"); } } - if (ObjectPrototypeIsPrototypeOf(Uint8ArrayPrototype, source)) { + if (source instanceof Uint8Array) { stream = { body: source, consumed: false }; length = source.byteLength; } else if (typeof source === "string") { @@ -451,22 +399,19 @@ webidl.converters["BodyInit_DOMString"] = (V, opts) => { // Union for (ReadableStream or Blob or ArrayBufferView or ArrayBuffer or FormData or URLSearchParams or USVString) - if (ObjectPrototypeIsPrototypeOf(ReadableStreamPrototype, V)) { + if (V instanceof ReadableStream) { // TODO(lucacasonato): ReadableStream is not branded return V; - } else if (ObjectPrototypeIsPrototypeOf(BlobPrototype, V)) { + } else if (V instanceof Blob) { return webidl.converters["Blob"](V, opts); - } else if (ObjectPrototypeIsPrototypeOf(FormDataPrototype, V)) { + } else if (V instanceof FormData) { return webidl.converters["FormData"](V, opts); - } else if (ObjectPrototypeIsPrototypeOf(URLSearchParamsPrototype, V)) { + } else if (V instanceof URLSearchParams) { // TODO(lucacasonato): URLSearchParams is not branded return V; } if (typeof V === "object") { - if ( - ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, V) || - ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, V) - ) { + if (V instanceof ArrayBuffer || V instanceof SharedArrayBuffer) { return webidl.converters["ArrayBuffer"](V, opts); } if (ArrayBufferIsView(V)) { diff --git a/ext/fetch/22_http_client.js b/ext/fetch/22_http_client.js index 15690b7d4..44159de07 100644 --- a/ext/fetch/22_http_client.js +++ b/ext/fetch/22_http_client.js @@ -34,10 +34,8 @@ core.close(this.rid); } } - const HttpClientPrototype = HttpClient.prototype; window.__bootstrap.fetch ??= {}; window.__bootstrap.fetch.createHttpClient = createHttpClient; window.__bootstrap.fetch.HttpClient = HttpClient; - window.__bootstrap.fetch.HttpClientPrototype = HttpClientPrototype; })(globalThis); diff --git a/ext/fetch/23_request.js b/ext/fetch/23_request.js index 5294009ff..5783cac9e 100644 --- a/ext/fetch/23_request.js +++ b/ext/fetch/23_request.js @@ -26,7 +26,7 @@ fillHeaders, getDecodeSplitHeader, } = window.__bootstrap.headers; - const { HttpClientPrototype } = window.__bootstrap.fetch; + const { HttpClient } = window.__bootstrap.fetch; const abortSignal = window.__bootstrap.abortSignal; const { ArrayPrototypeMap, @@ -36,7 +36,6 @@ MapPrototypeGet, MapPrototypeSet, ObjectKeys, - ObjectPrototypeIsPrototypeOf, RegExpPrototypeTest, Symbol, SymbolFor, @@ -242,9 +241,7 @@ const parsedURL = new URL(input, baseURL); request = newInnerRequest("GET", parsedURL.href, [], null, true); } else { // 6. - if (!ObjectPrototypeIsPrototypeOf(RequestPrototype, input)) { - throw new TypeError("Unreachable"); - } + if (!(input instanceof Request)) throw new TypeError("Unreachable"); request = input[_request]; signal = input[_signal]; } @@ -271,10 +268,7 @@ // NOTE: non standard extension. This handles Deno.HttpClient parameter if (init.client !== undefined) { - if ( - init.client !== null && - !ObjectPrototypeIsPrototypeOf(HttpClientPrototype, init.client) - ) { + if (init.client !== null && !(init.client instanceof HttpClient)) { throw webidl.makeException( TypeError, "`client` must be a Deno.HttpClient", @@ -318,7 +312,7 @@ // 33. let inputBody = null; - if (ObjectPrototypeIsPrototypeOf(RequestPrototype, input)) { + if (input instanceof Request) { inputBody = input[_body]; } @@ -362,32 +356,32 @@ } get method() { - webidl.assertBranded(this, RequestPrototype); + webidl.assertBranded(this, Request); return this[_request].method; } get url() { - webidl.assertBranded(this, RequestPrototype); + webidl.assertBranded(this, Request); return this[_request].url(); } get headers() { - webidl.assertBranded(this, RequestPrototype); + webidl.assertBranded(this, Request); return this[_headers]; } get redirect() { - webidl.assertBranded(this, RequestPrototype); + webidl.assertBranded(this, Request); return this[_request].redirectMode; } get signal() { - webidl.assertBranded(this, RequestPrototype); + webidl.assertBranded(this, Request); return this[_signal]; } clone() { - webidl.assertBranded(this, RequestPrototype); + webidl.assertBranded(this, Request); if (this[_body] && this[_body].unusable()) { throw new TypeError("Body is unusable."); } @@ -404,7 +398,7 @@ [SymbolFor("Deno.customInspect")](inspect) { return inspect(consoleInternal.createFilteredInspectProxy({ object: this, - evaluate: ObjectPrototypeIsPrototypeOf(RequestPrototype, this), + evaluate: this instanceof Request, keys: [ "bodyUsed", "headers", @@ -416,18 +410,18 @@ } } + mixinBody(Request, _body, _mimeType); + webidl.configurePrototype(Request); - const RequestPrototype = Request.prototype; - mixinBody(RequestPrototype, _body, _mimeType); webidl.converters["Request"] = webidl.createInterfaceConverter( "Request", - RequestPrototype, + Request, ); webidl.converters["RequestInfo_DOMString"] = (V, opts) => { // Union for (Request or USVString) if (typeof V == "object") { - if (ObjectPrototypeIsPrototypeOf(RequestPrototype, V)) { + if (V instanceof Request) { return webidl.converters["Request"](V, opts); } } diff --git a/ext/fetch/23_response.js b/ext/fetch/23_response.js index 14aadbaf2..e7b205418 100644 --- a/ext/fetch/23_response.js +++ b/ext/fetch/23_response.js @@ -33,7 +33,6 @@ MapPrototypeHas, MapPrototypeGet, MapPrototypeSet, - ObjectPrototypeIsPrototypeOf, RangeError, RegExp, RegExpPrototypeTest, @@ -298,7 +297,7 @@ * @returns {"basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect"} */ get type() { - webidl.assertBranded(this, ResponsePrototype); + webidl.assertBranded(this, Response); return this[_response].type; } @@ -306,7 +305,7 @@ * @returns {string} */ get url() { - webidl.assertBranded(this, ResponsePrototype); + webidl.assertBranded(this, Response); const url = this[_response].url(); if (url === null) return ""; const newUrl = new URL(url); @@ -318,7 +317,7 @@ * @returns {boolean} */ get redirected() { - webidl.assertBranded(this, ResponsePrototype); + webidl.assertBranded(this, Response); return this[_response].urlList.length > 1; } @@ -326,7 +325,7 @@ * @returns {number} */ get status() { - webidl.assertBranded(this, ResponsePrototype); + webidl.assertBranded(this, Response); return this[_response].status; } @@ -334,7 +333,7 @@ * @returns {boolean} */ get ok() { - webidl.assertBranded(this, ResponsePrototype); + webidl.assertBranded(this, Response); const status = this[_response].status; return status >= 200 && status <= 299; } @@ -343,7 +342,7 @@ * @returns {string} */ get statusText() { - webidl.assertBranded(this, ResponsePrototype); + webidl.assertBranded(this, Response); return this[_response].statusMessage; } @@ -351,7 +350,7 @@ * @returns {Headers} */ get headers() { - webidl.assertBranded(this, ResponsePrototype); + webidl.assertBranded(this, Response); return this[_headers]; } @@ -359,7 +358,7 @@ * @returns {Response} */ clone() { - webidl.assertBranded(this, ResponsePrototype); + webidl.assertBranded(this, Response); if (this[_body] && this[_body].unusable()) { throw new TypeError("Body is unusable."); } @@ -376,7 +375,7 @@ [SymbolFor("Deno.customInspect")](inspect) { return inspect(consoleInternal.createFilteredInspectProxy({ object: this, - evaluate: ObjectPrototypeIsPrototypeOf(ResponsePrototype, this), + evaluate: this instanceof Response, keys: [ "body", "bodyUsed", @@ -391,13 +390,13 @@ } } + mixinBody(Response, _body, _mimeType); + webidl.configurePrototype(Response); - const ResponsePrototype = Response.prototype; - mixinBody(ResponsePrototype, _body, _mimeType); webidl.converters["Response"] = webidl.createInterfaceConverter( "Response", - ResponsePrototype, + Response, ); webidl.converters["ResponseInit"] = webidl.createDictionaryConverter( "ResponseInit", @@ -458,7 +457,6 @@ window.__bootstrap.fetch ??= {}; window.__bootstrap.fetch.Response = Response; - window.__bootstrap.fetch.ResponsePrototype = ResponsePrototype; window.__bootstrap.fetch.newInnerResponse = newInnerResponse; window.__bootstrap.fetch.toInnerResponse = toInnerResponse; window.__bootstrap.fetch.fromInnerResponse = fromInnerResponse; diff --git a/ext/fetch/26_fetch.js b/ext/fetch/26_fetch.js index 0c58bbf97..c6fc9197b 100644 --- a/ext/fetch/26_fetch.js +++ b/ext/fetch/26_fetch.js @@ -15,9 +15,7 @@ const core = window.Deno.core; const webidl = window.__bootstrap.webidl; const { byteLowerCase } = window.__bootstrap.infra; - const { BlobPrototype } = window.__bootstrap.file; - const { errorReadableStream, ReadableStreamPrototype } = - window.__bootstrap.streams; + const { errorReadableStream } = window.__bootstrap.streams; const { InnerBody, extractBody } = window.__bootstrap.fetchBody; const { toInnerRequest, @@ -34,7 +32,6 @@ ArrayPrototypeSplice, ArrayPrototypeFilter, ArrayPrototypeIncludes, - ObjectPrototypeIsPrototypeOf, Promise, PromisePrototypeThen, PromisePrototypeCatch, @@ -44,7 +41,6 @@ TypedArrayPrototypeSubarray, TypeError, Uint8Array, - Uint8ArrayPrototype, WeakMap, WeakMapPrototypeDelete, WeakMapPrototypeGet, @@ -176,16 +172,8 @@ let reqBody = null; if (req.body !== null) { - if ( - ObjectPrototypeIsPrototypeOf( - ReadableStreamPrototype, - req.body.streamOrStatic, - ) - ) { - if ( - req.body.length === null || - ObjectPrototypeIsPrototypeOf(BlobPrototype, req.body.source) - ) { + if (req.body.streamOrStatic instanceof ReadableStream) { + if (req.body.length === null || req.body.source instanceof Blob) { reqBody = req.body.stream; } else { const reader = req.body.stream.getReader(); @@ -208,19 +196,14 @@ } } - const { requestRid, requestBodyRid, cancelHandleRid } = opFetch( - { - method: req.method, - url: req.currentUrl(), - headers: req.headerList, - clientRid: req.clientRid, - hasBody: reqBody !== null, - bodyLength: req.body?.length, - }, - ObjectPrototypeIsPrototypeOf(Uint8ArrayPrototype, reqBody) - ? reqBody - : null, - ); + const { requestRid, requestBodyRid, cancelHandleRid } = opFetch({ + method: req.method, + url: req.currentUrl(), + headers: req.headerList, + clientRid: req.clientRid, + hasBody: reqBody !== null, + bodyLength: req.body?.length, + }, reqBody instanceof Uint8Array ? reqBody : null); function onAbort() { if (cancelHandleRid !== null) { @@ -233,10 +216,7 @@ terminator[abortSignal.add](onAbort); if (requestBodyRid !== null) { - if ( - reqBody === null || - !ObjectPrototypeIsPrototypeOf(ReadableStreamPrototype, reqBody) - ) { + if (reqBody === null || !(reqBody instanceof ReadableStream)) { throw new TypeError("Unreachable"); } const reader = reqBody.getReader(); @@ -251,7 +231,7 @@ }, ); if (done) break; - if (!ObjectPrototypeIsPrototypeOf(Uint8ArrayPrototype, value)) { + if (!(value instanceof Uint8Array)) { await reader.cancel("value not a Uint8Array"); break; } |