Functional javascript library Fork on Github
Check bundle size on bundlephobia
$ npm install fun.js --save
The documentation is done using jsdocs and can be found in the /docs folder or at the url https://astuanax.github.io/fun/
The fun.js is a functional library which supports monads and follows mostly he ramda specifications but tries to keep the bite size down. The focus is to provide helpful functions for react development with a small footprint.
Most if not all functions are autocurried, which means they can have any arity and you can still use default parameters in your function parameters.
Neat.
const abc = curry((a, b, c = [1, 2, 3]) => concat(a, b, c))
const add1 = abc(['tss tss'])
add1(['check']) // ['tss tss', 'check', 1, 2, 3]
const lengthDeep = compose(sum, map(x => x.length))
const lengthDeep2 = fold((total, xs) => total + xs.length, 0)
const mapReduce = curry((m, r) => (x, y) => r(x, m(y)))
const deepLength = xs => fold(mapReduce(x => x.length, add), 0, xs)
lengthDeep([[1], [2, 3], [4, 5, 6]]) === 6
const mapReduce = curry((m, r) => (x, y) => r(x, m(y)))
const omap = curry((f, o) => fold(mapReduce(k => ({ [k]: f(o[k]) }), Object.assign), {}, keys(o)))
const omapAdd10 = omap(add(10))
omapAdd10({ a: 1, b: 2, c: 3 })) == { 'a': 11, 'b': 12, 'c': 13 }
const diffInSeconds = compose(toSeconds, diffDate)
const date1 = new Date('1999-12-31')
const date2 = new Date('2000-01-01')
diffInSeconds(date1, date2)) === -86400
The fun.js library is used together with some other libraries:
Matrix applicative providing standard matrix operations
Machine learning with functional undertones: perceptron, neural network and decision trees.
WIP React library with helper function