
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
group-objects-array
Advanced tools
Groups JavaScript objects array by a key and returns grouped array.
Groups the scattered objects in an array based on a groupByKey (e.g. id). For the given groupByKey value, if there is a multiple occurrence of same key (e.g., contact key for id: 3) but with unique values, then the values will be grouped into an array.
npm i group-objects-array
groupObjectArrayByKey(objArr, groupByKey)
const { groupObjectArrayByKey } = require('group-objects-array');
const objArray = [
{ id: 1, name: "John" },
{ id: 2, name: "Aaron" },
{ id: 1, age: 20 },
{ id: 2, age: 30 },
{ id: 3, name: "Michel" },
{ id: 1, address: { street: "123 Main Street", city: "NY", country: "USA" } },
{ id: 3, contact: "+01-51245 53125" },
{ id: 3, contact: "+02-51245 53125" },
{ id: 1, address: { street: "123 Main Street", city: "NY", country: "USA" } }
];
groupObjectArrayByKey(objArray, "id");
returns
[
{
id: 1,
name: "John",
age: 20,
address: { street: "123 Main Street", city: "NY", country: "USA" }
},
{
id: 2,
name: "Aaron",
age: 30
},
{
id: 3,
name: "Michel",
contact: [ "+01-51245 53125", "+02-51245 53125" ]
}
]
uniqueArray(arr)This function returns an array with duplicates removed.
const { uniqueArray } = require("group-objects-array");
const arr = [
{ name: "John", age: 30 },
{ name: "Doe", age: 29 },
{ name: "John", age: 30 },
{ name: "Michel", age: 21 }
];
uniqueArray(arr);
returns
[
{ name: "John", age: 30 },
{ name: "Doe", age: 29 },
{ name: "Michel", age: 21 }
]
isItemInArray(arr, item)This function checks if an item is in the given array.
const { isItemInArray } = require("group-objects-array");
const arr = [ { name: "John" }, "world" ];
isItemInArray(arr, { name: "John" }); // returns true
FAQs
Groups and merges array of objects by a single key.
The npm package group-objects-array receives a total of 1 weekly downloads. As such, group-objects-array popularity was classified as not popular.
We found that group-objects-array demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.