some.js 563 B

1234567891011121314151617
  1. var _cb = require('./_cb.js');
  2. var _isArrayLike = require('./_isArrayLike.js');
  3. var keys = require('./keys.js');
  4. // Determine if at least one element in the object passes a truth test.
  5. function some(obj, predicate, context) {
  6. predicate = _cb(predicate, context);
  7. var _keys = !_isArrayLike(obj) && keys(obj),
  8. length = (_keys || obj).length;
  9. for (var index = 0; index < length; index++) {
  10. var currentKey = _keys ? _keys[index] : index;
  11. if (predicate(obj[currentKey], currentKey, obj)) return true;
  12. }
  13. return false;
  14. }
  15. module.exports = some;