summaryrefslogtreecommitdiff
path: root/ext/web/06_streams.js
diff options
context:
space:
mode:
authorKenta Moriuchi <moriken@kimamass.com>2023-05-01 22:30:02 +0900
committerGitHub <noreply@github.com>2023-05-01 15:30:02 +0200
commit6728ad4203d731e555dabf89ec6157f113454ce6 (patch)
tree956dc2d403b5a6ef107c35cab1ccc259ad4d86a1 /ext/web/06_streams.js
parent94a148cdb6f7660518c75a3c20109bf64848f0f1 (diff)
fix(core): Use primordials for methods (#18839)
I would like to get this change into Deno before merging https://github.com/denoland/deno_lint/pull/1152
Diffstat (limited to 'ext/web/06_streams.js')
-rw-r--r--ext/web/06_streams.js28
1 files changed, 19 insertions, 9 deletions
diff --git a/ext/web/06_streams.js b/ext/web/06_streams.js
index 6d390308d..c0cbb3049 100644
--- a/ext/web/06_streams.js
+++ b/ext/web/06_streams.js
@@ -19,9 +19,10 @@ import {
const primordials = globalThis.__bootstrap.primordials;
const {
ArrayBuffer,
+ ArrayBufferIsView,
ArrayBufferPrototype,
ArrayBufferPrototypeGetByteLength,
- ArrayBufferIsView,
+ ArrayBufferPrototypeSlice,
ArrayPrototypeMap,
ArrayPrototypePush,
ArrayPrototypeShift,
@@ -34,12 +35,12 @@ const {
DataViewPrototypeGetByteOffset,
Float32Array,
Float64Array,
- Int8Array,
Int16Array,
Int32Array,
+ Int8Array,
+ MathMin,
NumberIsInteger,
NumberIsNaN,
- MathMin,
ObjectCreate,
ObjectDefineProperties,
ObjectDefineProperty,
@@ -52,14 +53,13 @@ const {
PromisePrototypeThen,
PromiseReject,
PromiseResolve,
- queueMicrotask,
RangeError,
ReflectHas,
SafeFinalizationRegistry,
SafePromiseAll,
SafeWeakMap,
// TODO(lucacasonato): add SharedArrayBuffer to primordials
- // SharedArrayBufferPrototype
+ // SharedArrayBufferPrototype,
Symbol,
SymbolAsyncIterator,
SymbolFor,
@@ -70,13 +70,14 @@ const {
TypedArrayPrototypeGetSymbolToStringTag,
TypedArrayPrototypeSet,
TypedArrayPrototypeSlice,
- Uint8Array,
Uint16Array,
Uint32Array,
+ Uint8Array,
Uint8ClampedArray,
WeakMapPrototypeGet,
WeakMapPrototypeHas,
WeakMapPrototypeSet,
+ queueMicrotask,
} = primordials;
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { assert, AssertionError } from "ext:deno_web/00_infra.js";
@@ -1252,7 +1253,16 @@ function readableByteStreamControllerEnqueueClonedChunkToQueue(
) {
let cloneResult;
try {
- cloneResult = buffer.slice(byteOffset, byteOffset + byteLength);
+ if (ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, buffer)) {
+ cloneResult = ArrayBufferPrototypeSlice(
+ buffer,
+ byteOffset,
+ byteOffset + byteLength,
+ );
+ } else {
+ // TODO(lucacasonato): add SharedArrayBuffer to primordials
+ cloneResult = buffer.slice(byteOffset, byteOffset + byteLength);
+ }
} catch (e) {
readableByteStreamControllerError(controller, e);
}
@@ -1864,7 +1874,7 @@ function readableByteStreamControllerPullInto(
return;
}
}
- controller[_pendingPullIntos].push(pullIntoDescriptor);
+ ArrayPrototypePush(controller[_pendingPullIntos], pullIntoDescriptor);
readableStreamAddReadIntoRequest(stream, readIntoRequest);
readableByteStreamControllerCallPullIfNeeded(controller);
}
@@ -4481,7 +4491,7 @@ function writableStreamMarkCloseRequestInFlight(stream) {
function writableStreamMarkFirstWriteRequestInFlight(stream) {
assert(stream[_inFlightWriteRequest] === undefined);
assert(stream[_writeRequests].length);
- const writeRequest = stream[_writeRequests].shift();
+ const writeRequest = ArrayPrototypeShift(stream[_writeRequests]);
stream[_inFlightWriteRequest] = writeRequest;
}