|
2 سال پیش | |
---|---|---|
.. | ||
lib | 2 سال پیش | |
README.md | 2 سال پیش | |
index.d.ts | 2 سال پیش | |
package.json | 2 سال پیش |
Filter by keys in array tree.
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: [...] }
// ]