API · Consume
toWebReadable()
Expose Exstream output as a pull-based Web `ReadableStream`.
Signature
interface ToWebReadableOptions {
signal?: AbortSignal
strategy?: QueuingStrategy<unknown>
}
toWebReadable(options?: ToWebReadableOptions | null): ReadableStream<T> Example
const body = exstream(rows).jsonlStringify().toWebReadable()
return new Response(body, { headers: { 'content-type': 'application/x-ndjson' } }) Parameters
signalAborts the underlying async iterator and Exstream branch.
strategyPassed as the native ReadableStream queuing strategy.
Demand and lifecycle
Each native pull() requests one Exstream value through toAsyncIterator(), so reader demand controls upstream work. Normal Exstream end closes the readable. A record or fatal error errors the native stream. Reader cancellation without a reason destroys the iterator cleanly; cancellation with a reason aborts the Exstream graph with that reason.
The method requires a global ReadableStream constructor and otherwise throws. It works in modern browsers and compatible Node runtimes.
Forms
stream.toWebReadable({ signal })
exstream.toWebReadable({ signal }, stream)
exstream.toWebReadable({ signal })(stream)