Group values of two objects by their key
$ npm install group-values-by-key
const groupValuesByKey = require("group-values-by-key");
const objects = [{ a: 2 }, { a: 3, b: 1 }];
groupValuesByKey(objects); //=> { a: [ 2, 3 ], b: [ 1 ] }
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 ] }
MIT © muceres