node/deps/npm/node_modules/archy
Rebecca Turner 507fc53e37 deps: upgrade npm to 3.3.10
PR-URL: https://github.com/nodejs/node/pull/3599
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-11-02 14:25:04 -05:00
..
examples npm: Upgrade to v2.1.6 2014-11-05 10:35:43 -08:00
test npm: Upgrade to v2.1.6 2014-11-05 10:35:43 -08:00
.travis.yml deps: upgrade npm to 3.3.6 2015-10-22 13:56:09 -04:00
index.js Upgrade npm to 1.1.14 2012-03-28 19:36:44 -07:00
LICENSE npm: Upgrade to v2.1.6 2014-11-05 10:35:43 -08:00
package.json deps: upgrade npm to 3.3.10 2015-11-02 14:25:04 -05:00
README.markdown npm: Upgrade to v2.1.6 2014-11-05 10:35:43 -08:00

archy

Render nested hierarchies npm ls style with unicode pipes.

browser support

build status

example

var archy = require('archy');
var s = archy({
  label : 'beep',
  nodes : [
    'ity',
    {
      label : 'boop',
      nodes : [
        {
          label : 'o_O',
          nodes : [
            {
              label : 'oh',
              nodes : [ 'hello', 'puny' ]
            },
            'human'
          ]
        },
        'party\ntime!'
      ]
    }
  ]
});
console.log(s);

output

beep
├── ity
└─┬ boop
  ├─┬ o_O
  │ ├─┬ oh
  │ │ ├── hello
  │ │ └── puny
  │ └── human
  └── party
      time!

methods

var archy = require('archy')

archy(obj, prefix='', opts={})

Return a string representation of obj with unicode pipe characters like how npm ls looks.

obj should be a tree of nested objects with 'label' and 'nodes' fields. 'label' is a string of text to display at a node level and 'nodes' is an array of the descendents of the current node.

If a node is a string, that string will be used as the 'label' and an empty array of 'nodes' will be used.

prefix gets prepended to all the lines and is used by the algorithm to recursively update.

If 'label' has newlines they will be indented at the present indentation level with the current prefix.

To disable unicode results in favor of all-ansi output set opts.unicode to false.

install

With npm do:

npm install archy

license

MIT