API · Low level

pull()

Attach a one-record consumer and request the next data, error, or end record.

Signature

pull(): Promise<T | typeof exstream.nil>
pull(fn: (error: ExstreamError<T> | null | undefined, value: T | typeof exstream.nil, context?: C) => void): void

Example

const value = await stream.pull()
if (value !== exstream.nil) console.log(value)

Behavior

Each call creates a temporary synchronous consumer, resumes it, removes it after one protocol record, and leaves the stream available for a later pull. Promise form resolves with data or exstream.nil and rejects on a record error. Callback form receives (error, value) and receives context only when it declares a third parameter.

An Exstream output supports one reliable consumer at a time. Do not mix pending pulls with another operator or terminal on the same branch; fork when consumers must coexist. Repeated pulls provide manual demand and therefore backpressure upstream.

toAsyncIterator(), consume(), each()