Implementation of a binary tree with both TS and flow support.
Just import the binTreeBuilder
to your project, and tell it what properties
you would like to see in the final result.
You can define it using an array of TreeCutter<T, U>
.
Example:
const cutters: TreeCutter<ValueTypes, ValueTypes>[] = [
{ type: ['Model S', 'Model 3'] }
]
Cutters tell the builder to take a node, then split the tree here
keeping all the information in the nodes, and creating two new one.
Result will be like this:
{
"node": {
"manufacturer": "Tesla"
},
"left": {
"node": {
"manufacturer": "Tesla",
"type": "Model S"
}
},
"right": {
"node": {
"manufacturer": "Tesla",
"type": "Model 3"
}
}
}
It "remembers about the history" in every node ON PURPOSE.
Another version is coming with an option to turn it off. (Need For Time ™)
You can find implementations for both Typescript and FlowJS.