every.js 554 B

1234567891011121314151617
  1. var _cb = require('./_cb.js');
  2. var _isArrayLike = require('./_isArrayLike.js');
  3. var keys = require('./keys.js');
  4. // Determine whether all of the elements pass a truth test.
  5. function every(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 false;
  12. }
  13. return true;
  14. }
  15. module.exports = every;