Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/franciscotln/callbag-map-when
Callbag operator that maps over values that satisfies a predicate. AKA filterMap
https://github.com/franciscotln/callbag-map-when
Last synced: 3 months ago
JSON representation
Callbag operator that maps over values that satisfies a predicate. AKA filterMap
- Host: GitHub
- URL: https://github.com/franciscotln/callbag-map-when
- Owner: franciscotln
- License: mit
- Created: 2018-03-18T11:26:47.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-04-09T06:00:26.000Z (almost 3 years ago)
- Last Synced: 2024-10-09T09:47:28.503Z (3 months ago)
- Language: JavaScript
- Size: 21.5 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
- awesome-callbags - map-when
README
# callbag-map-when
Callbag operator that applies a transformation function only to items that satisfy the predicate function. Works as filter() followed by map() on either pullable or listenable sources.
`npm install callbag-map-when`
## Example
```js
const mapWhen = require('callbag-map-when');
const forEach = require('callbag-for-each');
const fromIter = require('callbag-from-iter');
const pipe = require('callbag-pipe');pipe(
fromIter([1, 2, 3, 4]),
mapWhen(n => n % 2 === 0, n => n * 10),
forEach((n) => {
console.log(n); // 20
}) // 40
);
```