mirror of
https://github.com/swc-project/swc.git
synced 2024-12-21 12:41:54 +03:00
bbaf619f63
swc_bundler: - [x] Fix wrapped esms. (denoland/deno#9307) - [x] Make test secure.
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
// Loaded from https://deno.land/x/ramda@v0.27.2/source/anyPass.js
|
|
|
|
|
|
import _curry1 from './internal/_curry1.js';
|
|
import curryN from './curryN.js';
|
|
import max from './max.js';
|
|
import pluck from './pluck.js';
|
|
import reduce from './reduce.js';
|
|
|
|
|
|
/**
|
|
* Takes a list of predicates and returns a predicate that returns true for a
|
|
* given list of arguments if at least one of the provided predicates is
|
|
* satisfied by those arguments.
|
|
*
|
|
* The function returned is a curried function whose arity matches that of the
|
|
* highest-arity predicate.
|
|
*
|
|
* @func
|
|
* @memberOf R
|
|
* @since v0.9.0
|
|
* @category Logic
|
|
* @sig [(*... -> Boolean)] -> (*... -> Boolean)
|
|
* @param {Array} predicates An array of predicates to check
|
|
* @return {Function} The combined predicate
|
|
* @see R.allPass
|
|
* @example
|
|
*
|
|
* const isClub = R.propEq('suit', '♣');
|
|
* const isSpade = R.propEq('suit', '♠');
|
|
* const isBlackCard = R.anyPass([isClub, isSpade]);
|
|
*
|
|
* isBlackCard({rank: '10', suit: '♣'}); //=> true
|
|
* isBlackCard({rank: 'Q', suit: '♠'}); //=> true
|
|
* isBlackCard({rank: 'Q', suit: '♦'}); //=> false
|
|
*/
|
|
var anyPass = _curry1(function anyPass(preds) {
|
|
return curryN(reduce(max, 0, pluck('length', preds)), function() {
|
|
var idx = 0;
|
|
var len = preds.length;
|
|
while (idx < len) {
|
|
if (preds[idx].apply(this, arguments)) {
|
|
return true;
|
|
}
|
|
idx += 1;
|
|
}
|
|
return false;
|
|
});
|
|
});
|
|
export default anyPass;
|