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.
npm install --save tree-morph
// add a `depth` property to each nodeconst tree1 =// only keep `type` propertyconst tree2 =// filter nodes with type=fooconst tree3 =
See more examples.
See the api documentation.
- tree-mutate Little brother of
tree-morph, but for mutable trees.
- tree-crawl Generic tree traversal library. This module uses it.
MIT © Nicolas Gryman