UNPKG

@johngw/stream

Version:

Reactive programming tools using the WHATWG Streams API.

29 lines (28 loc) 984 B
import { ForkableSink } from '@johngw/stream/sinks/ForkableSink'; import { ControllableSource } from '@johngw/stream/sources/ControllableSource'; /** * An extension to the {@link ForkableSink:class} that immediately * queues the last received chunk to any fork. * * @group Sinks * @see {@link ForkableRecallStream:class} * @example * ``` * const forkable = new ForkableRecallSink<number>() * const writable = new WritableStream(forkable) * await fromCollection([1, 2, 3, 4, 5, 6, 7]).pipeTo(writable) * ``` * * Now the stream has finished, if we fork from it we'll * receive the last thing that was emitted. * * ``` * await forkable.fork().pipeTo(write(console.info)) * // 7 * ``` */ export declare class ForkableRecallSink<T> extends ForkableSink<T> { #private; write(chunk: T): void; protected _addController(underlyingSource?: UnderlyingDefaultSource<T>, queuingStrategy?: QueuingStrategy<T>): readonly [ControllableSource<T>, ReadableStream<T>]; }