Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(runtime/io): use primordials #15906

Merged
merged 2 commits into from
Sep 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions runtime/js/12_io.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
}

Expand All @@ -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;
Expand All @@ -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);
}
}

Expand Down