Version 1
[yaffs-website] / node_modules / uncss / node_modules / lodash / some.js
1 var arraySome = require('./internal/arraySome'),
2     baseIteratee = require('./internal/baseIteratee'),
3     baseSome = require('./internal/baseSome'),
4     isArray = require('./isArray'),
5     isIterateeCall = require('./internal/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  * @category Collection
15  * @param {Array|Object} collection The collection to iterate over.
16  * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration.
17  * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`.
18  * @returns {boolean} Returns `true` if any element passes the predicate check, else `false`.
19  * @example
20  *
21  * _.some([null, 0, 'yes', false], Boolean);
22  * // => true
23  *
24  * var users = [
25  *   { 'user': 'barney', 'active': true },
26  *   { 'user': 'fred',   'active': false }
27  * ];
28  *
29  * // using the `_.matches` iteratee shorthand
30  * _.some(users, { 'user': 'barney', 'active': false });
31  * // => false
32  *
33  * // using the `_.matchesProperty` iteratee shorthand
34  * _.some(users, ['active', false]);
35  * // => true
36  *
37  * // using the `_.property` iteratee shorthand
38  * _.some(users, 'active');
39  * // => true
40  */
41 function some(collection, predicate, guard) {
42   var func = isArray(collection) ? arraySome : baseSome;
43   if (guard && isIterateeCall(collection, predicate, guard)) {
44     predicate = undefined;
45   }
46   return func(collection, baseIteratee(predicate, 3));
47 }
48
49 module.exports = some;