Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

ts-tree-tools

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

ts-tree-tools

the tools for tree

unpublished
latest
Source
npmnpm
Version
0.0.8
Version published
Maintainers
0
Created
Source

TS Tools for processing tree structure

Introduction

Ts-Tree-Tools(TTs) is based on tree-tool, with no dependencies and small size.

How to install

# 使用pnpm
pnpm install ts-tree-tools

# 使用npm
npm install ts-tree-tools

# 使用yarn
yarn install ts-tree-tools

How to use

Import

// commonjs
const TTs = require('ts-tree-tools')

// es6
import TTs from 'ts-tree-tools'

Usage

API

The following methods are available in this library:

MethodDescription
toTreeConverts a flat list structure into a hierarchical tree structure.
toListConverts a hierarchical tree structure back into a flat list structure.
findNodeByIdBFSFinds the first node by its id using a breadth-first search (BFS) approach.
findNodeByIdDFSFinds the first node by its id using a depth-first search (DFS) approach.
findNodeByFuncFinds the first node that satisfies a given function condition in the tree.
findAllNodeFinds all nodes that satisfy a given function condition in the tree.
findPathByIdBFSFinds the path from the root to the first node with the specified id using BFS.
findPathByIdDFSFinds the path from the root to the first node with the specified id using DFS.
findPathByFuncBFSFinds the path from the root to the first node that satisfies a given function using BFS.
findPathByFuncDFSFinds the path from the root to the first node that satisfies a given function using DFS.
findPathAllFinds all paths from the root to all nodes that satisfy a given function condition in the tree.

Keywords

tree

FAQs

Package last updated on 26 Aug 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