Streams

Readable.from()

Create a readable from a finite iterable; configure object mode explicitly for byte examples. 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.from(iterable[, options])

Parameters & Attributes

NameTypeDescription
iterableIterable | AsyncIterableFinite source for this lesson.
optionsobjectReadable options including objectMode.

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 source = Readable.from([Buffer.from('bo'), Buffer.from('ok')], {objectMode:false});let text = '';for await (const chunk of source) text += chunk.toString('ascii');console.log(text);
Node.js Reference