mout
Version:
Modular Utilities
20 lines (17 loc) • 536 B
JavaScript
define(['./forOwn', '../function/makeIterator_'], function(forOwn, makeIterator) {
/**
* Creates a new object with all the properties where the callback returns
* true.
*/
function filterValues(obj, callback, thisObj) {
callback = makeIterator(callback, thisObj);
var output = {};
forOwn(obj, function(value, key, obj) {
if (callback(value, key, obj)) {
output[key] = value;
}
});
return output;
}
return filterValues;
});