flat-to-nested
Convert a hierarchy from flat to nested representation.
Example
var FlatToNested, flatToNested, flat;
FlatToNested = require('flat-to-nested');
flatToNested = new FlatToNested( );
flat = [
{id: 111, parent: 11},
{id: 11, parent: 1},
{id: 12, parent: 1},
{id: 1}
];
var nested = flatToNested.convert(flat);
console.log(nested);
Configuration
The constructor accepts an optional object with some or all of these properties:
flatToNested = new FlatToNested({
id: 'id',
parent: 'parent',
children: 'children'
}});
Contributing
Setup
Fork this repository and run npm install
on the project root folder to make sure you have all project dependencies installed.
Code Linting
Run npm run lint
This will check both source and tests for code correctness and style compliance.
Running Tests
Run npm test