source: node_modules/ramda/es/any.js

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
RevLine 
[d24f17c]1import _curry2 from "./internal/_curry2.js";
2import _dispatchable from "./internal/_dispatchable.js";
3import _xany from "./internal/_xany.js";
4/**
5 * Returns `true` if at least one of the elements of the list match the predicate,
6 * `false` otherwise.
7 *
8 * Dispatches to the `any` method of the second argument, if present.
9 *
10 * Acts as a transducer if a transformer is given in list position.
11 *
12 * @func
13 * @memberOf R
14 * @since v0.1.0
15 * @category List
16 * @sig (a -> Boolean) -> [a] -> Boolean
17 * @param {Function} fn The predicate function.
18 * @param {Array} list The array to consider.
19 * @return {Boolean} `true` if the predicate is satisfied by at least one element, `false`
20 * otherwise.
21 * @see R.all, R.none, R.transduce
22 * @example
23 *
24 * const lessThan0 = R.flip(R.lt)(0);
25 * const lessThan2 = R.flip(R.lt)(2);
26 * R.any(lessThan0)([1, 2]); //=> false
27 * R.any(lessThan2)([1, 2]); //=> true
28 */
29
30var any =
31/*#__PURE__*/
32_curry2(
33/*#__PURE__*/
34_dispatchable(['any'], _xany, function any(fn, list) {
35 var idx = 0;
36
37 while (idx < list.length) {
38 if (fn(list[idx])) {
39 return true;
40 }
41
42 idx += 1;
43 }
44
45 return false;
46}));
47
48export default any;
Note: See TracBrowser for help on using the repository browser.