This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const varg = (fn, arity) => (...args) => { | |
const l = args.length < arity ? args.length : arity; | |
return typeof args[l - 1] === 'function' | |
? fn( | |
...args.slice(0, -1), | |
...new Array(arity - l).fill(undefined), | |
args[l - 1] | |
) | |
: fn(...args, ...new Array(arity - args.length).fill(undefined)); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const wait = ms => x => new Promise(resolve => setTimeout(resolve, ms, x)); | |
const pipeP = (...fns) => x => | |
fns.reduce((p, fn) => p.then(fn), Promise.resolve(x)); | |
const pipe = (...fns) => x => fns.reduce((acc, fn) => fn(acc), x); | |
const pipeC = (...fns) => (...args) => | |
fns.reduceRight( | |
(acc, fn) => |