@johngw/stream
Version:
Reactive programming tools using the WHATWG Streams API.
37 lines • 1.56 kB
TypeScript
import type { Forkable } from './Forkable.js';
import type { Controllable } from '../sources/Controllable.js';
import { ControllableSource } from '../sources/ControllableSource.js';
import type { UnderlyingDefaultSource, UnderlyingSink } from 'node:stream/web';
/**
* A ForkableSink is the underlying logic for "1 Writable to many Readables".
*
* @group Sinks
* @see {@link ForkableStream:class}
* @example
* ```
* const forkable = new ForkableSink<T>()
* const writable = new WritableStream(forkable)
*
* fromCollection([1, 2, 3, 4, 5, 6, 7]).pipeTo(writable)
*
* forkable.fork().pipeTo(write(x => console.info('fork1', x)))
* // fork1 1, fork1 2, fork1 3, fork1 4, fork1 5, fork1 6, fork1 7
*
* forkable.fork().pipeTo(write(x => console.info('fork2', x)))
* // fork2 1, fork2 2, fork2 3, fork2 4, fork2 5, fork2 6, fork2 7
* ```
*/
export declare class ForkableSink<T> implements UnderlyingSink<T>, Forkable<T> {
#private;
abort(reason: unknown): void;
close(): void;
write(chunk: T): void;
get finished(): boolean;
fork(underlyingSource?: UnderlyingDefaultSource<T>, queuingStrategy?: QueuingStrategy<T>): ReadableStream<T>;
protected _addController(underlyingSource?: UnderlyingDefaultSource<T>, queuingStrategy?: QueuingStrategy<T>): readonly [ControllableSource<T>, import("node:stream/web").ReadableStream<T>];
protected _pipeThroughController([controller, stream]: readonly [
Controllable<T>,
ReadableStream<T>
]): ReadableStream<T>;
}
//# sourceMappingURL=ForkableSink.d.ts.map