Cali
A JS utility library in FP style
Installation
npm install cali
Usage
the library can be imported by AMD, CommonJS or ES6 loaders, or as the global variable 'cali'
// ES6;// CommonJSvar cali = ;
API
Functions
Curry
takes a function and returns a function that's automatically curried
let curriedSum = ;23 === 6; // true
Identity
takes a value and returns it
let obj = {}; === obj; // true
Compose
composes functions, executes each sequentially starting from the right most function
5 === 12
Map
maps over a collection, automatically curried
123 // [2,4,6]
Functors, Applicative, Monads
Functor
general functor
let functor = 1;functor // Functor(2)
function functor
let functor = a + 1;let f = functor // f is equivalent to 'compose(a => a + 1, a => a * 2)' === 2 + 1 * 2
Applicative
applicative functor
let applicative = a + 1;applicative // Applicative(3)
Maybe
a container may have a value or nothing
// Just(4) // Nothing