tree-to-string
npm install tree-to-string
Usage
const treeToString = require('tree-to-string')
const tree = {
value: [7],
children: [{
value: [3, 5],
children: [{
value: [2]
}, {
value: [4]
}, {
value: [6]
}]
}, {
value: [8]
}]
}
console.log(treeToString(tree))
Running the above prints something similar to
[ 2 ]ββ
β
[ 4 ]ββΌβ[ 3, 5 ]ββ
β β
[ 6 ]ββ ββ[ 7 ]
β
[ 8 ]ββ
API
const str = treeToString(tree, [format])
Converts a tree to a human friendly string. The tree should have a layout similar to this
{
value: someJsObject,
children: [tree, ...]
}
Format defaults to util.inspect
. Change this to your
own method that pretty prints your object if your prefer.
License
MIT