source: trip-planner-front/node_modules/lodash/some.js@ bdd6491

Last change on this file since bdd6491 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.6 KB
Line 
1var arraySome = require('./_arraySome'),
2 baseIteratee = require('./_baseIteratee'),
3 baseSome = require('./_baseSome'),
4 isArray = require('./isArray'),
5 isIterateeCall = require('./_isIterateeCall');
6
7/**
8 * Checks if `predicate` returns truthy for **any** element of `collection`.
9 * Iteration is stopped once `predicate` returns truthy. The predicate is
10 * invoked with three arguments: (value, index|key, collection).
11 *
12 * @static
13 * @memberOf _
14 * @since 0.1.0
15 * @category Collection
16 * @param {Array|Object} collection The collection to iterate over.
17 * @param {Function} [predicate=_.identity] The function invoked per iteration.
18 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
19 * @returns {boolean} Returns `true` if any element passes the predicate check,
20 * else `false`.
21 * @example
22 *
23 * _.some([null, 0, 'yes', false], Boolean);
24 * // => true
25 *
26 * var users = [
27 * { 'user': 'barney', 'active': true },
28 * { 'user': 'fred', 'active': false }
29 * ];
30 *
31 * // The `_.matches` iteratee shorthand.
32 * _.some(users, { 'user': 'barney', 'active': false });
33 * // => false
34 *
35 * // The `_.matchesProperty` iteratee shorthand.
36 * _.some(users, ['active', false]);
37 * // => true
38 *
39 * // The `_.property` iteratee shorthand.
40 * _.some(users, 'active');
41 * // => true
42 */
43function some(collection, predicate, guard) {
44 var func = isArray(collection) ? arraySome : baseSome;
45 if (guard && isIterateeCall(collection, predicate, guard)) {
46 predicate = undefined;
47 }
48 return func(collection, baseIteratee(predicate, 3));
49}
50
51module.exports = some;
Note: See TracBrowser for help on using the repository browser.