Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
flat-to-nested
Advanced tools
Convert a hierarchy from flat to nested representation.
var FlatToNested, flatToNested, flat;
FlatToNested = require('flat-to-nested');
flatToNested = new FlatToNested( /* can take a config object to use other property names */ );
flat = [
{id: 111, parent: 11},
{id: 11, parent: 1},
{id: 12, parent: 1},
{id: 1}
];
var nested = flatToNested.convert(flat);
console.log(nested);
// {
// id: 1,
// children: [
// {
// id: 11,
// children: [
// {
// id: 111
// }
// ]
// },
// {
// id: 12
// }
// ]
// }
The constructor accepts an optional object with some or all of these properties:
flatToNested = new FlatToNested({
// The name of the property with the node id in the flat representation
id: 'id',
// The name of the property with the parent node id in the flat representation
parent: 'parent',
// The name of the property that will hold the children nodes in the nested representation
children: 'children'
}});
Fork this repository and run npm install
on the project root folder to make sure you have all project dependencies installed.
Run npm run lint
This will check both source and tests for code correctness and style compliance.
Run npm test
FAQs
Convert a hierarchy from flat to nested representation.
The npm package flat-to-nested receives a total of 4,506 weekly downloads. As such, flat-to-nested popularity was classified as popular.
We found that flat-to-nested 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.