tree-morph
Agnostic tree morphing library.
tree-morph allows you to apply either homomorphisms or isomorphisms to an immutable tree. You can mutate nodes at a data level and at a structural level. In other words, tree-morph
lets you easily create high-order functions such as map or filter that work well with your tree structure.
tree-morph
works around mutators. Those mutators contain logic to handle tree mutations. Depending on your needs and your tree structure, you can mutate your tree however you want, making tree-morph
a versatile and agnostic tree mutation library.
Install
npm install --save tree-morph
Usage
// add a `depth` property to each nodeconst tree1 = // only keep `type` propertyconst tree2 = // filter nodes with type=fooconst tree3 =
See more examples.
API
See the api documentation.
Related
- tree-mutate Little brother of
tree-morph
, but for mutable trees. - tree-crawl Generic tree traversal library. This module uses it.
License
MIT © Nicolas Gryman