Sha256: 375c981f019441e8aa7c081d38a4747a06f1be1fc85d8b341db7416e583c80c9
Contents?: true
Size: 643 Bytes
Versions: 33
Compression:
Stored size: 643 Bytes
Contents
/** Wraps a value in a function. If given a function, returns it as-is. */ const wrap = x => typeof x === 'function' ? x : () => x /** Returns a predicate that returns true if all arguments are true or evaluate to true for the given input. */ const and = (...fs) => (...args) => fs.length === 0 || ( !!wrap(fs[0])(...args) && and(...fs.slice(1))(...args) ) /** Returns a predicate that returns true if at least one argument is true or evaluates to true for the given input. */ const or = (...fs) => (...args) => fs.length > 0 && ( !!wrap(fs[0])(...args) || or(...fs.slice(1))(...args) ) module.exports = { and, or }
Version data entries
33 entries across 33 versions & 1 rubygems