Spec-Zone.ru › Deno 2

Streams

Manage data streams, queuing strategies, and transformations. Handle data in chunks, process large datasets, and optimize memory usage.

Eg ReadableStream, WritableStream, TransformStream


interface ByteLengthQueuingStrategy

extends QueuingStrategy<ArrayBufferView>

Properties

highWaterMark: number
readonly
size: QueuingStrategySize<ArrayBufferView>
readonly

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
readonly

interface CompressionStream

extends GenericTransformStream

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>>
readonly
writable: WritableStream<BufferSource>
readonly

variable CompressionStream

An API for compressing a stream of data.

Examples

await Deno.stdin.readable
  .pipeThrough(new CompressionStream("gzip"))
  .pipeTo(Deno.stdout.writable);

Properties

prototype: CompressionStream
readonly

interface CountQueuingStrategy

extends QueuingStrategy

This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams.

Properties

highWaterMark: number
readonly
size: QueuingStrategySize
readonly

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
readonly

interface DecompressionStream

extends GenericTransformStream

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>>
readonly
writable: WritableStream<BufferSource>
readonly

variable 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

prototype: DecompressionStream
readonly

interface GenericTransformStream

Properties

readable: ReadableStream
readonly
writable: WritableStream
readonly

interface QueuingStrategy

Type Parameters

T = any

Properties

highWaterMark: number
optional
size: QueuingStrategySize<T>
optional

interface QueuingStrategyInit

Properties

highWaterMark: number

interface QueuingStrategySize

Type Parameters

T = any

Call Signatures

(chunk: T): number

interface ReadableByteStreamController

Properties

byobRequest: ReadableStreamBYOBRequest | null
readonly
desiredSize: number | null
readonly

Methods

close(): void
enqueue(chunk: ArrayBufferView): void
error(e?: any): void

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
readonly

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

locked: boolean
readonly

Methods

cancel(reason?: any): Promise<void>
getReader(options: { mode: "byob"; }): ReadableStreamBYOBReader
getReader(): ReadableStreamDefaultReader<R>
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
readonly

Methods

from<R>(asyncIterable: AsyncIterable<R> | Iterable<R | PromiseLike<R>> & object): ReadableStream<R>

interface ReadableStreamBYOBReader

extends ReadableStreamGenericReader

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
readonly

interface ReadableStreamBYOBReaderReadOptions

Properties

min: number
optional

interface ReadableStreamBYOBRequest

Properties

view: Uint8Array<ArrayBuffer> | null
readonly

Methods

respond(bytesWritten: number): void
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
readonly

interface ReadableStreamDefaultController

Type Parameters

R = any

Properties

desiredSize: number | null
readonly

Methods

close(): void
enqueue(chunk?: R): void
error(e?: any): void

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
readonly

interface ReadableStreamDefaultReader

extends ReadableStreamGenericReader

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
readonly

interface ReadableStreamGenericReader

Properties

closed: Promise<void>
readonly

Methods

cancel(reason?: any): Promise<void>

interface ReadableStreamGetReaderOptions

Properties

mode: ReadableStreamReaderMode
optional

interface ReadableStreamIteratorOptions

Properties

preventCancel: boolean
optional

interface ReadableStreamReadDoneResult

Type Parameters

T

Properties

done: true
value: T
optional

interface ReadableStreamReadValueResult

Type Parameters

T

Properties

done: false
value: T

interface ReadableWritablePair

Type Parameters

R = any
W = any

Properties

readable: ReadableStream<R>
writable: WritableStream<W>

interface StreamPipeOptions

Properties

preventAbort: boolean
optional
preventCancel: boolean
optional
preventClose: boolean
optional
signal: AbortSignal
optional

interface Transformer

Type Parameters

I = any
O = any

Properties

flush: TransformerFlushCallback<O>
optional
readableType: undefined
optional
start: TransformerStartCallback<O>
optional
transform: TransformerTransformCallback<I, O>
optional
cancel: TransformerCancelCallback
optional
writableType: undefined
optional

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

Type Parameters

I
O

Call Signatures

(
chunk: I,
controller: TransformStreamDefaultController<O>,
): void | PromiseLike<void>

interface TransformStream

Type Parameters

I = any
O = any

Properties

readable: ReadableStream<O>
readonly
writable: WritableStream<I>
readonly

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
readonly

interface TransformStreamDefaultController

Type Parameters

O = any

Properties

desiredSize: number | null
readonly

Methods

enqueue(chunk?: O): void
error(reason?: any): void
terminate(): void

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
readonly

interface UnderlyingByteSource

Properties

autoAllocateChunkSize: number
optional
cancel: UnderlyingSourceCancelCallback
optional
pull: (controller: ReadableByteStreamController) => void | PromiseLike<void>
optional
start: (controller: ReadableByteStreamController) => any
optional
type: "bytes"

interface UnderlyingDefaultSource

Type Parameters

R = any

Properties

cancel: UnderlyingSourceCancelCallback
optional
pull: (controller: ReadableStreamDefaultController<R>) => void | PromiseLike<void>
optional
start: (controller: ReadableStreamDefaultController<R>) => any
optional
type: undefined
optional

interface UnderlyingSink

Type Parameters

W = any

Properties

abort: UnderlyingSinkAbortCallback
optional
close: UnderlyingSinkCloseCallback
optional
start: UnderlyingSinkStartCallback
optional
type: undefined
optional
write: UnderlyingSinkWriteCallback<W>
optional

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
optional
cancel: UnderlyingSourceCancelCallback
optional
pull: UnderlyingSourcePullCallback<R>
optional
start: UnderlyingSourceStartCallback<R>
optional
type: ReadableStreamType
optional

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

This Streams API interface provides a standard abstraction for writing streaming data to a destination, known as a sink. This object comes with built-in backpressure and queuing.

Type Parameters

W = any

Properties

locked: boolean
readonly

Methods

abort(reason?: any): Promise<void>
close(): Promise<void>
getWriter(): WritableStreamDefaultWriter<W>

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
readonly

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
readonly

Methods

error(e?: any): void

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
readonly

interface WritableStreamDefaultWriter

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 Parameters

W = any

Properties

closed: Promise<void>
readonly
desiredSize: number | null
readonly
ready: Promise<void>
readonly

Methods

abort(reason?: any): Promise<void>
close(): Promise<void>
releaseLock(): void
write(chunk?: W): Promise<void>

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
readonly

type alias CompressionFormat

Definition

"deflate"
| "deflate-raw"
| "gzip"
| "brotli"

type alias ReadableStreamController

Type Parameters

T

Definition

ReadableStreamDefaultController<T> | ReadableByteStreamController

type alias ReadableStreamReader

Type Parameters

T

Definition

ReadableStreamDefaultReader<T> | ReadableStreamBYOBReader

type alias ReadableStreamReaderMode

Definition

"byob"

type alias ReadableStreamReadResult

Type Parameters

T

Definition

ReadableStreamReadValueResult<T> | ReadableStreamReadDoneResult<T>

type alias ReadableStreamType

Definition

"bytes"

© 2018–2025 the Deno authors
Licensed under the MIT License.
https://docs.deno.com/api/web/streams

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API