Streams
Manage data streams, queuing strategies, and transformations. Handle data in chunks, process large datasets, and optimize memory usage.
Interfaces
This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams.
This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object.
This Streams API interface represents a controller allowing control of a WritableStream's state. When constructing a WritableStream, the underlying sink is given a corresponding WritableStreamDefaultController instance to manipulate.
This Streams API interface is the object returned by WritableStream.getWriter() and once created locks the < writer to the WritableStream ensuring that no other streams can write to the underlying sink.
Type Aliases
interface ByteLengthQueuingStrategy
Properties #
#highWaterMark: number #size: QueuingStrategySize<ArrayBufferView> variable ByteLengthQueuingStrategy
The constructor object for ByteLengthQueuingStrategy, used to
create a queuing strategy that measures each chunk by its byteLength toward
the stream's high water mark.
Properties #
#prototype: ByteLengthQueuingStrategy interface CompressionStream
An API for compressing a stream of data.
Examples #
await Deno.stdin.readable
.pipeThrough(new CompressionStream("gzip"))
.pipeTo(Deno.stdout.writable);
Properties #
#readable: ReadableStream<Uint8Array<ArrayBuffer>> #writable: WritableStream<BufferSource> variable CompressionStream
interface CountQueuingStrategy
This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams.
Properties #
#highWaterMark: number #size: QueuingStrategySize variable CountQueuingStrategy
The constructor object for CountQueuingStrategy, used to create a
queuing strategy that counts each chunk as a single unit toward the stream's
high water mark.
Properties #
#prototype: CountQueuingStrategy interface DecompressionStream
An API for decompressing a stream of data.
Examples #
const input = await Deno.open("./file.txt.gz");
const output = await Deno.create("./file.txt");
await input.readable
.pipeThrough(new DecompressionStream("gzip"))
.pipeTo(output.writable);
Properties #
#readable: ReadableStream<Uint8Array<ArrayBuffer>> #writable: WritableStream<BufferSource> variable DecompressionStream
interface GenericTransformStream
Properties #
#readable: ReadableStream #writable: WritableStream interface QueuingStrategy
Type Parameters #
#T = any Properties #
#highWaterMark: number #size: QueuingStrategySize<T> interface QueuingStrategyInit
Properties #
#highWaterMark: number interface QueuingStrategySize
interface ReadableByteStreamController
Properties #
#byobRequest: ReadableStreamBYOBRequest | null #desiredSize: number | null Methods #
variable ReadableByteStreamController
The constructor object for ReadableByteStreamController.
Instances are passed to a byte-oriented ReadableStream's
underlying source callbacks rather than constructed directly, so calling the
constructor throws.
Properties #
#prototype: ReadableByteStreamController interface ReadableStream
This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object.
Type Parameters #
#R = any Properties #
Methods #
#getReader(options: { mode: "byob"; }): ReadableStreamBYOBReader #getReader(options?: ReadableStreamGetReaderOptions): ReadableStreamReader<R> #pipeThrough<T>(transform: ReadableWritablePair<T, R>,options?: StreamPipeOptions,): ReadableStream<T> #pipeTo(destination: WritableStream<R>,options?: StreamPipeOptions,): Promise<void> #tee(): [ReadableStream<R>, ReadableStream<R>] #values(options?: ReadableStreamIteratorOptions): AsyncIterableIterator<R> #[[Symbol.asyncIterator]](options?: ReadableStreamIteratorOptions): AsyncIterableIterator<R> variable ReadableStream
The constructor object for ReadableStream, used to create a
readable stream from an underlying source describing how data is enqueued and
consumed.
Properties #
#prototype: ReadableStream Methods #
#from<R>(asyncIterable: AsyncIterable<R> | Iterable<R | PromiseLike<R>> & object): ReadableStream<R> interface ReadableStreamBYOBReader
Methods #
#read<T extends ArrayBufferView>(view: T,options?: ReadableStreamBYOBReaderReadOptions,): Promise<ReadableStreamReadResult<T>> #releaseLock(): void variable ReadableStreamBYOBReader
The constructor object for ReadableStreamBYOBReader, used to
create a "bring your own buffer" reader locked to the given byte stream. Most
code obtains one via ReadableStream.getReader({ mode: "byob" }) instead.
Properties #
#prototype: ReadableStreamBYOBReader interface ReadableStreamBYOBReaderReadOptions
interface ReadableStreamBYOBRequest
Properties #
#view: Uint8Array<ArrayBuffer> | null Methods #
#respondWithNewView(view: ArrayBufferView): void variable ReadableStreamBYOBRequest
The constructor object for ReadableStreamBYOBRequest.
Instances are provided to a byte stream's controller rather than constructed directly, so calling the constructor throws.
Properties #
#prototype: ReadableStreamBYOBRequest interface ReadableStreamDefaultController
variable ReadableStreamDefaultController
The constructor object for ReadableStreamDefaultController.
Instances are passed to a ReadableStream's underlying source
callbacks rather than constructed directly, so calling the constructor
throws.
Properties #
#prototype: ReadableStreamDefaultController interface ReadableStreamDefaultReader
Type Parameters #
#R = any Methods #
#read(): Promise<ReadableStreamReadResult<R>> #releaseLock(): void variable ReadableStreamDefaultReader
The constructor object for ReadableStreamDefaultReader, used to
create a default reader locked to the given ReadableStream. Most
code obtains one via ReadableStream.getReader instead.
Properties #
#prototype: ReadableStreamDefaultReader interface ReadableStreamGetReaderOptions
Properties #
#mode: ReadableStreamReaderMode interface ReadableStreamIteratorOptions
Properties #
#preventCancel: boolean interface ReadableWritablePair
interface StreamPipeOptions
Properties #
#preventAbort: boolean #preventCancel: boolean #preventClose: boolean #signal: AbortSignal interface Transformer
Type Parameters #
Properties #
#flush: TransformerFlushCallback<O> #readableType: undefined #start: TransformerStartCallback<O> #transform: TransformerTransformCallback<I, O> #cancel: TransformerCancelCallback #writableType: undefined interface TransformerCancelCallback
Call Signatures #
(reason: any): void | PromiseLike<void> interface TransformerFlushCallback
Type Parameters #
#O Call Signatures #
(controller: TransformStreamDefaultController<O>): void | PromiseLike<void> interface TransformerStartCallback
Type Parameters #
#O Call Signatures #
(controller: TransformStreamDefaultController<O>): any interface TransformerTransformCallback
interface TransformStream
variable TransformStream
The constructor object for TransformStream, used to create a
transform stream from a transformer describing how chunks read from its
writable side are transformed before appearing on its readable side.
Properties #
#prototype: TransformStream interface TransformStreamDefaultController
variable TransformStreamDefaultController
The constructor object for TransformStreamDefaultController.
Instances are passed to a TransformStream's transformer callbacks
rather than constructed directly, so calling the constructor throws.
Properties #
#prototype: TransformStreamDefaultController interface UnderlyingByteSource
Properties #
#autoAllocateChunkSize: number #cancel: UnderlyingSourceCancelCallback #pull: (controller: ReadableByteStreamController) => void | PromiseLike<void> #start: (controller: ReadableByteStreamController) => any interface UnderlyingDefaultSource
interface UnderlyingSink
Type Parameters #
#W = any Properties #
#abort: UnderlyingSinkAbortCallback #close: UnderlyingSinkCloseCallback #start: UnderlyingSinkStartCallback #write: UnderlyingSinkWriteCallback<W> interface UnderlyingSinkAbortCallback
Call Signatures #
(reason?: any): void | PromiseLike<void> interface UnderlyingSinkCloseCallback
Call Signatures #
(): void | PromiseLike<void> interface UnderlyingSinkStartCallback
Call Signatures #
(controller: WritableStreamDefaultController): any interface UnderlyingSinkWriteCallback
Type Parameters #
#W Call Signatures #
(chunk: W,controller: WritableStreamDefaultController,): void | PromiseLike<void> interface UnderlyingSource
Type Parameters #
#R = any Properties #
#autoAllocateChunkSize: number #cancel: UnderlyingSourceCancelCallback #pull: UnderlyingSourcePullCallback<R> #start: UnderlyingSourceStartCallback<R> #type: ReadableStreamType interface UnderlyingSourceCancelCallback
Call Signatures #
(reason?: any): void | PromiseLike<void> interface UnderlyingSourcePullCallback
Type Parameters #
#R Call Signatures #
(controller: ReadableStreamController<R>): void | PromiseLike<void> interface UnderlyingSourceStartCallback
Type Parameters #
#R Call Signatures #
(controller: ReadableStreamController<R>): any interface WritableStream
variable WritableStream
The constructor object for WritableStream, used to create a
writable stream from an underlying sink describing how written chunks are
handled.
Properties #
#prototype: WritableStream interface WritableStreamDefaultController
This Streams API interface represents a controller allowing control of a WritableStream's state. When constructing a WritableStream, the underlying sink is given a corresponding WritableStreamDefaultController instance to manipulate.
Properties #
#signal: AbortSignal Methods #
variable WritableStreamDefaultController
The constructor object for WritableStreamDefaultController.
Instances are passed to a WritableStream's underlying sink
callbacks rather than constructed directly, so calling the constructor
throws.
Properties #
#prototype: WritableStreamDefaultController interface WritableStreamDefaultWriter
variable WritableStreamDefaultWriter
The constructor object for WritableStreamDefaultWriter, used to
create a writer locked to the given WritableStream. Most code
obtains one via WritableStream.getWriter instead.
Properties #
#prototype: WritableStreamDefaultWriter type alias CompressionFormat
Definition #
"deflate"
| "deflate-raw"
| "gzip"
| "brotli" type alias ReadableStreamController
type alias ReadableStreamReader
type alias ReadableStreamReaderMode
Definition #
"byob" type alias ReadableStreamReadResult
type alias ReadableStreamType
Definition #
"bytes"