Streams

Readable.fromWeb()

Adapt a WHATWG readable for Node stream consumption; check stability and options for your release. Local Node 22.16.0; production target compatibility pending. See https://nodejs.org/download/release/v22.16.0/docs/api/stream.html.

Formal Syntax & Structure

nodejs syntaxnodejs
Readable.fromWeb(readableStream[, options])

Parameters & Attributes

NameTypeDescription
readableStreamReadableStreamWeb stream to adapt.
optionsobjectNode adapter settings.

Return Value

Readable

Result or receiver of the documented operation; see the linked versioned API contract.

Working Example

Example Snippetnodejs
import { Readable, Writable, Transform } from 'node:stream';import { pipeline, finished } from 'node:stream/promises';const web = new ReadableStream({start(c){c.enqueue(new Uint8Array([65,66]));c.close();}});const result=[];for await(const chunk of Readable.fromWeb(web)) result.push(...chunk);console.log(result.join(','));
Node.js Reference