@johngw/stream
Version:
Reactive programming tools using the WHATWG Streams API.
27 lines • 558 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.tap = void 0;
/**
* Subscribe to chunks in the stream, immediately passing any
* chunks on to the pipe.
*
* @group Transformers
* @example
* ```
* --1--2--3--4--5--6--
*
* tap(chunk => console.info(x))
*
* --1--2--3--4--5--6--
* ```
*/
function tap(fn) {
return new TransformStream({
transform(chunk, controller) {
fn(chunk);
controller.enqueue(chunk);
},
});
}
exports.tap = tap;
//# sourceMappingURL=tap.js.map