Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

array-tree-filter

Package Overview
Dependencies
Maintainers
1
Versions
7
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.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
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

FAQs

Package last updated on 22 Oct 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc