lowdash
lowdash is a functional JavaScript library including compose, pipe, curry, transduce, identity, trace, Functor, Monad, Applicative
Examples
const compose curry pipe identity trace transduce Functor Monad Applicative = // curry const match = const replace = const filter = const map = 'hello world'//=> [ ' ' ] const hasSpaces = // function(x) { return x.match(/\s+/g) } //=> [ ' ' ] //=> null //=> ['te amo'] const findSpaces = // function(xs) { return xs.filter(function(x) { return x.match(/\s+/g) }) } //=> ['te amo'] const noVowels = // function(replacement, x) { return x.replace(/[aeiou]/ig, replacement) } const censored = // function(x) { return x.replace(/[aeiou]/ig, '*') } //=> 'Ch*c*l*t* C*k*' // compose const toUpperCase = { return x }const exclaim = { return x + '!' }const shout = //=> 'ANGRY OR HUNGRY!' const reduce = const head = { return x0 }const reverse = const last = //=> 'upper' const lastUpper = //=> 'UPPER' // pipe const shoutPipe = console//=> 'ANGRY OR HUNGRY!' // pointfree const toLowerCase = { return x }const snakeCase = //=> 'snake_case' const split = const join = const initials = //=> 'J. J. J' // transduce = transform + reduce const t = result console//=> [4, 5] // debug const dasherize = //=> after split [ 'The', 'world', 'is', 'a', 'vampire' ]//=> 'the-world-is-a-vampire' // Functor, Monad, Applicative const increment = x + 1const add2 = const add4 = console const incrementMonad = const add2Monad = Monadconst add4Monad = Monad console const add = a + bconst add2 = let left = Applicativelet right = Applicative console
Installation
npm install --save lowdash
Usage
You can import from lowdash
:
;// orconst compose curry pipe identity trace transduce Functor Monad Applicative = ;