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/io/12_io.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'ext/io') diff --git a/ext/io/12_io.js b/ext/io/12_io.js index e17711735..2a825e7f6 100644 --- a/ext/io/12_io.js +++ b/ext/io/12_io.js @@ -17,6 +17,8 @@ const { MathMin, TypedArrayPrototypeSubarray, TypedArrayPrototypeSet, + TypedArrayPrototypeGetBuffer, + TypedArrayPrototypeGetByteLength, } = primordials; const DEFAULT_BUFFER_SIZE = 32 * 1024; @@ -131,7 +133,10 @@ async function readAllInner(r, options) { const buf = new Uint8Array(READ_PER_ITER); const read = await r.read(buf); if (typeof read == "number") { - ArrayPrototypePush(buffers, new Uint8Array(buf.buffer, 0, read)); + ArrayPrototypePush( + buffers, + new Uint8Array(TypedArrayPrototypeGetBuffer(buf), 0, read), + ); } else { break; } @@ -160,7 +165,7 @@ function readAllSync(r) { function concatBuffers(buffers) { let totalLen = 0; for (let i = 0; i < buffers.length; ++i) { - totalLen += buffers[i].byteLength; + totalLen += TypedArrayPrototypeGetByteLength(buffers[i]); } const contents = new Uint8Array(totalLen); @@ -169,7 +174,7 @@ function concatBuffers(buffers) { for (let i = 0; i < buffers.length; ++i) { const buf = buffers[i]; TypedArrayPrototypeSet(contents, buf, n); - n += buf.byteLength; + n += TypedArrayPrototypeGetByteLength(buf); } return contents; -- cgit v1.2.3