mirror of
https://github.com/denoland/deno.git
synced 2025-01-08 07:08:27 -05:00
refactor(runtime/io): use primordials (#15906)
This commit is contained in:
parent
f911b58631
commit
a253ec4e55
1 changed files with 5 additions and 5 deletions
|
@ -145,7 +145,7 @@
|
||||||
const buf = new Uint8Array(READ_PER_ITER);
|
const buf = new Uint8Array(READ_PER_ITER);
|
||||||
const read = r.readSync(buf);
|
const read = r.readSync(buf);
|
||||||
if (typeof read == "number") {
|
if (typeof read == "number") {
|
||||||
ArrayPrototypePush(buffers, buf.subarray(0, read));
|
ArrayPrototypePush(buffers, TypedArrayPrototypeSubarray(buf, 0, read));
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@
|
||||||
|
|
||||||
while (cursor < size) {
|
while (cursor < size) {
|
||||||
const sliceEnd = MathMin(size + 1, cursor + READ_PER_ITER);
|
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);
|
const read = r.readSync(slice);
|
||||||
if (typeof read == "number") {
|
if (typeof read == "number") {
|
||||||
cursor += read;
|
cursor += read;
|
||||||
|
@ -191,7 +191,7 @@
|
||||||
// Read remaining and concat
|
// Read remaining and concat
|
||||||
return concatBuffers([buf, readAllSync(r)]);
|
return concatBuffers([buf, readAllSync(r)]);
|
||||||
} else { // cursor == size
|
} else { // cursor == size
|
||||||
return buf.subarray(0, cursor);
|
return TypedArrayPrototypeSubarray(buf, 0, cursor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@
|
||||||
while (cursor < size) {
|
while (cursor < size) {
|
||||||
signal?.throwIfAborted();
|
signal?.throwIfAborted();
|
||||||
const sliceEnd = MathMin(size + 1, cursor + READ_PER_ITER);
|
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);
|
const read = await r.read(slice);
|
||||||
if (typeof read == "number") {
|
if (typeof read == "number") {
|
||||||
cursor += read;
|
cursor += read;
|
||||||
|
@ -217,7 +217,7 @@
|
||||||
// Read remaining and concat
|
// Read remaining and concat
|
||||||
return concatBuffers([buf, await readAllInner(r, options)]);
|
return concatBuffers([buf, await readAllInner(r, options)]);
|
||||||
} else {
|
} else {
|
||||||
return buf.subarray(0, cursor);
|
return TypedArrayPrototypeSubarray(buf, 0, cursor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue