1 | var _curry1 =
|
2 | /*#__PURE__*/
|
3 | require("./internal/_curry1");
|
4 |
|
5 | var curryN =
|
6 | /*#__PURE__*/
|
7 | require("./curryN");
|
8 |
|
9 | var max =
|
10 | /*#__PURE__*/
|
11 | require("./max");
|
12 |
|
13 | var pluck =
|
14 | /*#__PURE__*/
|
15 | require("./pluck");
|
16 |
|
17 | var reduce =
|
18 | /*#__PURE__*/
|
19 | require("./reduce");
|
20 | /**
|
21 | * Takes a list of predicates and returns a predicate that returns true for a
|
22 | * given list of arguments if at least one of the provided predicates is
|
23 | * satisfied by those arguments.
|
24 | *
|
25 | * The function returned is a curried function whose arity matches that of the
|
26 | * highest-arity predicate.
|
27 | *
|
28 | * @func
|
29 | * @memberOf R
|
30 | * @since v0.9.0
|
31 | * @category Logic
|
32 | * @sig [(*... -> Boolean)] -> (*... -> Boolean)
|
33 | * @param {Array} predicates An array of predicates to check
|
34 | * @return {Function} The combined predicate
|
35 | * @see R.allPass
|
36 | * @example
|
37 | *
|
38 | * const isClub = R.propEq('suit', '♣');
|
39 | * const isSpade = R.propEq('suit', '♠');
|
40 | * const isBlackCard = R.anyPass([isClub, isSpade]);
|
41 | *
|
42 | * isBlackCard({rank: '10', suit: '♣'}); //=> true
|
43 | * isBlackCard({rank: 'Q', suit: '♠'}); //=> true
|
44 | * isBlackCard({rank: 'Q', suit: '♦'}); //=> false
|
45 | */
|
46 |
|
47 |
|
48 | var anyPass =
|
49 | /*#__PURE__*/
|
50 | _curry1(function anyPass(preds) {
|
51 | return curryN(reduce(max, 0, pluck('length', preds)), function () {
|
52 | var idx = 0;
|
53 | var len = preds.length;
|
54 |
|
55 | while (idx < len) {
|
56 | if (preds[idx].apply(this, arguments)) {
|
57 | return true;
|
58 | }
|
59 |
|
60 | idx += 1;
|
61 | }
|
62 |
|
63 | return false;
|
64 | });
|
65 | });
|
66 |
|
67 | module.exports = anyPass; |
\ | No newline at end of file |