@johngw/stream
Version:
Reactive programming tools using the WHATWG Streams API.
32 lines • 1.07 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ForkableRecallStream = void 0;
const ForkableRecallSink_1 = require("@johngw/stream/sinks/ForkableRecallSink");
const BaseForkableStream_1 = require("@johngw/stream/sinks/BaseForkableStream");
/**
* An extension to the {@link ForkableStream:class} that immediately
* queues the last received chunk to any fork.
*
* @group Sinks
* @see {@link ForkableRecallSink}
* @example
* ```
* const forkable = new ForkableRecallStream<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 last thing that was emitted.
*
* ```
* await forkable.fork().pipeTo(write(console.info))
* // 7
* ```
*/
class ForkableRecallStream extends BaseForkableStream_1.BaseForkableStream {
constructor(strategy) {
super(new ForkableRecallSink_1.ForkableRecallSink(), strategy);
}
}
exports.ForkableRecallStream = ForkableRecallStream;
//# sourceMappingURL=ForkableRecallStream.js.map