some.js 541 B

123456789101112131415
  1. import cb from './_cb.js';
  2. import isArrayLike from './_isArrayLike.js';
  3. import keys from './keys.js';
  4. // Determine if at least one element in the object passes a truth test.
  5. export default 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. }