
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.
dictify and arrayify
Objectopts.bystring: specify the path to get key of a item, example: `id`, `n.id`function: specify the function to get key of a item, example: item => item.id
opts.include[path]opts for inner objectpath can have dot like opts.by, which specifies the path to a inner array or dict.stringshortcut for opts.by
Make array into dict
const opts = {
by: "id",
include: {
lists: "id",
"namespace.inners": "id"
}
};
const array = [
{ id: 1, lists: [{ id: 1 }] },
{ id: 2, lists: [{ id: 1 }] },
{
id: 3,
lists: [{ id: 1 }],
namespace: {
inners: [{ id: 1 }, { id: 2 }, { id: 3 }]
}
}
];
log(dictify(array, opts));
/*
{
"1": {
"id": 1,
"lists": {
"1": {
"id": 1
}
}
},
"2": {
"id": 2,
"lists": {
"1": {
"id": 1
}
}
},
"3": {
"id": 3,
"lists": {
"1": {
"id": 1
}
},
"namespace": {
"inners": {
"1": {
"id": 1
},
"2": {
"id": 2
},
"3": {
"id": 3
}
}
}
}
}
*/
Make dict into array
const opts = {
by: "id", // by is useless here
include: {
lists: "id",
"namespace.inners": "id"
}
};
const dict = {
"1": {
id: 1,
lists: {
"1": { id: 1 }
}
},
"2": {
id: 2,
lists: {
"1": { id: 1 }
}
},
"3": {
id: 3,
lists: { "1": { id: 1 } },
namespace: {
inners: {
"1": { id: 1 },
"2": { id: 2 },
"3": { id: 3 }
}
}
}
};
log(arrayify(dict, opts));
/*
[
{
"id": 1,
"lists": [
{
"id": 1
}
]
},
{
"id": 2,
"lists": [
{
"id": 1
}
]
},
{
"id": 3,
"lists": [
{
"id": 1
}
],
"namespace": {
"inners": [
{
"id": 1
},
{
"id": 2
},
{
"id": 3
}
]
}
}
]
*/
FAQs
dictify and arrayify
We found that daify 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.