Format a tree like structure to a depth indented string
npm install formatree
$ npm i -g formatree
`Usage
`js
const formatree = require('formatree');
const tree = { foo: { bar: 0 }, baz: 1, qux: { quux: 2 } };
formatree(tree);
// .
// ├── foo
// │ └── bar
// ├── baz
// └── qux
// └── quux
//
formatree(tree, { limit: 1, spacing: 1, values: true });
// .
// │
// ├── foo
// │
// ├── baz (1)
// │
// └── qux
//
formatree(tree, { sibling: '|-- ', lastSibling: '-- ', indent: '| ' });-- bar
// |-- baz
// -- qux-- quux
//
`API
$3
#### input
Type:
objectThe tree structure that needs to be formatted.
#### options
Type:
Object##### limit
Type:
number
Default: 0Limit the tree at a specific branch depth, 0 is no limit.
##### spacing
Type:
number
Default: 0Add some extra lines between the tree branches, 0 is no spacing.
##### values
Type:
boolean
Default: falseShow the values of the siblings in the tree
##### header
Type:
string
Default: .The first line of the tree
##### footer
Type:
string
Default: \nThe last line of the tree
##### sibling
Type:
string
Default: ├── ##### lastSibling
Type:
string
Default: └── ##### indent
Type:
string
Default: │ ##### lastIndent
Type:
string
Default: ##### parent
Type:
string
Default: Append a string after a parent branch in the tree
Themes
##### ASCII
`
{sibling: '|-- ',lastSibling: '-- ',indent: '| '}
##### Clean
`
{header: '',sibling: ' ',lastSibling: ' ',indent: ' ',lastIndent: ' ', footer: ''}
`
##### 101010
`
{header: '0',sibling: '101 ',lastSibling: '101 ',indent: '1010',lastIndent: '1010'}
`
##### Stripes
`
{sibling: '─ ',lastSibling: '─ ',indent: '──',lastIndent: '──'}
`
##### Arrows
`
{header: 'v',sibling: '> ',lastSibling: '> ',indent: '>>',lastIndent: '>>', footer: '^'}
``- formatree-cli - CLI for this module
MIT © A1rPun