2.1.0 • Published 5 years ago
callbag-map-when v2.1.0
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
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
);