group-values-by-key

Group values of two objects by their key

Usage no npm install needed!

<script type="module">
  import groupValuesByKey from 'https://cdn.skypack.dev/group-values-by-key';
</script>

README

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