Readable, debbuggable & fast ES6 Functional Programming
fp
offers a collection of usefull functions :
compose
,curry
,partial
higher-order functionsmap
function to iterate over any objectnot
,arity
&path
helper functions to use withcompose
&map
identity
,constant
,noop
& other utilities functions
Source are written as ES6 modules, just include the sources
- import
fp
library
import fp from 'fp/src'
- import
fp.compose
function
import compose from 'fp/src/compose'
! source functions are not auto curried
fp.js
file is an ES5 umd bundle (including amd, commonjs & global definitions)
define(['fp'], function (fp) { ... })
var fp = require('fp')
global.fp // just `fp` or `window.fp`
partial
, curry
& compose
functions are unit-tested, to run all tests :
npm test
or run tests for a specific function :
npm run test:partial
npm run test:curry
npm run test:compose
curry
function is benchmarked against Ramda and Lodash implementations, to run benchmarks :
npm run bench
curried functions are 1.7× faster than Lodash and 7× faster than Ramda ;) not true anymore
doc
function allow to get Hindley-Milner signature of every fp
function
console.log(fp.doc(fp.compose))
Clone & rollup
git clone git@github.com:adriengibrat/fp.git
cd fp
npm install --no-optional # optional dependencies are only used for benchmarks
npm start # watch `src` directory and bundle `fp.js` on change
This library assumes an ES5 environment, it may be supported in older browsers :
add ES5 shims in your js dependencies or include Polyfills script in your html <script src="https://cdn.jsdelivr.net/polyfills/polyfill.js+es5"></script>
.
In no particular order :
- mostly-adequate-guide
- ramda
- lodash the Swiss army knife
- fantasyland just love the logo ;)
- folktalejs modular & smart
- functionaljs K.I.S.S.
fp
grandpa
Copyright © 2016 Adrien Gibrat.
Released under the MIT licence.