diff --git a/ext/io/12_io.js b/ext/io/12_io.js index 36cde6020d..3bf05207d4 100644 --- a/ext/io/12_io.js +++ b/ext/io/12_io.js @@ -15,7 +15,6 @@ const { ArrayPrototypePush, TypedArrayPrototypeSubarray, TypedArrayPrototypeSet, - TypedArrayPrototypeGetBuffer, TypedArrayPrototypeGetByteLength, } = primordials; @@ -112,26 +111,18 @@ function write(rid, data) { const READ_PER_ITER = 64 * 1024; // 64kb -function readAll(r) { - return readAllInner(r); -} -async function readAllInner(r, options) { +async function readAll(r) { const buffers = []; - const signal = options?.signal ?? null; + while (true) { - signal?.throwIfAborted(); const buf = new Uint8Array(READ_PER_ITER); const read = await r.read(buf); if (typeof read == "number") { - ArrayPrototypePush( - buffers, - new Uint8Array(TypedArrayPrototypeGetBuffer(buf), 0, read), - ); + ArrayPrototypePush(buffers, TypedArrayPrototypeSubarray(buf, 0, read)); } else { break; } } - signal?.throwIfAborted(); return concatBuffers(buffers); } @@ -275,7 +266,6 @@ export { iterSync, read, readAll, - readAllInner, readAllSync, readSync, SeekMode,