ReadableByteStreamController.js [plain text]
function enqueue(chunk)
{
"use strict";
if (!@isReadableByteStreamController(this))
throw @makeThisTypeError("ReadableByteStreamController", "enqueue");
if (this.@closeRequested)
@throwTypeError("ReadableByteStreamController is requested to close");
if (this.@controlledReadableStream.@state !== @streamReadable)
@throwTypeError("ReadableStream is not readable");
if (!@isObject(chunk))
@throwTypeError("Provided chunk is not an object");
if (!@ArrayBuffer.@isView(chunk))
@throwTypeError("Provided chunk is not an ArrayBuffer view");
return @readableByteStreamControllerEnqueue(this, chunk);
}
function error(error)
{
"use strict";
if (!@isReadableByteStreamController(this))
throw @makeThisTypeError("ReadableByteStreamController", "error");
if (this.@controlledReadableStream.@state !== @streamReadable)
@throwTypeError("ReadableStream is not readable");
@readableByteStreamControllerError(this, error);
}
function close()
{
"use strict";
if (!@isReadableByteStreamController(this))
throw @makeThisTypeError("ReadableByteStreamController", "close");
if (this.@closeRequested)
@throwTypeError("Close has already been requested");
if (this.@controlledReadableStream.@state !== @streamReadable)
@throwTypeError("ReadableStream is not readable");
@readableByteStreamControllerClose(this);
}
function byobRequest()
{
"use strict";
if (!@isReadableByteStreamController(this))
throw @makeGetterTypeError("ReadableByteStreamController", "byobRequest");
if (this.@byobRequest === @undefined && this.@pendingPullIntos.length) {
const firstDescriptor = this.@pendingPullIntos[0];
const view = new @Uint8Array(firstDescriptor.buffer,
firstDescriptor.byteOffset + firstDescriptor.bytesFilled,
firstDescriptor.byteLength - firstDescriptor.bytesFilled);
this.@byobRequest = new @ReadableStreamBYOBRequest(this, view);
}
return this.@byobRequest;
}
function desiredSize()
{
"use strict";
if (!@isReadableByteStreamController(this))
throw @makeGetterTypeError("ReadableByteStreamController", "desiredSize");
return @readableByteStreamControllerGetDesiredSize(this);
}