callbag-tap
v1.3.0
Published
Callbag operator that taps the source with the given function, but otherwise is a noop
Downloads
2,556
Readme
callbag-tap
Callbag operator that taps the source with the given function, but otherwise acts as a noop.
Therefore it is not the same as forEach which is a sink (that actively consumes sources).
npm install callbag-tap
You can tap data, error and completion respectively:
const tapped = tap(dataTapFunc, errorTapFunc, completionTapFunc)(source);
example
const fromIter = require('callbag-from-iter');
const tap = require('callbag-tap');
const forEach = require('callbag-for-each');
const source = fromIter([1,2,3]);
const tapped = tap(x => console.log("tap", x))(source);
const sink = forEach(x => console.log("sink", x))(tapped);
// tap 1
// sink 1
// tap 2
// sink 2
// tap 3
// sink 3