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 every one of the provided predicates is satisfied
|
23 | * 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.anyPass
|
36 | * @example
|
37 | *
|
38 | * const isQueen = R.propEq('rank', 'Q');
|
39 | * const isSpade = R.propEq('suit', '♠︎');
|
40 | * const isQueenOfSpades = R.allPass([isQueen, isSpade]);
|
41 | *
|
42 | * isQueenOfSpades({rank: 'Q', suit: '♣︎'}); //=> false
|
43 | * isQueenOfSpades({rank: 'Q', suit: '♠︎'}); //=> true
|
44 | */
|
45 |
|
46 |
|
47 | var allPass =
|
48 | /*#__PURE__*/
|
49 | _curry1(function allPass(preds) {
|
50 | return curryN(reduce(max, 0, pluck('length', preds)), function () {
|
51 | var idx = 0;
|
52 | var len = preds.length;
|
53 |
|
54 | while (idx < len) {
|
55 | if (!preds[idx].apply(this, arguments)) {
|
56 | return false;
|
57 | }
|
58 |
|
59 | idx += 1;
|
60 | }
|
61 |
|
62 | return true;
|
63 | });
|
64 | });
|
65 |
|
66 | module.exports = allPass; |
\ | No newline at end of file |