API · Low level

write()

Push one data value, record error, or end marker into a manually writable Exstream.

Signature

write(value: T | Error | DataValue<T> | typeof exstream.nil): boolean

Example

const source = exstream()
const result = source.map(transform).toPromise()

if (!source.write(row)) await new Promise((resolve) => source.once('drain', resolve))
source.end()

Value protocol

Ordinary values are data. An Error becomes a recoverable record error. exstream.nil ends the stream. exstream.data(error) forces an Error object to travel as data; writeData() is the direct alternative.

The boolean reports whether writing may continue without waiting. false means the stream is paused or the configured best-effort overflow policy rejected the new value. A producer should wait for drain before continuing. With overflow: 'error', exceeding bufferLimit throws BufferOverflowError; drop policies update dropped.

Lifecycle

Writes may buffer while paused. Calling write() after end/nil throws Cannot write to stream after nil. write() does not automatically end a source.

Forms

write() is instance-only and intended for manually writable sources and adapters.

writeData(), end(), pause(), Create a source