ReadableStreamController.js [plain text]
function enqueue(chunk)
{
"use strict";
if (!@isReadableStreamController(this))
throw new @TypeError("Function should be called on a ReadableStreamController");
const stream = this.@controlledReadableStream;
if (stream.@state === @streamErrored)
throw stream.@storedError;
if (stream.@closeRequested)
throw new @TypeError("ReadableStream is requested to close");
return @enqueueInReadableStream(stream, chunk);
}
function error(error)
{
"use strict";
if (!@isReadableStreamController(this))
throw new @TypeError("Function should be called on a ReadableStreamController");
const stream = this.@controlledReadableStream;
if (stream.@state !== @streamReadable)
throw new @TypeError("ReadableStream is not readable");
@errorReadableStream(stream, error);
}
function close()
{
"use strict";
if (!@isReadableStreamController(this))
throw new @TypeError("Function should be called on a ReadableStreamController");
const stream = this.@controlledReadableStream;
if (stream.@closeRequested)
throw new @TypeError("ReadableStream is already requested to close");
if (stream.@state === @streamErrored)
throw new @TypeError("ReadableStream is already errored");
@closeReadableStream(stream);
}
function desiredSize()
{
"use strict";
if (!@isReadableStreamController(this))
throw new @TypeError("Function should be called on a ReadableStreamController");
return @getReadableStreamDesiredSize(this.@controlledReadableStream);
}