Skip to content

Tiny library of functional programming operations for ES6 collections (Maps and Sets)

Notifications You must be signed in to change notification settings

milosh86/fp-es6

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fp-es6

Tiny library of functional programming operations for ES6 collections (Maps and Sets). Couldn't find any similar library without Traceur dependancy :(

npm install fp-es6

Provides following operations:

  • map: MapOrSet -> MapOrSet
  • filter: MapOrSet -> MapOrSet
  • reduce: MapOrSet -> Any
  • some: MapOrSet -> Boolean
  • every: MapOrSet -> Boolean

Assumes that Map and Set are present (native or polyfill).

var fn = require('fp-es6');

var doubledAndFiltered = fn(new Set([1,2,3]))
  .map(val => 2 * val)
  .filter(val => val > 2)
  .value(); // call value() to extract the native collection

doubledAndFiltered instanceof Set // true

var sum = fn(new Set([1,2,3])).reduce((a, b) => a + b);

var hasFive = fn(new Set([1,2,3])).some(val => val === 5);

fn(new Map([['a', 1], ['b', 1]])).every(val => val === 1);

About

Tiny library of functional programming operations for ES6 collections (Maps and Sets)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published