refactor: update runtime code for primordial checks for "instanceof" (#13497)

This commit is contained in:
Bartek Iwańczuk 2022-01-27 13:36:36 +01:00 committed by GitHub
parent dcf8f144ab
commit 884143218f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 1030 additions and 660 deletions

View file

@ -9,21 +9,22 @@
((window) => {
const webidl = window.__bootstrap.webidl;
const { add, remove, signalAbort, newSignal } =
const { add, remove, signalAbort, newSignal, AbortSignalPrototype } =
window.__bootstrap.abortSignal;
const {
ArrayBuffer,
ArrayBufferPrototype,
ArrayBufferIsView,
ArrayPrototypeMap,
ArrayPrototypePush,
ArrayPrototypeShift,
BigInt64Array,
BigUint64Array,
BigInt64ArrayPrototype,
BigUint64ArrayPrototype,
DataView,
Error,
Int8Array,
Int16Array,
Int32Array,
Int8ArrayPrototype,
Int16ArrayPrototype,
Int32ArrayPrototype,
NumberIsInteger,
NumberIsNaN,
MathMin,
@ -31,6 +32,7 @@
ObjectDefineProperties,
ObjectDefineProperty,
ObjectGetPrototypeOf,
ObjectPrototypeIsPrototypeOf,
ObjectSetPrototypeOf,
Promise,
PromiseAll,
@ -46,9 +48,10 @@
SymbolFor,
TypeError,
Uint8Array,
Uint16Array,
Uint32Array,
Uint8ClampedArray,
Uint8ArrayPrototype,
Uint16ArrayPrototype,
Uint32ArrayPrototype,
Uint8ClampedArrayPrototype,
WeakMap,
WeakMapPrototypeGet,
WeakMapPrototypeHas,
@ -134,7 +137,7 @@
/** @param {any} e */
function rethrowAssertionErrorRejection(e) {
if (e && e instanceof AssertionError) {
if (e && ObjectPrototypeIsPrototypeOf(AssertionError.prototype, e)) {
queueMicrotask(() => {
console.error(`Internal Error: ${e.stack}`);
});
@ -214,7 +217,10 @@
*/
function canTransferArrayBuffer(O) {
assert(typeof O === "object");
assert(O instanceof ArrayBuffer || O instanceof SharedArrayBuffer);
assert(
ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, O) ||
ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, O),
);
if (isDetachedBuffer(O)) {
return false;
}
@ -1364,15 +1370,15 @@
let ctor = DataView;
if (
view instanceof Int8Array ||
view instanceof Uint8Array ||
view instanceof Uint8ClampedArray ||
view instanceof Int16Array ||
view instanceof Uint16Array ||
view instanceof Int32Array ||
view instanceof Uint32Array ||
view instanceof BigInt64Array ||
view instanceof BigUint64Array
ObjectPrototypeIsPrototypeOf(Int8ArrayPrototype, view) ||
ObjectPrototypeIsPrototypeOf(Uint8ArrayPrototype, view) ||
ObjectPrototypeIsPrototypeOf(Uint8ClampedArrayPrototype, view) ||
ObjectPrototypeIsPrototypeOf(Int16ArrayPrototype, view) ||
ObjectPrototypeIsPrototypeOf(Uint16ArrayPrototype, view) ||
ObjectPrototypeIsPrototypeOf(Int32ArrayPrototype, view) ||
ObjectPrototypeIsPrototypeOf(Uint32ArrayPrototype, view) ||
ObjectPrototypeIsPrototypeOf(BigInt64ArrayPrototype, view) ||
ObjectPrototypeIsPrototypeOf(BigUint64ArrayPrototype, view)
) {
elementSize = view.constructor.BYTES_PER_ELEMENT;
ctor = view.constructor;
@ -1983,7 +1989,10 @@
typeof preventClose === "boolean" && typeof preventAbort === "boolean" &&
typeof preventCancel === "boolean",
);
assert(signal === undefined || signal instanceof AbortSignal);
assert(
signal === undefined ||
ObjectPrototypeIsPrototypeOf(AbortSignalPrototype, signal),
);
assert(!isReadableStreamLocked(source));
assert(!isWritableStreamLocked(dest));
// We use acquireReadableStreamDefaultReader even in case of ReadableByteStreamController
@ -2327,7 +2336,12 @@
function readableStreamTee(stream, cloneForBranch2) {
assert(isReadableStream(stream));
assert(typeof cloneForBranch2 === "boolean");
if (stream[_controller] instanceof ReadableByteStreamController) {
if (
ObjectPrototypeIsPrototypeOf(
ReadableByteStreamControllerPrototype,
stream[_controller],
)
) {
return readableByteStreamTee(stream);
} else {
return readableStreamDefaultTee(stream, cloneForBranch2);
@ -2491,7 +2505,12 @@
*/
function readableByteStreamTee(stream) {
assert(isReadableStream(stream));
assert(stream[_controller] instanceof ReadableByteStreamController);
assert(
ObjectPrototypeIsPrototypeOf(
ReadableByteStreamControllerPrototype,
stream[_controller],
),
);
let reader = acquireReadableStreamDefaultReader(stream);
let reading = false;
let readAgainForBranch1 = false;
@ -2999,7 +3018,12 @@
if (isReadableStreamLocked(stream)) {
throw new TypeError("ReadableStream is locked.");
}
if (!(stream[_controller] instanceof ReadableByteStreamController)) {
if (
!(ObjectPrototypeIsPrototypeOf(
ReadableByteStreamControllerPrototype,
stream[_controller],
))
) {
throw new TypeError("Cannot use a BYOB reader with a non-byte stream");
}
readableStreamReaderGenericInitialize(reader, stream);
@ -3032,7 +3056,7 @@
transformAlgorithm,
flushAlgorithm,
) {
assert(stream instanceof TransformStream);
assert(ObjectPrototypeIsPrototypeOf(TransformStreamPrototype, stream));
assert(stream[_controller] === undefined);
controller[_stream] = stream;
stream[_controller] = controller;
@ -4174,13 +4198,13 @@
/** @returns {number} */
get highWaterMark() {
webidl.assertBranded(this, ByteLengthQueuingStrategy);
webidl.assertBranded(this, ByteLengthQueuingStrategyPrototype);
return this[_highWaterMark];
}
/** @returns {(chunk: ArrayBufferView) => number} */
get size() {
webidl.assertBranded(this, ByteLengthQueuingStrategy);
webidl.assertBranded(this, ByteLengthQueuingStrategyPrototype);
initializeByteLengthSizeFunction(this[_globalObject]);
return WeakMapPrototypeGet(byteSizeFunctionWeakMap, this[_globalObject]);
}
@ -4188,7 +4212,10 @@
[SymbolFor("Deno.customInspect")](inspect) {
return inspect(consoleInternal.createFilteredInspectProxy({
object: this,
evaluate: this instanceof ByteLengthQueuingStrategy,
evaluate: ObjectPrototypeIsPrototypeOf(
ByteLengthQueuingStrategyPrototype,
this,
),
keys: [
"highWaterMark",
"size",
@ -4198,6 +4225,8 @@
}
webidl.configurePrototype(ByteLengthQueuingStrategy);
const ByteLengthQueuingStrategyPrototype =
ByteLengthQueuingStrategy.prototype;
/** @type {WeakMap<typeof globalThis, (chunk: ArrayBufferView) => number>} */
const byteSizeFunctionWeakMap = new WeakMap();
@ -4226,13 +4255,13 @@
/** @returns {number} */
get highWaterMark() {
webidl.assertBranded(this, CountQueuingStrategy);
webidl.assertBranded(this, CountQueuingStrategyPrototype);
return this[_highWaterMark];
}
/** @returns {(chunk: any) => 1} */
get size() {
webidl.assertBranded(this, CountQueuingStrategy);
webidl.assertBranded(this, CountQueuingStrategyPrototype);
initializeCountSizeFunction(this[_globalObject]);
return WeakMapPrototypeGet(countSizeFunctionWeakMap, this[_globalObject]);
}
@ -4240,7 +4269,10 @@
[SymbolFor("Deno.customInspect")](inspect) {
return inspect(consoleInternal.createFilteredInspectProxy({
object: this,
evaluate: this instanceof CountQueuingStrategy,
evaluate: ObjectPrototypeIsPrototypeOf(
CountQueuingStrategyPrototype,
this,
),
keys: [
"highWaterMark",
"size",
@ -4250,6 +4282,7 @@
}
webidl.configurePrototype(CountQueuingStrategy);
const CountQueuingStrategyPrototype = CountQueuingStrategy.prototype;
/** @type {WeakMap<typeof globalThis, () => 1>} */
const countSizeFunctionWeakMap = new WeakMap();
@ -4333,7 +4366,7 @@
/** @returns {boolean} */
get locked() {
webidl.assertBranded(this, ReadableStream);
webidl.assertBranded(this, ReadableStreamPrototype);
return isReadableStreamLocked(this);
}
@ -4343,7 +4376,7 @@
*/
cancel(reason = undefined) {
try {
webidl.assertBranded(this, ReadableStream);
webidl.assertBranded(this, ReadableStreamPrototype);
if (reason !== undefined) {
reason = webidl.converters.any(reason);
}
@ -4363,7 +4396,7 @@
* @returns {ReadableStreamDefaultReader<R> | ReadableStreamBYOBReader}
*/
getReader(options = {}) {
webidl.assertBranded(this, ReadableStream);
webidl.assertBranded(this, ReadableStreamPrototype);
const prefix = "Failed to execute 'getReader' on 'ReadableStream'";
options = webidl.converters.ReadableStreamGetReaderOptions(options, {
prefix,
@ -4384,7 +4417,7 @@
* @returns {ReadableStream<T>}
*/
pipeThrough(transform, options = {}) {
webidl.assertBranded(this, ReadableStream);
webidl.assertBranded(this, ReadableStreamPrototype);
const prefix = "Failed to execute 'pipeThrough' on 'ReadableStream'";
webidl.requiredArguments(arguments.length, 1, { prefix });
transform = webidl.converters.ReadableWritablePair(transform, {
@ -4422,7 +4455,7 @@
*/
pipeTo(destination, options = {}) {
try {
webidl.assertBranded(this, ReadableStream);
webidl.assertBranded(this, ReadableStreamPrototype);
const prefix = "Failed to execute 'pipeTo' on 'ReadableStream'";
webidl.requiredArguments(arguments.length, 1, { prefix });
destination = webidl.converters.WritableStream(destination, {
@ -4459,7 +4492,7 @@
/** @returns {[ReadableStream<R>, ReadableStream<R>]} */
tee() {
webidl.assertBranded(this, ReadableStream);
webidl.assertBranded(this, ReadableStreamPrototype);
return readableStreamTee(this, false);
}
@ -4469,7 +4502,7 @@
* @returns {AsyncIterableIterator<R>}
*/
values(options = {}) {
webidl.assertBranded(this, ReadableStream);
webidl.assertBranded(this, ReadableStreamPrototype);
const prefix = "Failed to execute 'values' on 'ReadableStream'";
options = webidl.converters.ReadableStreamIteratorOptions(options, {
prefix,
@ -4498,6 +4531,7 @@
});
webidl.configurePrototype(ReadableStream);
const ReadableStreamPrototype = ReadableStream.prototype;
function errorReadableStream(stream, e) {
readableStreamDefaultControllerError(stream[_controller], e);
@ -4527,7 +4561,7 @@
/** @returns {Promise<ReadableStreamReadResult<R>>} */
read() {
try {
webidl.assertBranded(this, ReadableStreamDefaultReader);
webidl.assertBranded(this, ReadableStreamDefaultReaderPrototype);
} catch (err) {
return PromiseReject(err);
}
@ -4556,7 +4590,7 @@
/** @returns {void} */
releaseLock() {
webidl.assertBranded(this, ReadableStreamDefaultReader);
webidl.assertBranded(this, ReadableStreamDefaultReaderPrototype);
if (this[_stream] === undefined) {
return;
}
@ -4565,7 +4599,7 @@
get closed() {
try {
webidl.assertBranded(this, ReadableStreamDefaultReader);
webidl.assertBranded(this, ReadableStreamDefaultReaderPrototype);
} catch (err) {
return PromiseReject(err);
}
@ -4578,7 +4612,7 @@
*/
cancel(reason = undefined) {
try {
webidl.assertBranded(this, ReadableStreamDefaultReader);
webidl.assertBranded(this, ReadableStreamDefaultReaderPrototype);
if (reason !== undefined) {
reason = webidl.converters.any(reason);
}
@ -4600,6 +4634,8 @@
}
webidl.configurePrototype(ReadableStreamDefaultReader);
const ReadableStreamDefaultReaderPrototype =
ReadableStreamDefaultReader.prototype;
/** @template R */
class ReadableStreamBYOBReader {
@ -4628,7 +4664,7 @@
*/
read(view) {
try {
webidl.assertBranded(this, ReadableStreamBYOBReader);
webidl.assertBranded(this, ReadableStreamBYOBReaderPrototype);
const prefix = "Failed to execute 'read' on 'ReadableStreamBYOBReader'";
view = webidl.converters.ArrayBufferView(view, {
prefix,
@ -4678,7 +4714,7 @@
/** @returns {void} */
releaseLock() {
webidl.assertBranded(this, ReadableStreamBYOBReader);
webidl.assertBranded(this, ReadableStreamBYOBReaderPrototype);
if (this[_stream] === undefined) {
return;
}
@ -4687,7 +4723,7 @@
get closed() {
try {
webidl.assertBranded(this, ReadableStreamBYOBReader);
webidl.assertBranded(this, ReadableStreamBYOBReaderPrototype);
} catch (err) {
return PromiseReject(err);
}
@ -4700,7 +4736,7 @@
*/
cancel(reason = undefined) {
try {
webidl.assertBranded(this, ReadableStreamBYOBReader);
webidl.assertBranded(this, ReadableStreamBYOBReaderPrototype);
if (reason !== undefined) {
reason = webidl.converters.any(reason);
}
@ -4722,6 +4758,7 @@
}
webidl.configurePrototype(ReadableStreamBYOBReader);
const ReadableStreamBYOBReaderPrototype = ReadableStreamBYOBReader.prototype;
class ReadableStreamBYOBRequest {
/** @type {ReadableByteStreamController} */
@ -4731,7 +4768,7 @@
/** @returns {ArrayBufferView | null} */
get view() {
webidl.assertBranded(this, ReadableStreamBYOBRequest);
webidl.assertBranded(this, ReadableStreamBYOBRequestPrototype);
return this[_view];
}
@ -4740,7 +4777,7 @@
}
respond(bytesWritten) {
webidl.assertBranded(this, ReadableStreamBYOBRequest);
webidl.assertBranded(this, ReadableStreamBYOBRequestPrototype);
const prefix =
"Failed to execute 'respond' on 'ReadableStreamBYOBRequest'";
webidl.requiredArguments(arguments.length, 1, { prefix });
@ -4764,7 +4801,7 @@
}
respondWithNewView(view) {
webidl.assertBranded(this, ReadableStreamBYOBRequest);
webidl.assertBranded(this, ReadableStreamBYOBRequestPrototype);
const prefix =
"Failed to execute 'respondWithNewView' on 'ReadableStreamBYOBRequest'";
webidl.requiredArguments(arguments.length, 1, { prefix });
@ -4786,6 +4823,8 @@
}
webidl.configurePrototype(ReadableStreamBYOBRequest);
const ReadableStreamBYOBRequestPrototype =
ReadableStreamBYOBRequest.prototype;
class ReadableByteStreamController {
/** @type {number | undefined} */
@ -4821,19 +4860,19 @@
/** @returns {ReadableStreamBYOBRequest | null} */
get byobRequest() {
webidl.assertBranded(this, ReadableByteStreamController);
webidl.assertBranded(this, ReadableByteStreamControllerPrototype);
return readableByteStreamControllerGetBYOBRequest(this);
}
/** @returns {number | null} */
get desiredSize() {
webidl.assertBranded(this, ReadableByteStreamController);
webidl.assertBranded(this, ReadableByteStreamControllerPrototype);
return readableByteStreamControllerGetDesiredSize(this);
}
/** @returns {void} */
close() {
webidl.assertBranded(this, ReadableByteStreamController);
webidl.assertBranded(this, ReadableByteStreamControllerPrototype);
if (this[_closeRequested] === true) {
throw new TypeError("Closed already requested.");
}
@ -4850,7 +4889,7 @@
* @returns {void}
*/
enqueue(chunk) {
webidl.assertBranded(this, ReadableByteStreamController);
webidl.assertBranded(this, ReadableByteStreamControllerPrototype);
const prefix =
"Failed to execute 'enqueue' on 'ReadableByteStreamController'";
webidl.requiredArguments(arguments.length, 1, { prefix });
@ -4890,7 +4929,7 @@
* @returns {void}
*/
error(e = undefined) {
webidl.assertBranded(this, ReadableByteStreamController);
webidl.assertBranded(this, ReadableByteStreamControllerPrototype);
if (e !== undefined) {
e = webidl.converters.any(e);
}
@ -4900,7 +4939,10 @@
[SymbolFor("Deno.customInspect")](inspect) {
return inspect(consoleInternal.createFilteredInspectProxy({
object: this,
evaluate: this instanceof ReadableByteStreamController,
evaluate: ObjectPrototypeIsPrototypeOf(
ReadableByteStreamControllerPrototype,
this,
),
keys: ["desiredSize"],
}));
}
@ -4967,6 +5009,8 @@
}
webidl.configurePrototype(ReadableByteStreamController);
const ReadableByteStreamControllerPrototype =
ReadableByteStreamController.prototype;
/** @template R */
class ReadableStreamDefaultController {
@ -4999,13 +5043,13 @@
/** @returns {number | null} */
get desiredSize() {
webidl.assertBranded(this, ReadableStreamDefaultController);
webidl.assertBranded(this, ReadableStreamDefaultControllerPrototype);
return readableStreamDefaultControllerGetDesiredSize(this);
}
/** @returns {void} */
close() {
webidl.assertBranded(this, ReadableStreamDefaultController);
webidl.assertBranded(this, ReadableStreamDefaultControllerPrototype);
if (readableStreamDefaultControllerCanCloseOrEnqueue(this) === false) {
throw new TypeError("The stream controller cannot close or enqueue.");
}
@ -5017,7 +5061,7 @@
* @returns {void}
*/
enqueue(chunk = undefined) {
webidl.assertBranded(this, ReadableStreamDefaultController);
webidl.assertBranded(this, ReadableStreamDefaultControllerPrototype);
if (chunk !== undefined) {
chunk = webidl.converters.any(chunk);
}
@ -5032,7 +5076,7 @@
* @returns {void}
*/
error(e = undefined) {
webidl.assertBranded(this, ReadableStreamDefaultController);
webidl.assertBranded(this, ReadableStreamDefaultControllerPrototype);
if (e !== undefined) {
e = webidl.converters.any(e);
}
@ -5042,7 +5086,10 @@
[SymbolFor("Deno.customInspect")](inspect) {
return inspect(consoleInternal.createFilteredInspectProxy({
object: this,
evaluate: this instanceof ReadableStreamDefaultController,
evaluate: ObjectPrototypeIsPrototypeOf(
ReadableStreamDefaultController.prototype,
this,
),
keys: ["desiredSize"],
}));
}
@ -5085,6 +5132,8 @@
}
webidl.configurePrototype(ReadableStreamDefaultController);
const ReadableStreamDefaultControllerPrototype =
ReadableStreamDefaultController.prototype;
/**
* @template I
@ -5186,13 +5235,13 @@
/** @returns {ReadableStream<O>} */
get readable() {
webidl.assertBranded(this, TransformStream);
webidl.assertBranded(this, TransformStreamPrototype);
return this[_readable];
}
/** @returns {WritableStream<I>} */
get writable() {
webidl.assertBranded(this, TransformStream);
webidl.assertBranded(this, TransformStreamPrototype);
return this[_writable];
}
@ -5204,6 +5253,7 @@
}
webidl.configurePrototype(TransformStream);
const TransformStreamPrototype = TransformStream.prototype;
/** @template O */
class TransformStreamDefaultController {
@ -5220,7 +5270,7 @@
/** @returns {number | null} */
get desiredSize() {
webidl.assertBranded(this, TransformStreamDefaultController);
webidl.assertBranded(this, TransformStreamDefaultController.prototype);
const readableController = this[_stream][_readable][_controller];
return readableStreamDefaultControllerGetDesiredSize(
/** @type {ReadableStreamDefaultController<O>} */ readableController,
@ -5232,7 +5282,7 @@
* @returns {void}
*/
enqueue(chunk = undefined) {
webidl.assertBranded(this, TransformStreamDefaultController);
webidl.assertBranded(this, TransformStreamDefaultController.prototype);
if (chunk !== undefined) {
chunk = webidl.converters.any(chunk);
}
@ -5244,7 +5294,7 @@
* @returns {void}
*/
error(reason = undefined) {
webidl.assertBranded(this, TransformStreamDefaultController);
webidl.assertBranded(this, TransformStreamDefaultController.prototype);
if (reason !== undefined) {
reason = webidl.converters.any(reason);
}
@ -5253,20 +5303,25 @@
/** @returns {void} */
terminate() {
webidl.assertBranded(this, TransformStreamDefaultController);
webidl.assertBranded(this, TransformStreamDefaultControllerPrototype);
transformStreamDefaultControllerTerminate(this);
}
[SymbolFor("Deno.customInspect")](inspect) {
return inspect(consoleInternal.createFilteredInspectProxy({
object: this,
evaluate: this instanceof TransformStreamDefaultController,
evaluate: ObjectPrototypeIsPrototypeOf(
TransformStreamDefaultController.prototype,
this,
),
keys: ["desiredSize"],
}));
}
}
webidl.configurePrototype(TransformStreamDefaultController);
const TransformStreamDefaultControllerPrototype =
TransformStreamDefaultController.prototype;
/** @template W */
class WritableStream {
@ -5336,7 +5391,7 @@
/** @returns {boolean} */
get locked() {
webidl.assertBranded(this, WritableStream);
webidl.assertBranded(this, WritableStreamPrototype);
return isWritableStreamLocked(this);
}
@ -5346,7 +5401,7 @@
*/
abort(reason = undefined) {
try {
webidl.assertBranded(this, WritableStream);
webidl.assertBranded(this, WritableStreamPrototype);
} catch (err) {
return PromiseReject(err);
}
@ -5366,7 +5421,7 @@
/** @returns {Promise<void>} */
close() {
try {
webidl.assertBranded(this, WritableStream);
webidl.assertBranded(this, WritableStreamPrototype);
} catch (err) {
return PromiseReject(err);
}
@ -5387,7 +5442,7 @@
/** @returns {WritableStreamDefaultWriter<W>} */
getWriter() {
webidl.assertBranded(this, WritableStream);
webidl.assertBranded(this, WritableStreamPrototype);
return acquireWritableStreamDefaultWriter(this);
}
@ -5397,6 +5452,7 @@
}
webidl.configurePrototype(WritableStream);
const WritableStreamPrototype = WritableStream.prototype;
/** @template W */
class WritableStreamDefaultWriter {
@ -5426,7 +5482,7 @@
/** @returns {Promise<void>} */
get closed() {
try {
webidl.assertBranded(this, WritableStreamDefaultWriter);
webidl.assertBranded(this, WritableStreamDefaultWriterPrototype);
} catch (err) {
return PromiseReject(err);
}
@ -5435,7 +5491,7 @@
/** @returns {number} */
get desiredSize() {
webidl.assertBranded(this, WritableStreamDefaultWriter);
webidl.assertBranded(this, WritableStreamDefaultWriterPrototype);
if (this[_stream] === undefined) {
throw new TypeError(
"A writable stream is not associated with the writer.",
@ -5447,7 +5503,7 @@
/** @returns {Promise<void>} */
get ready() {
try {
webidl.assertBranded(this, WritableStreamDefaultWriter);
webidl.assertBranded(this, WritableStreamDefaultWriterPrototype);
} catch (err) {
return PromiseReject(err);
}
@ -5460,7 +5516,7 @@
*/
abort(reason = undefined) {
try {
webidl.assertBranded(this, WritableStreamDefaultWriter);
webidl.assertBranded(this, WritableStreamDefaultWriterPrototype);
} catch (err) {
return PromiseReject(err);
}
@ -5478,7 +5534,7 @@
/** @returns {Promise<void>} */
close() {
try {
webidl.assertBranded(this, WritableStreamDefaultWriter);
webidl.assertBranded(this, WritableStreamDefaultWriterPrototype);
} catch (err) {
return PromiseReject(err);
}
@ -5498,7 +5554,7 @@
/** @returns {void} */
releaseLock() {
webidl.assertBranded(this, WritableStreamDefaultWriter);
webidl.assertBranded(this, WritableStreamDefaultWriterPrototype);
const stream = this[_stream];
if (stream === undefined) {
return;
@ -5513,7 +5569,7 @@
*/
write(chunk = undefined) {
try {
webidl.assertBranded(this, WritableStreamDefaultWriter);
webidl.assertBranded(this, WritableStreamDefaultWriterPrototype);
if (chunk !== undefined) {
chunk = webidl.converters.any(chunk);
}
@ -5531,7 +5587,10 @@
[SymbolFor("Deno.customInspect")](inspect) {
return inspect(consoleInternal.createFilteredInspectProxy({
object: this,
evaluate: this instanceof WritableStreamDefaultWriter,
evaluate: ObjectPrototypeIsPrototypeOf(
WritableStreamDefaultWriter.prototype,
this,
),
keys: [
"closed",
"desiredSize",
@ -5542,6 +5601,8 @@
}
webidl.configurePrototype(WritableStreamDefaultWriter);
const WritableStreamDefaultWriterPrototype =
WritableStreamDefaultWriter.prototype;
/** @template W */
class WritableStreamDefaultController {
@ -5567,7 +5628,7 @@
[_signal];
get signal() {
webidl.assertBranded(this, WritableStreamDefaultController);
webidl.assertBranded(this, WritableStreamDefaultControllerPrototype);
return this[_signal];
}
@ -5580,7 +5641,7 @@
* @returns {void}
*/
error(e = undefined) {
webidl.assertBranded(this, WritableStreamDefaultController);
webidl.assertBranded(this, WritableStreamDefaultControllerPrototype);
if (e !== undefined) {
e = webidl.converters.any(e);
}
@ -5594,7 +5655,10 @@
[SymbolFor("Deno.customInspect")](inspect) {
return inspect(consoleInternal.createFilteredInspectProxy({
object: this,
evaluate: this instanceof WritableStreamDefaultController,
evaluate: ObjectPrototypeIsPrototypeOf(
WritableStreamDefaultController.prototype,
this,
),
keys: [],
}));
}
@ -5615,6 +5679,8 @@
}
webidl.configurePrototype(WritableStreamDefaultController);
const WritableStreamDefaultControllerPrototype =
WritableStreamDefaultController.prototype;
/**
* @param {ReadableStream} stream
@ -5624,9 +5690,9 @@
}
webidl.converters.ReadableStream = webidl
.createInterfaceConverter("ReadableStream", ReadableStream);
.createInterfaceConverter("ReadableStream", ReadableStream.prototype);
webidl.converters.WritableStream = webidl
.createInterfaceConverter("WritableStream", WritableStream);
.createInterfaceConverter("WritableStream", WritableStream.prototype);
webidl.converters.ReadableStreamType = webidl.createEnumConverter(
"ReadableStreamType",
@ -5787,6 +5853,7 @@
ByteLengthQueuingStrategy,
CountQueuingStrategy,
ReadableStream,
ReadableStreamPrototype,
ReadableStreamDefaultReader,
TransformStream,
WritableStream,