UNPKG

508 BJavaScriptView Raw
1const mixCompose = (chain, func) => (chain instanceof Promise || typeof chain.then === "function") ? chain.then(func) : func(chain);
2
3const pipe = (...fn) => input => fn.reduce(mixCompose,input);
4const compose = (...fn) => input => fn.reduceRight(mixCompose,input);
5
6const 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}
12module.exports = {pipe, compose, curry};