Reduce an object or array.
$ component install ianstormtaylor/reduce
Arrays:
var reduce = require('reduce');
reduce([1, 2, 3], 0, function (curr, val, i) {
return curr + val;
});
// 6
Objects:
var reduce = require('reduce');
reduce({ a: 1, b: 2, c: 3 }, 0, function (curr, key, val) {
return curr + val;
});
// 6
Reduce the obj
using an iterator
and starting with the memo
.
MIT