array-tree-filter
v3.0.2
Published
filter in array tree
Downloads
5,702,483
Readme
array-tree-filter
Filter and traverse nested hierarchical tree structures.
import arrayTreeFilter from 'array-tree-filter';
const data = [{
value: 'a',
children: [{
value: 'b',
children: [{
value: 'c'
}, {
value: 'd',
}]
}],
}];
const values = ['a', 'b', 'c'];
const result = arrayTreeFilter(
data, (item, level) => item.value === values[level]
);
console.log(result);
// [
// { value: 'a', children: [...] },
// { value: 'b', children: [...] },
// { value: 'c', children: [...] }
// ]