Sha256: 7f8fefcb3de431fc4bc370c35f0c718531898568711f3084530b32aaec207064
Contents?: true
Size: 654 Bytes
Versions: 69
Compression:
Stored size: 654 Bytes
Contents
var forOwn = require('./forOwn'); var size = require('./size'); /** * Object reduce */ function reduce(obj, callback, memo, thisObj) { var initial = arguments.length > 2; if (!size(obj) && !initial) { throw new Error('reduce of empty object with no initial value'); } forOwn(obj, function(value, key, list) { if (!initial) { memo = value; initial = true; } else { memo = callback.call(thisObj, memo, value, key, list); } }); return memo; } module.exports = reduce;
Version data entries
69 entries across 69 versions & 2 rubygems