ReadableStream
Represents a readable stream of data.Constructor
Object defining the stream’s data source:
start(controller): Called immediately when the stream is constructedpull(controller): Called when the consumer requests more datacancel(reason): Called when the stream is cancelledtype: Either"bytes"for a byte stream or omit for a default streamautoAllocateChunkSize: For byte streams, the size of automatically allocated buffers
Strategy for managing the stream’s internal queue:
highWaterMark: Maximum size of the internal queuesize(chunk): Function to compute the size of each chunk
Properties
True if the stream is locked to a reader.
Methods
Acquire a reader for the stream.
Pipe the stream to a WritableStream.
Pipe the stream through a TransformStream.
Split the stream into two branches.
Cancel the stream.
Get an async iterator for the stream.
ReadableStreamDefaultReader
Reader for ReadableStream.Methods
Read the next chunk from the stream.Returns:
{ done: false, value: R }when data is available{ done: true, value: undefined }when the stream is closed
Release the reader’s lock on the stream.
Cancel the stream.
WritableStream
Represents a writable stream of data.Constructor
Object defining the stream’s destination:
start(controller): Called immediately when the stream is constructedwrite(chunk, controller): Called when a new chunk is ready to be writtenclose(): Called when the stream is closedabort(reason): Called when the stream is aborted
Strategy for managing the stream’s internal queue.
Properties
True if the stream is locked to a writer.
Methods
Acquire a writer for the stream.
Abort the stream.
Close the stream.
WritableStreamDefaultWriter
Writer for WritableStream.Properties
The desired size of the stream’s internal queue.
Promise that resolves when the writer is ready to accept writes.
Promise that resolves when the stream is closed.
Methods
Write a chunk to the stream.
Close the writer.
Abort the stream.
Release the writer’s lock on the stream.
TransformStream
Represents a transform stream that modifies data as it passes through.Constructor
Object defining the transformation:
start(controller): Called when the stream is constructedtransform(chunk, controller): Called for each chunkflush(controller): Called when all chunks have been written
Properties
The readable side of the transform stream.
The writable side of the transform stream.
Compression streams
Transform stream that compresses data.
Transform stream that decompresses data.
Text encoding streams
Transform stream that encodes strings to UTF-8 bytes.
Transform stream that decodes UTF-8 bytes to strings.
Queuing strategies
Queuing strategy that uses byte length for sizing.
Queuing strategy that counts chunks.