0%

compose

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
*
* @param {...fn||arg} fns from right to left
*/
function compose(...fns) {
return function(x) {
return fns.reduceRight((arg, fn) => fn(arg), x);
};
}
/**
*
* @param {...fn||arg} fns from left to right
*/
function pipe(...fns) {
return function(x) {
return fns.reduce((arg, fn) => fn(arg), x);
};
}