1 | var _curry2 =
|
2 | /*#__PURE__*/
|
3 | require("./internal/_curry2");
|
4 |
|
5 | var _dispatchable =
|
6 | /*#__PURE__*/
|
7 | require("./internal/_dispatchable");
|
8 |
|
9 | var _xall =
|
10 | /*#__PURE__*/
|
11 | require("./internal/_xall");
|
12 | /**
|
13 | * Returns `true` if all elements of the list match the predicate, `false` if
|
14 | * there are any that don't.
|
15 | *
|
16 | * Dispatches to the `all` method of the second argument, if present.
|
17 | *
|
18 | * Acts as a transducer if a transformer is given in list position.
|
19 | *
|
20 | * @func
|
21 | * @memberOf R
|
22 | * @since v0.1.0
|
23 | * @category List
|
24 | * @sig (a -> Boolean) -> [a] -> Boolean
|
25 | * @param {Function} fn The predicate function.
|
26 | * @param {Array} list The array to consider.
|
27 | * @return {Boolean} `true` if the predicate is satisfied by every element, `false`
|
28 | * otherwise.
|
29 | * @see R.any, R.none, R.transduce
|
30 | * @example
|
31 | *
|
32 | * const equals3 = R.equals(3);
|
33 | * R.all(equals3)([3, 3, 3, 3]); //=> true
|
34 | * R.all(equals3)([3, 3, 1, 3]); //=> false
|
35 | */
|
36 |
|
37 |
|
38 | var all =
|
39 | /*#__PURE__*/
|
40 | _curry2(
|
41 | /*#__PURE__*/
|
42 | _dispatchable(['all'], _xall, function all(fn, list) {
|
43 | var idx = 0;
|
44 |
|
45 | while (idx < list.length) {
|
46 | if (!fn(list[idx])) {
|
47 | return false;
|
48 | }
|
49 |
|
50 | idx += 1;
|
51 | }
|
52 |
|
53 | return true;
|
54 | }));
|
55 |
|
56 | module.exports = all; |
\ | No newline at end of file |