ReadableByteStreamController.js [plain text]
function initializeReadableByteStreamController(stream, underlyingByteSource, highWaterMark)
{
"use strict";
if (arguments.length !== 4 && arguments[3] !== @isReadableStream)
@throwTypeError("ReadableByteStreamController constructor should not be called directly");
return @privateInitializeReadableByteStreamController.@call(this, stream, underlyingByteSource, highWaterMark);
}
function enqueue(chunk)
{
"use strict";
if (!@isReadableByteStreamController(this))
throw @makeThisTypeError("ReadableByteStreamController", "enqueue");
if (@getByIdDirectPrivate(this, "closeRequested"))
@throwTypeError("ReadableByteStreamController is requested to close");
if (@getByIdDirectPrivate(@getByIdDirectPrivate(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 (@getByIdDirectPrivate(@getByIdDirectPrivate(this, "controlledReadableStream"), "state") !== @streamReadable)
@throwTypeError("ReadableStream is not readable");
@readableByteStreamControllerError(this, error);
}
function close()
{
"use strict";
if (!@isReadableByteStreamController(this))
throw @makeThisTypeError("ReadableByteStreamController", "close");
if (@getByIdDirectPrivate(this, "closeRequested"))
@throwTypeError("Close has already been requested");
if (@getByIdDirectPrivate(@getByIdDirectPrivate(this, "controlledReadableStream"), "state") !== @streamReadable)
@throwTypeError("ReadableStream is not readable");
@readableByteStreamControllerClose(this);
}
@getter
function byobRequest()
{
"use strict";
if (!@isReadableByteStreamController(this))
throw @makeGetterTypeError("ReadableByteStreamController", "byobRequest");
if (@getByIdDirectPrivate(this, "byobRequest") === @undefined && @getByIdDirectPrivate(this, "pendingPullIntos").length) {
const firstDescriptor = @getByIdDirectPrivate(this, "pendingPullIntos")[0];
const view = new @Uint8Array(firstDescriptor.buffer,
firstDescriptor.byteOffset + firstDescriptor.bytesFilled,
firstDescriptor.byteLength - firstDescriptor.bytesFilled);
@putByIdDirectPrivate(this, "byobRequest", new @ReadableStreamBYOBRequest(this, view, @isReadableStream));
}
return @getByIdDirectPrivate(this, "byobRequest");
}
@getter
function desiredSize()
{
"use strict";
if (!@isReadableByteStreamController(this))
throw @makeGetterTypeError("ReadableByteStreamController", "desiredSize");
return @readableByteStreamControllerGetDesiredSize(this);
}