From 03edd48edd004cec091541e6b71095cfbc4b4c87 Mon Sep 17 00:00:00 2001 From: Kenta Moriuchi Date: Mon, 3 Apr 2023 02:41:41 +0900 Subject: chore: Turn back on dlintPreferPrimordials (#17715) Closes #17709 --- ext/flash/01_http.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'ext/flash') diff --git a/ext/flash/01_http.js b/ext/flash/01_http.js index 4d0112c5b..fe503ed05 100644 --- a/ext/flash/01_http.js +++ b/ext/flash/01_http.js @@ -31,11 +31,12 @@ const { PromisePrototypeCatch, PromisePrototypeThen, SafePromiseAll, + TypedArrayPrototypeGetByteLength, + TypedArrayPrototypeGetSymbolToStringTag, TypedArrayPrototypeSet, TypedArrayPrototypeSubarray, TypeError, Uint8Array, - Uint8ArrayPrototype, } = primordials; const statusCodes = { @@ -188,9 +189,15 @@ function http1Response( str += body ?? ""; } else { const head = core.encode(str); - const response = new Uint8Array(head.byteLength + bodyLen); + const response = new Uint8Array( + TypedArrayPrototypeGetByteLength(head) + bodyLen, + ); TypedArrayPrototypeSet(response, head, 0); - TypedArrayPrototypeSet(response, body, head.byteLength); + TypedArrayPrototypeSet( + response, + body, + TypedArrayPrototypeGetByteLength(head), + ); return response; } @@ -303,7 +310,7 @@ async function handleResponse( } isStreamingResponseBody = !( typeof respBody === "string" || - ObjectPrototypeIsPrototypeOf(Uint8ArrayPrototype, respBody) + TypedArrayPrototypeGetSymbolToStringTag(respBody) === "Uint8Array" ); } else { if (innerResp.body.streamOrStatic.consumed === true) { @@ -318,7 +325,9 @@ async function handleResponse( const ws = resp[_ws]; if (isStreamingResponseBody === false) { - const length = respBody.byteLength || core.byteLength(respBody); + const length = typeof respBody === "string" + ? core.byteLength(respBody) + : TypedArrayPrototypeGetByteLength(respBody); const responseStr = http1Response( method, innerResp.status ?? 200, @@ -394,8 +403,10 @@ async function handleResponse( innerResp.status ?? 200, innerResp.headerList, null, + // deno-lint-ignore prefer-primordials respBody.byteLength, ), + // deno-lint-ignore prefer-primordials respBody.byteLength, false, respondFast, @@ -722,7 +733,7 @@ function createRequestBodyStream(serverId, token) { token, ); if (!firstRead) return null; - let firstEnqueued = firstRead.byteLength == 0; + let firstEnqueued = TypedArrayPrototypeGetByteLength(firstRead) === 0; return new ReadableStream({ type: "bytes", -- cgit v1.2.3