npm.io
1.0.1 • Published 6 years ago

group-values-by-key

Licence
MIT
Version
1.0.1
Deps
2
Size
6 kB
Vulns
0
Weekly
0

group-values-by-key

Build Status Coverage Status Maintainability Language grade: JavaScript tested with jest code style: prettier

Group values of two objects by their key

Install

$ npm install group-values-by-key

Usage

const groupValuesByKey = require("group-values-by-key");

const objects = [{ a: 2 }, { a: 3, b: 1 }];

groupValuesByKey(objects); //=> { a: [ 2, 3 ], b: [ 1 ] }

API

groupValuesByKey(objects) ⇒ Object

group values of two objects by their key

Returns: Object - object grouping values

Param Type Description
objects Object[] array of object

Example

groupValuesByKey({ a: 2 }, { a: 3, b: 1 }); //=> { a: [ 2, 3 ], b: [ 1 ] }

License

MIT saxjst