Version 1
[yaffs-website] / node_modules / archy / readme.markdown
1 # archy
2
3 Render nested hierarchies `npm ls` style with unicode pipes.
4
5 [![browser support](http://ci.testling.com/substack/node-archy.png)](http://ci.testling.com/substack/node-archy)
6
7 [![build status](https://secure.travis-ci.org/substack/node-archy.png)](http://travis-ci.org/substack/node-archy)
8
9 # example
10
11 ``` js
12 var archy = require('archy');
13 var s = archy({
14   label : 'beep',
15   nodes : [
16     'ity',
17     {
18       label : 'boop',
19       nodes : [
20         {
21           label : 'o_O',
22           nodes : [
23             {
24               label : 'oh',
25               nodes : [ 'hello', 'puny' ]
26             },
27             'human'
28           ]
29         },
30         'party\ntime!'
31       ]
32     }
33   ]
34 });
35 console.log(s);
36 ```
37
38 output
39
40 ```
41 beep
42 ├── ity
43 └─┬ boop
44   ├─┬ o_O
45   │ ├─┬ oh
46   │ │ ├── hello
47   │ │ └── puny
48   │ └── human
49   └── party
50       time!
51 ```
52
53 # methods
54
55 var archy = require('archy')
56
57 ## archy(obj, prefix='', opts={})
58
59 Return a string representation of `obj` with unicode pipe characters like how
60 `npm ls` looks.
61
62 `obj` should be a tree of nested objects with `'label'` and `'nodes'` fields.
63 `'label'` is a string of text to display at a node level and `'nodes'` is an
64 array of the descendents of the current node.
65
66 If a node is a string, that string will be used as the `'label'` and an empty
67 array of `'nodes'` will be used.
68
69 `prefix` gets prepended to all the lines and is used by the algorithm to
70 recursively update.
71
72 If `'label'` has newlines they will be indented at the present indentation level
73 with the current prefix.
74
75 To disable unicode results in favor of all-ansi output set `opts.unicode` to
76 `false`.
77
78 # install
79
80 With [npm](http://npmjs.org) do:
81
82 ```
83 npm install archy
84 ```
85
86 # license
87
88 MIT