0.1.8 • Published 6 years ago
entries-reduce v0.1.8
entries-reduce
NOTE: entries-reduce was renamed to @extra-entries/reduce.
Reduce entries to single value with accumulator and values, like Array.reduce().
const reduce = require('entries-reduce');
// reduce(<entries>, <reduce function>, [initial value], [begin=0], [end])
// - <reduce function>(<accumulator>, <value>, <key>, <entries>)
// -> <accumulator>
reduce([22, 338, 618].entries(), (acc, v) => acc+v);
// 978
reduce(new Set([74, 207, 281]).entries(), (acc, v, k, ent) => acc+v+k, 0);
// 1124
reduce(new Map().set('GIMPS', 'prime').entries(), (acc, v, k, ent) => acc+v+k, '!');
// '!primeGIMPS'