main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | var _curry2 =
|
---|
2 | /*#__PURE__*/
|
---|
3 | require("./internal/_curry2.js");
|
---|
4 |
|
---|
5 | var _dispatchable =
|
---|
6 | /*#__PURE__*/
|
---|
7 | require("./internal/_dispatchable.js");
|
---|
8 |
|
---|
9 | var _xany =
|
---|
10 | /*#__PURE__*/
|
---|
11 | require("./internal/_xany.js");
|
---|
12 | /**
|
---|
13 | * Returns `true` if at least one of the elements of the list match the predicate,
|
---|
14 | * `false` otherwise.
|
---|
15 | *
|
---|
16 | * Dispatches to the `any` 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 at least one element, `false`
|
---|
28 | * otherwise.
|
---|
29 | * @see R.all, R.none, R.transduce
|
---|
30 | * @example
|
---|
31 | *
|
---|
32 | * const lessThan0 = R.flip(R.lt)(0);
|
---|
33 | * const lessThan2 = R.flip(R.lt)(2);
|
---|
34 | * R.any(lessThan0)([1, 2]); //=> false
|
---|
35 | * R.any(lessThan2)([1, 2]); //=> true
|
---|
36 | */
|
---|
37 |
|
---|
38 |
|
---|
39 | var any =
|
---|
40 | /*#__PURE__*/
|
---|
41 | _curry2(
|
---|
42 | /*#__PURE__*/
|
---|
43 | _dispatchable(['any'], _xany, function any(fn, list) {
|
---|
44 | var idx = 0;
|
---|
45 |
|
---|
46 | while (idx < list.length) {
|
---|
47 | if (fn(list[idx])) {
|
---|
48 | return true;
|
---|
49 | }
|
---|
50 |
|
---|
51 | idx += 1;
|
---|
52 | }
|
---|
53 |
|
---|
54 | return false;
|
---|
55 | }));
|
---|
56 |
|
---|
57 | module.exports = any; |
---|
Note:
See
TracBrowser
for help on using the repository browser.