1 var arraySome = require('./_arraySome'),
2 baseIteratee = require('./_baseIteratee'),
3 baseSome = require('./_baseSome'),
4 isArray = require('./isArray'),
5 isIterateeCall = require('./_isIterateeCall');
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).
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,
23 * _.some([null, 0, 'yes', false], Boolean);
27 * { 'user': 'barney', 'active': true },
28 * { 'user': 'fred', 'active': false }
31 * // The `_.matches` iteratee shorthand.
32 * _.some(users, { 'user': 'barney', 'active': false });
35 * // The `_.matchesProperty` iteratee shorthand.
36 * _.some(users, ['active', false]);
39 * // The `_.property` iteratee shorthand.
40 * _.some(users, 'active');
43 function some(collection, predicate, guard) {
44 var func = isArray(collection) ? arraySome : baseSome;
45 if (guard && isIterateeCall(collection, predicate, guard)) {
46 predicate = undefined;
48 return func(collection, baseIteratee(predicate, 3));
51 module.exports = some;