0.0.8 • Published 11 months ago

ts-tree-tools v0.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

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.
0.0.8

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

12 months ago