summaryrefslogtreecommitdiff
path: root/runtime/js/12_io.js
diff options
context:
space:
mode:
authorMarcos Casagrande <marcoscvp90@gmail.com>2022-09-15 10:05:41 +0200
committerGitHub <noreply@github.com>2022-09-15 13:35:41 +0530
commit606a6d786129eae20cc8eb50a8a810319541017b (patch)
tree3f597cf978191837bb20c8cd7740a3a92d5cb72b /runtime/js/12_io.js
parent1de17fad7f6c15ecc2fa76360a086c6ea24e1c12 (diff)
refactor(runtime/io): use primordials (#15906)
Diffstat (limited to 'runtime/js/12_io.js')
-rw-r--r--runtime/js/12_io.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/runtime/js/12_io.js b/runtime/js/12_io.js
index e41657d96..db83343bf 100644
--- a/runtime/js/12_io.js
+++ b/runtime/js/12_io.js
@@ -145,7 +145,7 @@
const buf = new Uint8Array(READ_PER_ITER);
const read = r.readSync(buf);
if (typeof read == "number") {
- ArrayPrototypePush(buffers, buf.subarray(0, read));
+ ArrayPrototypePush(buffers, TypedArrayPrototypeSubarray(buf, 0, read));
} else {
break;
}
@@ -177,7 +177,7 @@
while (cursor < size) {
const sliceEnd = MathMin(size + 1, cursor + READ_PER_ITER);
- const slice = buf.subarray(cursor, sliceEnd);
+ const slice = TypedArrayPrototypeSubarray(buf, cursor, sliceEnd);
const read = r.readSync(slice);
if (typeof read == "number") {
cursor += read;
@@ -191,7 +191,7 @@
// Read remaining and concat
return concatBuffers([buf, readAllSync(r)]);
} else { // cursor == size
- return buf.subarray(0, cursor);
+ return TypedArrayPrototypeSubarray(buf, 0, cursor);
}
}
@@ -202,7 +202,7 @@
while (cursor < size) {
signal?.throwIfAborted();
const sliceEnd = MathMin(size + 1, cursor + READ_PER_ITER);
- const slice = buf.subarray(cursor, sliceEnd);
+ const slice = TypedArrayPrototypeSubarray(buf, cursor, sliceEnd);
const read = await r.read(slice);
if (typeof read == "number") {
cursor += read;
@@ -217,7 +217,7 @@
// Read remaining and concat
return concatBuffers([buf, await readAllInner(r, options)]);
} else {
- return buf.subarray(0, cursor);
+ return TypedArrayPrototypeSubarray(buf, 0, cursor);
}
}