Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/krawaller/callbag-tap
https://github.com/krawaller/callbag-tap
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/krawaller/callbag-tap
- Owner: krawaller
- License: mit
- Created: 2018-02-14T15:29:04.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-11-27T08:46:46.000Z (about 4 years ago)
- Last Synced: 2024-09-18T04:45:47.143Z (4 months ago)
- Language: JavaScript
- Size: 17.6 KB
- Stars: 4
- Watchers: 3
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-callbags - tap
README
# callbag-tap
[Callbag](https://github.com/callbag/callbag) operator that allows you to `tap` data, error and completion. Allows you to inspect and do side effects without disturbing the stream.
In contrast to [forEach](https://github.com/staltz/callbag-for-each) which is a sink and actively consumes sources), `tap` does not consume sources.
Install with:
`npm install callbag-tap`You can tap data, error and completion respectively:
```js
const tapped = tap(dataTapFunc, errorTapFunc, completionTapFunc)(source);
```## example
```js
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
```