From c00258e24b5c7bf2b13f969a7fd2ba3ab9f2eef2 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Sun, 20 Nov 2022 18:30:59 -0500 Subject: [PATCH] stream: add primordials to adapters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/45511 Reviewed-By: Antoine du Hamel Reviewed-By: Daeyeon Jeong Reviewed-By: Michaƫl Zasso --- lib/internal/webstreams/adapters.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/internal/webstreams/adapters.js b/lib/internal/webstreams/adapters.js index 7e8643266e1452..0e844d01200751 100644 --- a/lib/internal/webstreams/adapters.js +++ b/lib/internal/webstreams/adapters.js @@ -5,6 +5,9 @@ const { PromiseResolve, SafePromiseAll, SafePromisePrototypeFinally, + TypedArrayPrototypeGetBuffer, + TypedArrayPrototypeGetByteOffset, + TypedArrayPrototypeGetByteLength, Uint8Array, } = primordials; @@ -267,9 +270,10 @@ function newStreamWritableFromWritableStream(writableStream, options = kEmptyObj } else { chunk = Buffer.from(chunk, encoding); chunk = new Uint8Array( - chunk.buffer, - chunk.byteOffset, - chunk.byteLength); + TypedArrayPrototypeGetBuffer(chunk), + TypedArrayPrototypeGetByteOffset(chunk), + TypedArrayPrototypeGetByteLength(chunk), + ); } } @@ -692,9 +696,10 @@ function newStreamDuplexFromReadableWritablePair(pair = kEmptyObject, options = } else { chunk = Buffer.from(chunk, encoding); chunk = new Uint8Array( - chunk.buffer, - chunk.byteOffset, - chunk.byteLength); + TypedArrayPrototypeGetBuffer(chunk), + TypedArrayPrototypeGetByteOffset(chunk), + TypedArrayPrototypeGetByteLength(chunk), + ); } }