ascii-tree-array

0.1.1 • Public • Published

ascii-tree-array NPM version Build Status

Create ascii text trees from multidimensional arrays

Installation

$ npm install --save ascii-tree-array

Usage

const asciiTree = require('ascii-tree-array')
const data = [
  'foo',
  [
    'bar',
    'baz',
    [
      'qux',
      'qui'
    ]
  ]
]
 
asciiTree.list(data)
// => #foo\r\n##bar\r\n##baz\r\n###qux\r\n###qui
 
asciiTree.tree(data)
// =>
foo
├─ bar
└─ baz
   ├─ qux
   └─ qui

API

asciiTree.tree(array)

=> **Returns** `String`

When passing in an array, there should be only one value that is to be your root. For example:

[
  'home',
  [
    'sean'
  ]
]

is allowed. However,

[
  'home',
  'sean',
  [
    'projects'
  ]
]

is not. This is because there can only be a single root to the tree.

asciiTree.list(array)

=> Returns String

This will return a raw bullet list of your array.

License

MIT © Sean Wilson

Readme

Keywords

Package Sidebar

Install

npm i ascii-tree-array

Weekly Downloads

0

Version

0.1.1

License

MIT

Last publish

Collaborators

  • programmatical