every.js 635 B

1234567891011121314151617181920212223
  1. var forOwn = require('./forOwn');
  2. var makeIterator = require('../function/makeIterator_');
  3. /**
  4. * Object every
  5. */
  6. function every(obj, callback, thisObj) {
  7. callback = makeIterator(callback, thisObj);
  8. var result = true;
  9. forOwn(obj, function(val, key) {
  10. // we consider any falsy values as "false" on purpose so shorthand
  11. // syntax can be used to check property existence
  12. if (!callback(val, key, obj)) {
  13. result = false;
  14. return false; // break
  15. }
  16. });
  17. return result;
  18. }
  19. module.exports = every;