API · Async
massThen()
Call `.then()` on every promise value and emit the resulting promises.
Signature
massThen<U>(
fn: (value: ResolvedValue<T>, context: C) => U,
): Exstream<Promise<Awaited<U>>, C> Example
const names = exstream(requestPromises)
.massThen((response) => response.json())
.resolve(8, true) Parameters
fnPassed to each input's
then(). It may return a value or promise.
Behavior
massThen() does not await, limit, or reorder asynchronous work. It synchronously maps each input x to x.then(fn), so output promise order equals input order while settlement order is unconstrained. Backpressure controls promise objects, not the work already represented by them.
Every input must expose a callable .then(). Context is captured and passed to fn only when it declares a second parameter.
Errors
A missing or invalid .then() becomes a record error through map(). A rejected input bypasses fn and remains a rejected output promise. A throw or rejection from fn rejects that output promise; use resolve() or mapAsync() to turn it into Exstream’s record-error protocol.
Forms
stream.massThen(onFulfilled)
exstream.pipeline().massThen(onFulfilled)
exstream.massThen(onFulfilled, stream)
stream.through(exstream.massThen(onFulfilled))