tree-flatten
v1.0.0
Published
Flatten nested tree objects to array
Downloads
3,331
Maintainers
Readme
Tree Flatten
Flatten nested tree objects to array
Install
npm install --save tree-flatten
Usage
const flatten = require('tree-flatten');
const tree = {
name: 'root-1',
children: [{
name: 'root-1-1'
}, {
name: 'root-1-2',
children:[{
name: 'root-1-2-1'
}]
}]
};
flatten(tree, 'children')
/* =>
[
{ name: 'root-1' },
{ name: 'root-1-1' },
{ name: 'root-1-2' },
{ name: 'root-1-2-1' },
]
*/
License
MIT