🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

array-tree-filter

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-tree-filter

filter in array tree

3.0.3
latest
Source
npm
Version published
Weekly downloads
1.1M
6.97%
Maintainers
1
Weekly downloads
 
Created

What is array-tree-filter?

The array-tree-filter npm package is used to filter tree structures in JavaScript arrays. It allows you to traverse and filter nodes in a tree-like array based on a predicate function.

What are array-tree-filter's main functionalities?

Filter Tree Nodes

This feature allows you to filter nodes in a tree structure based on a predicate function. In this example, the tree is filtered to include only nodes whose value contains '1'.

const arrayTreeFilter = require('array-tree-filter');

const tree = [
  {
    value: '1',
    children: [
      { value: '1.1', children: [{ value: '1.1.1' }] },
      { value: '1.2' }
    ]
  },
  { value: '2', children: [{ value: '2.1' }] }
];

const result = arrayTreeFilter(tree, (item, level) => item.value.indexOf('1') > -1);
console.log(result);

Other packages similar to array-tree-filter

Keywords

array

FAQs

Package last updated on 23 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts