const tree = [
{
name: 'A',
children: [
{
name: 'B',
children: [
{
name: 'D',
},
{
name: 'E'
}
]
},
{
name: 'C',
children: [
{
name: 'F'
},
{
name: 'G'
}
]
}
]
}
]
const tree = new Tree({
data: tree,
key: 'name'
})
const keys = tree.getKeys() // -> [A,B,D,E,C,F,G]
const tree = new Tree({
data: tree,
key: 'name'
}).walk(([children, index]) => {
const child = children[index]
if(child?.name === 'B') {
return false
}
return true
})
// output:
// [{
// "name": "A",
// "children": [{
// "name": "C",
// "children": [{
// "name": "F",
// "children": []
// }, {
// "name": "G",
// "children": []
// }]
// }]
// }]
- arrayIntegrate
- uniqConcat