Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/streams/mod.ts

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
import * as mod from "https://deno.land/std@0.209.0/streams/mod.ts";

Utilities for working with the Streams API.

Includes buffering and conversion.

Classes

A variable-sized buffer of bytes with read() and write() methods.

A transform stream that only transforms from the zero-indexed start and end bytes (both inclusive).

Divide a stream into chunks delimited by a given byte sequence.

A TransformStream that will only read & enqueue size amount of bytes. This operation is chunk based and not BYOB based, and as such will read more than needed.

A TransformStream that will only read & enqueue size amount of chunks.

Transform a stream into a stream where each chunk is divided by a given delimiter.

Transform a stream into a stream where each chunk is divided by a newline, be it \n or \r\n. \r can be enabled via the allowCR option.

Functions

f
copy
deprecated

Copies from src to dst until either EOF (null) is read from src or an error occurs. It resolves to the number of bytes copied or rejects with the first error encountered while copying.

Merge multiple streams into a single one, taking order into account, and each stream will wait for a chunk to enqueue before the next stream can append another chunk. If a stream ends before other ones, the others will be cancelled.

f
iterateReader
deprecated

Turns a Reader, r, into an async iterator.

Turns a ReaderSync, r, into an iterator.

Merge multiple streams into a single one, not taking order into account. If a stream ends before other ones, the other will continue adding data, and the finished one will not add any more data.

Create a ReadableStream of Uint8Arrays from a Reader.

f
readAll
deprecated

Read Reader r until EOF (null) and resolve to the content as Uint8Array.

f
readAllSync
deprecated

Synchronously reads Reader r until EOF (null) and returns the content as Uint8Array.

Create a Reader from an iterable of Uint8Arrays.

Converts a ReadableStream of Uint8Arrays to an ArrayBuffer. Works the same asResponse.arrayBuffer.

Converts a ReadableStream of strings or Uint8Arrays to a Blob. Works the same as Response.blob.

Converts a JSON-formatted ReadableSteam of strings or Uint8Arrays to an object. Works the same as Response.json.

Converts a ReadableSteam of strings or Uint8Arrays to a single string. Works the same as Response.text.

Convert the generator function into a TransformStream.

Create a WritableStream from a Writer.

f
writeAll
deprecated

Write all the content of the array buffer (arr) to the writer (w).

f
writeAllSync
deprecated

Synchronously write all the content of the array buffer (arr) to the writer (w).

Merge multiple streams into a single one, taking order into account, and each stream will wait for a chunk to enqueue before the next stream can append another chunk. If a stream ends before other ones, the others will continue adding data in order, and the finished one will not add any more data.

Interfaces

I
Closer
deprecated

An abstract interface which when implemented provides an interface to close files/resources that were previously opened.

Options for DelimiterStream.

I
Reader
deprecated

An abstract interface which when implemented provides an interface to read bytes into an array buffer asynchronously.

I
ReaderSync
deprecated

An abstract interface which when implemented provides an interface to read bytes into an array buffer synchronously.

Options for TextLineStream.

I
Writer
deprecated

An abstract interface which when implemented provides an interface to write bytes from an array buffer to a file/resource asynchronously.

I
WriterSync
deprecated

An abstract interface which when implemented provides an interface to write bytes from an array buffer to a file/resource synchronously.

Type Aliases

Disposition of the delimiter for DelimiterStreamOptions.