Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

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

install

npm i ascii-tree-array

Downloadsweekly downloads

4

version

0.1.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar