Browse API packages

API · v0.13.0

stream

Standard library streams

Member signatures use schematic object.member(...) API notation. Exported type declarations are valid TypeScript.

Utilities for consuming web streams.

These utilities use standard ReadableStream and encoding APIs available in current browsers, Node, Deno, and Bun.

ts
import stream from "@rcompat/stream";

stream.stringify#

Reads a byte stream and decodes its complete contents as UTF-8 text.

Multibyte characters remain intact when their bytes span chunks. Streams returned by FileRef.stream() and methods keyed by @rcompat/symbol.stream are compatible.

Parameters

  • input — The byte stream to consume.

Returns: The complete decoded text.

Throws: If input is not a ReadableStream instance.

ts
stream.stringify(input: ReadableStream<Uint8Array>): Promise<string>;

Example

ts
const response = new Response("Hello");
await stream.stringify(response.body!); // "Hello"