No Description

every.js 531B

123456789101112131415
  1. import cb from './_cb.js';
  2. import isArrayLike from './_isArrayLike.js';
  3. import keys from './keys.js';
  4. // Determine whether all of the elements pass a truth test.
  5. export default 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. }