1 | const mixCompose = (chain, func) => (chain instanceof Promise || typeof chain.then === "function") ? chain.then(func) : func(chain);
|
2 |
|
3 | const pipe = (...fn) => input => fn.reduce(mixCompose,input);
|
4 | const compose = (...fn) => input => fn.reduceRight(mixCompose,input);
|
5 |
|
6 | const curry = f => {
|
7 | return function currify() {
|
8 | const args = Array.prototype.slice.call(arguments);
|
9 | return args.length >= f.length ? f.apply(null, args) : currify.bind(null, ...args)
|
10 | }
|
11 | }
|
12 | module.exports = {pipe, compose, curry};
|