Import
What it does
The pipeline system lets you compose typed transformation operators into a reusable, lazy, immutable pipeline. Nothing executes until you call .process(data). Each .pipe() call returns a new Pipeline instance — the original is never mutated.
map — transform each element. Async functions run concurrently (Promise.all).
filter — retain elements by predicate. Async predicates run concurrently.
reduce — accumulate to a scalar. Reducer steps run sequentially.
PipelineOp<TIn, TOut>
The atomic unit of a pipeline — a function that transforms a value synchronously or asynchronously.
Pipeline<TIn, TOut>
pipe(...ops)
Creates a typed Pipeline from a sequence of operators. Type inference flows left-to-right for up to 7 operators. Use the escape-hatch overload for dynamic/longer pipelines.
map<T, U>(fn)
filter<T>(fn)
reduce<T, U>(fn, initial)
Behaviour guarantees
Examples
Sync composition
Async map (concurrent enrichment)
Immutable builder — reuse and extend
ApiClient integration
Apply a pipeline to the response body automatically, after parsing and validation.
Error handling
All three operator factories accept both sync and async functions — you don’t need to change anything to switch between them.
reduce is always sequential. If you need parallel reduction (e.g., independent batch writes), use map followed by Promise.all outside the pipeline.