Skip to content

Callbag operator that maps over values that satisfies a predicate. AKA filterMap

License

Notifications You must be signed in to change notification settings

franciscotln/callbag-map-when

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
);

About

Callbag operator that maps over values that satisfies a predicate. AKA filterMap

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published