baseSome.js 647 B

1234567891011121314151617181920212223
  1. var baseEach = require('./baseEach');
  2. /**
  3. * The base implementation of `_.some` without support for callback shorthands
  4. * and `this` binding.
  5. *
  6. * @private
  7. * @param {Array|Object|string} collection The collection to iterate over.
  8. * @param {Function} predicate The function invoked per iteration.
  9. * @returns {boolean} Returns `true` if any element passes the predicate check,
  10. * else `false`.
  11. */
  12. function baseSome(collection, predicate) {
  13. var result;
  14. baseEach(collection, function(value, index, collection) {
  15. result = predicate(value, index, collection);
  16. return !result;
  17. });
  18. return !!result;
  19. }
  20. module.exports = baseSome;