every.js
620 Bytes
define(['./forOwn', '../function/makeIterator_'], function(forOwn, makeIterator) {
/**
* Object every
*/
function every(obj, callback, thisObj) {
callback = makeIterator(callback, thisObj);
var result = true;
forOwn(obj, function(val, key) {
// we consider any falsy values as "false" on purpose so shorthand
// syntax can be used to check property existence
if (!callback(val, key, obj)) {
result = false;
return false; // break
}
});
return result;
}
return every;
});