Skip to main content

Module stream_consumers

Module stream_consumers 

Source
Expand description

Node stream/consumers module: read an entire stream to a single value.

Each function (text/json/arrayBuffer/buffer/bytes/blob) returns a Promise that settles once the stream ends. The reader is a small compiled JS factory (same re-entrant compile_completion → load_merged → run_chunk_on path util.promisify uses): it attaches data/end/error listeners on the stream’s real EventEmitter surface, accumulates chunks with Buffer.concat, and resolves the Promise on end (rejecting on error). Building it in JS means the genuine Promise + emitter machinery does the work — no bespoke native listener/accumulator.

Runtime byte container: this engine represents raw bytes as a Buffer, so arrayBuffer/bytes resolve with a Buffer (matching buffer::blob_call, which likewise resolves its arrayBuffer/bytes accessors with a Buffer rather than a bare ArrayBuffer/Uint8Array). blob resolves a real Blob.

Constants§

METHODS
The free functions exported by require('stream/consumers').

Functions§

call
Module free-function dispatch (consumers.text, consumers.json, …).