source: imaps-frontend/node_modules/lodash-es/some.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.6 KB
Line 
1import arraySome from './_arraySome.js';
2import baseIteratee from './_baseIteratee.js';
3import baseSome from './_baseSome.js';
4import isArray from './isArray.js';
5import isIterateeCall from './_isIterateeCall.js';
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
51export default some;
Note: See TracBrowser for help on using the repository browser.