Streams

readable.read()

Pulls available data from the internal queue in paused mode. A null result means no data can be returned at that moment; it does not by itself establish end of input. Prefer async iteration when no explicit pull control is needed. Tested on Node.js 22.16.0. Example output (one line per entry): ["ab cd null"].

Formal Syntax & Structure

nodejs syntaxnodejs
readable.read([size])

Parameters & Attributes

NameTypeDescription
sizenumberRequested byte count for byte streams.

Return Value

any | null

A chunk, or null if unavailable.

Working Example

Example Snippetnodejs
import { Readable } from 'node:stream';const r = new Readable({ read() { } });r.push(Buffer.from('abcd'));r.push(null);console.log(r.read(2).toString(), r.read(2).toString(), r.read());
Node.js Reference