just-reduce-object
TypeScript icon, indicating that this package has built-in type declarations

2.3.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

npm install just-reduce-object
yarn add just-reduce-object

Reduce an object

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

Package Sidebar

Install

npm i just-reduce-object

Weekly Downloads

28,478

Version

2.3.0

License

MIT

Unpacked Size

6.3 kB

Total Files

9

Last publish

Collaborators

  • angus-c