some.js 552 B

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