API · Lifecycle
end()
Gracefully finish a stream after delivering values already accepted into its buffer.
Example
source.write(first)
source.write(second)
source.end() Behavior
end() queues the end marker, force-flushes buffered records if needed, transitions to ended, emits end once for readable streams, detaches consumers/observers, and releases source resources. Repeated terminal calls are no-ops; the first terminal state wins.
Graceful end delivers accepted buffered values instead of discarding them, and no abort reason is set. Downstream end propagation follows the connected graph. Later write() calls throw. External cancellation is expressed through the AbortSignal supplied when the source or terminal is created.
end() is immediate in lifecycle terms and returns no completion promise. Await a terminal consumer such as drain() or pipeTo() when downstream completion matters.
Signature
end(): void