group-values-by-key
v1.0.1
Published
Group values of two objects by their key
Downloads
2
Readme
group-values-by-key
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