From 1fd60881ea1e32224aa583f984d40fd4544e6956 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Fri, 18 Nov 2022 18:20:40 -0500 Subject: [PATCH] stream: add primordials to adapters --- 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 c907ba7db30268..165e79318838eb 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), + ); } }