base-tree-data
v0.0.4
Published
operation of tree data
Downloads
1
Readme
import {findParents} from 'base-tree-data'
let list = [
{
"id": "5a42327d9d7b2555c54e94c1",
"name": "Carney Livingston",
"children": [
{
"id": "5a42327d6c3ec84516e9a01e",
"name": "Francesca Rice",
"children": [
{
"id": "5a42327df5419a1796e7b43e",
"name": "Gladys Kramer"
},
{
"id": "5a42327d4263c504d740360d",
"name": "Kerry Pacheco"
}
]
},
{
"id": "5a42327d0f8a5a94c5ff93d2",
"name": "Acosta Perez",
"children": [
{
"id": "5a42327d1c907390edbae7d9",
"name": "Mcfadden Sloan"
}
]
}
]
}
]
let value = "Acosta Perez" ;
let valueKey = "id" ;
const parents = findParents(list,value,valueKey);
console.log("parents: ",parents);