Print tree
npm install @prostojs/treeLight and easy output in tree library.
```
ProstoTree
└── Light and easy
npm: npm install @prostojs/tree
Via CDN:
``
`js
const { ProstoTree } = require('@prostojs/tree')
const tree = new ProstoTree()
tree.print({
label: 'root node',
children: [
{ label: 'node with label' },
'some node',
{
label: 'big',
children: [
'more',
'nodes',
{ label: 'nested', children: ['deep', 'deep2'] },
'nested ends',
],
},
'small',
],
})
`
`js
const options = {
label: '
children: '
renderLabel: (node) => '
branchWidth: 2, // the horizontal length of branch tail
branches: {
vLine: '│', // vertical line character
hLine: '─', // horizontal line character (repeated
end: '└', // ending branch character
middle: '├', // middle branch character
}
}
const tree = new ProstoTree(options)
// render tree to string
const stringResult = tree.render(/ tree, renderOptions? /)
// console.log tree
tree.print(/ tree, renderOptions? /)
`
`js
const renderOptions = {
// limits the output to go as deep as the
// level value
level: 3,
// limits the output count of direct children
// nodes upto the childrenLimit value
childrenLimit: 5,
// when showLast === true the first items
// over the limit will be hidden
// when showLast === false the last items
// over the limit will be hidden
showLast: true,
})
``