I’ve released a new package @lukeaus/plain-tree
.
plain-tree
is a performant plain tree library for JavaScript with all the tools (hopefully) to create, search and manage JavaScript trees.
Features
- Create trees
- manually
- from array
- Create nodes
- manually
- from array
- from object
- Search
- Find one
- Find all
- Some/Every
- Traverse (breath first and depth first)
- Nodes at height
- Nodes count
- all
- by height
- Width
- Height
- Depth
- Manipulate trees and nodes
- FlatMap
- Into single array
- Into array of arrays by height
- Convert to JSON
- … and more (see below)
More Info
Check out the source code on GitHub.