Compose-Function
Installation |
Usage |
Related |
License
logo by Justin Mezzell
Compose a new function from smaller functions `f(g(x))`
Installation
npm install compose-function
Usage
Basic usage
import compose from 'compose-function';
const composition = compose(sqr, add2);
composition(2)
compose(sqr, inc)(2);
compose(inc, sqr)(2);
with curry
import compose from 'compose-function';
import { curry, _ } from 'curry-this';
const add = (x, y) => x + y;
compose(
add::curry(6),
sqr,
add::curry(2),
);
compose(
map::curry(_, sqr),
filter::curry(_, even),
)([1,2,3,4,5,6,7,8])
::
huh?
If you’re wondering what the ::
thing means, you’d better read this excellent overview by @jussi-kalliokoski or have a look at the function bind syntax proposal.
Or checkout the curry-this docs.
Related
License
MIT © Christoph Hermann