array-tree-filter
TypeScript icon, indicating that this package has built-in type declarations

3.0.2 • Public • Published

array-tree-filter

Filter and traverse nested hierarchical tree structures.

NPM version NPM downloads codecov

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: [...] }
// ]

Readme

Keywords

Package Sidebar

Install

npm i array-tree-filter

Weekly Downloads

964,840

Version

3.0.2

License

MIT

Unpacked Size

4.37 kB

Total Files

5

Last publish

Collaborators

  • afc163