react / wstein / node_modules / jest-cli / node_modules / istanbul / node_modules / js-yaml / node_modules / argparse / node_modules / lodash / collection / some.js
80742 viewsvar arraySome = require('../internal/arraySome'),1baseCallback = require('../internal/baseCallback'),2baseSome = require('../internal/baseSome'),3isArray = require('../lang/isArray'),4isIterateeCall = require('../internal/isIterateeCall');56/**7* Checks if `predicate` returns truthy for **any** element of `collection`.8* The function returns as soon as it finds a passing value and does not iterate9* over the entire collection. The predicate is bound to `thisArg` and invoked10* with three arguments: (value, index|key, collection).11*12* If a property name is provided for `predicate` the created `_.property`13* style callback returns the property value of the given element.14*15* If a value is also provided for `thisArg` the created `_.matchesProperty`16* style callback returns `true` for elements that have a matching property17* value, else `false`.18*19* If an object is provided for `predicate` the created `_.matches` style20* callback returns `true` for elements that have the properties of the given21* object, else `false`.22*23* @static24* @memberOf _25* @alias any26* @category Collection27* @param {Array|Object|string} collection The collection to iterate over.28* @param {Function|Object|string} [predicate=_.identity] The function invoked29* per iteration.30* @param {*} [thisArg] The `this` binding of `predicate`.31* @returns {boolean} Returns `true` if any element passes the predicate check,32* else `false`.33* @example34*35* _.some([null, 0, 'yes', false], Boolean);36* // => true37*38* var users = [39* { 'user': 'barney', 'active': true },40* { 'user': 'fred', 'active': false }41* ];42*43* // using the `_.matches` callback shorthand44* _.some(users, { 'user': 'barney', 'active': false });45* // => false46*47* // using the `_.matchesProperty` callback shorthand48* _.some(users, 'active', false);49* // => true50*51* // using the `_.property` callback shorthand52* _.some(users, 'active');53* // => true54*/55function some(collection, predicate, thisArg) {56var func = isArray(collection) ? arraySome : baseSome;57if (thisArg && isIterateeCall(collection, predicate, thisArg)) {58predicate = null;59}60if (typeof predicate != 'function' || thisArg !== undefined) {61predicate = baseCallback(predicate, thisArg, 3);62}63return func(collection, predicate);64}6566module.exports = some;676869