UNPKG

@johngw/stream

Version:

Reactive programming tools using the WHATWG Streams API.

41 lines 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ForkableReplayStream = void 0; const BaseForkableStream_1 = require("@johngw/stream/sinks/BaseForkableStream"); const ForkableReplaySink_1 = require("@johngw/stream/sinks/ForkableReplaySink"); /** * An extension to the {@link ForkableStream:class} that immediately * queues the entire contents of whatever has been previously consumed. * * @group Sinks * @see {@link ForkableReplaySink} * @example * ``` * const forkable = new ForkableReplayStream<number>() * await fromCollection([1, 2, 3, 4, 5, 6, 7]).pipeTo(forkable) * ``` * * Now the stream has finished, if we fork from it we'll * receive the entire events that were published to it. * * ``` * await forkable.fork().pipeTo(write(console.info)) * // 1 * // 2 * // 3 * // 4 * // 5 * // 6 * // 7 * ``` */ class ForkableReplayStream extends BaseForkableStream_1.BaseForkableStream { constructor(maxReplaySize, strategy) { super(new ForkableReplaySink_1.ForkableReplaySink(maxReplaySize), strategy); } clear() { return this.sink.clear(); } } exports.ForkableReplayStream = ForkableReplayStream; //# sourceMappingURL=ForkableReplayStream.js.map