API · Consume
toArray()
Run the stream to completion and resolve with every output value.
Example
const rows = await exstream(response.body).csv({ header: true }).toArray() Behavior
toArray() is terminal and starts demand immediately. It always returns a promise, including for a completely synchronous pipeline. Normal completion resolves with values in output order, or [] for an empty stream.
The promise rejects on the first unhandled record error, fatal failure, or abort.
Buffering
toArray() retains every output value until the stream ends because the resolved result is one complete array. Memory grows linearly with output size, and an unbounded stream can neither resolve nor release that accumulated output.
Use drain() when values can be discarded, pipeTo() when they have a destination, or async iteration to process them incrementally.
Signature
toArray(): Promise<T[]>