npm

npm’s 2019 JavaScript ecosystem survey analysis is now available! Get your copy here »

just-reduce-object

1.1.0 • Public • Published

just-reduce-object

Part of a library of zero-dependency npm modules that do just do one thing. Guilt-free utilities for every occasion.

Try it now

import reduce from 'just-reduce-object';
 
// applies a function against an accumulator and each key-value pairs of the object
// to reduce it to a single value
reduce({a: 3, b: 5, c: 9}, (acc, key, value, index, keys) => {
  acc[value] = key;
  return acc;
}, {}); // {3: 'a', 5: 'b', 9: 'c'}
 
reduce({a: 3, b: 5, c: 9}, (acc, key, value, index, keys) => {
  acc += value;
  return acc;
}); // 17

install

npm i just-reduce-object

Downloadsweekly downloads

3,347

version

1.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability