Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/staltz/callbag-map
👜 Callbag operator that applies a transformation on data passing through it
https://github.com/staltz/callbag-map
Last synced: 5 days ago
JSON representation
👜 Callbag operator that applies a transformation on data passing through it
- Host: GitHub
- URL: https://github.com/staltz/callbag-map
- Owner: staltz
- License: mit
- Created: 2018-01-23T21:30:49.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-10-16T06:46:24.000Z (about 4 years ago)
- Last Synced: 2024-10-28T02:51:17.461Z (16 days ago)
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 8
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: readme.js
- License: LICENSE
Awesome Lists containing this project
- awesome-callbags - map
README
/**
* callbag-map
* -----------
*
* Callbag operator that applies a transformation on data passing through it.
* Works on either pullable or listenable sources.
*
* `npm install callbag-map`
*
* Example:
*
* const fromIter = require('callbag-from-iter');
* const iterate = require('callbag-iterate');
* const map = require('callbag-map');
*
* const source = map(x => x * 0.1)(fromIter([10,20,30,40]));
*
* iterate(x => console.log(x))(source); // 1
* // 2
* // 3
* // 4
*/const map = f => source => (start, sink) => {
if (start !== 0) return;
source(0, (t, d) => {
sink(t, t === 1 ? f(d) : d)
});
};module.exports = map;