API · Graph
fork()
Create an independent reliable branch that participates in shared-source backpressure.
Signature
fork(disableAutostart?: boolean): Exstream<T, C> Example
const source = exstream(records)
const database = source.fork()
const audit = source.fork()
await Promise.all([database.pipeTo(databaseWriter), audit.jsonlStringify().pipeTo(auditWriter)]) Create all branches synchronously, before the source starts.
Parameters
disableAutostart-
By default, Exstream schedules the shared source to start after the current synchronous setup turn. Pass
trueto wire branches without that scheduled start, then callsource.start()explicitly. The runtime uses truthiness; the public TypeScript API accepts booleans.
Delivery
Every fork receives every source record in order. The shared source advances only after each active reliable branch can accept the record, so the slowest fork controls throughput. No drop policy is available on a reliable fork.
Contexts are copied at the branch boundary. Mutating one branch’s context does not mutate its sibling’s context object.
Lifecycle
Calling fork() after the source has started throws. A branch that is destroyed detaches from the shared source. A failure in one terminal destination cancels that fork; reliable siblings may continue, so application code awaiting several branches decides whether to abort them together.
With disableAutostart: true, terminal consumers may be attached to every fork first, but no source work begins until source.start() is called. start() releases the source and resolves after startup is scheduled; it is not a completion promise. Await the branch terminal operations for completion.
Use observe() when observation must never slow the reliable flow and data loss is acceptable.
Forms
fork() is a graph operation on a concrete stream. It is not available on reusable pipeline definitions and has no standalone operator form because it must attach to one live source instance.