1const compose = (...funcs) => args => funcs.reduceRight((arg, fn) => fn(arg), args);
2
3// Or if you like in ES5
4function compose(...funcs)
5{
6 return function(args)
7 {
8 return funcs.reduceRight( (arg, fn) => fn(arg), args);
9 }
10}
11
1Curried Function
2// Non-curried
3function add(a, b, c) {
4 return a + b + c
5}
6
7add(1, 2, 3)
8//-> 6
9
10// Curried
11function addd(a) {
12 return function (b) {
13 return function (c) {
14 return a + b + c
15 }
16 }
17}
18
19addd(1)(2)(3)
20//-> 6