Sha256: a394760d37b72f47d6b41ca817a34a8e9db46051d9edc45ea6af499f94ba4b7b

Contents?: true

Size: 1.57 KB

Versions: 265

Compression:

Stored size: 1.57 KB

Contents

var arraySome = require('./_arraySome'),
    baseIteratee = require('./_baseIteratee'),
    baseSome = require('./_baseSome'),
    isArray = require('./isArray'),
    isIterateeCall = require('./_isIterateeCall');

/**
 * Checks if `predicate` returns truthy for **any** element of `collection`.
 * Iteration is stopped once `predicate` returns truthy. The predicate is
 * invoked with three arguments: (value, index|key, collection).
 *
 * @static
 * @memberOf _
 * @since 0.1.0
 * @category Collection
 * @param {Array|Object} collection The collection to iterate over.
 * @param {Function} [predicate=_.identity] The function invoked per iteration.
 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
 * @returns {boolean} Returns `true` if any element passes the predicate check,
 *  else `false`.
 * @example
 *
 * _.some([null, 0, 'yes', false], Boolean);
 * // => true
 *
 * var users = [
 *   { 'user': 'barney', 'active': true },
 *   { 'user': 'fred',   'active': false }
 * ];
 *
 * // The `_.matches` iteratee shorthand.
 * _.some(users, { 'user': 'barney', 'active': false });
 * // => false
 *
 * // The `_.matchesProperty` iteratee shorthand.
 * _.some(users, ['active', false]);
 * // => true
 *
 * // The `_.property` iteratee shorthand.
 * _.some(users, 'active');
 * // => true
 */
function some(collection, predicate, guard) {
  var func = isArray(collection) ? arraySome : baseSome;
  if (guard && isIterateeCall(collection, predicate, guard)) {
    predicate = undefined;
  }
  return func(collection, baseIteratee(predicate, 3));
}

module.exports = some;

Version data entries

265 entries across 263 versions & 30 rubygems

Version Path
sumomo-0.10.0 data/sumomo/api_modules/node_modules/lodash/some.js
reed_sdk-1.0.1 node_modules/lodash/some.js
reed_sdk-1.0.0 node_modules/lodash/some.js
boring_generators-0.12.0 tmp/templates/app_template/node_modules/lodash/some.js
sumomo-0.9.0 data/sumomo/api_modules/node_modules/lodash/some.js
sumomo-0.8.22 data/sumomo/api_modules/node_modules/lodash/some.js
sumomo-0.8.21 data/sumomo/api_modules/node_modules/lodash/some.js
sumomo-0.8.20 data/sumomo/api_modules/node_modules/lodash/some.js
sumomo-0.8.17 data/sumomo/api_modules/node_modules/lodash/some.js
sumomo-0.8.16 data/sumomo/api_modules/node_modules/lodash/some.js
disco_app-0.18.0 test/dummy/node_modules/lodash/some.js
disco_app-0.18.2 test/dummy/node_modules/lodash/some.js
sumomo-0.8.15 data/sumomo/api_modules/node_modules/lodash/some.js
trusty-cms-5.0.7 node_modules/lodash/some.js
appmap-0.72.2 ./node_modules/lodash/some.js
trusty-cms-5.0.6 node_modules/lodash/some.js
appmap-0.72.1 ./node_modules/lodash/some.js
appmap-0.72.0 ./node_modules/lodash/some.js
trusty-cms-5.0.5 node_modules/lodash/some.js
trusty-cms-5.0.4 node_modules/lodash/some.js