Welcome to mirror list, hosted at ThFree Co, Russian Federation.

README.markdown « archy « node_modules - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ef7a5cf34be1f36fe7cd52aa2294b2857a52b688 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# archy

Render nested hierarchies `npm ls` style with unicode pipes.

[![browser support](http://ci.testling.com/substack/node-archy.png)](http://ci.testling.com/substack/node-archy)

[![build status](https://secure.travis-ci.org/substack/node-archy.png)](http://travis-ci.org/substack/node-archy)

# example

``` js
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](http://npmjs.org) do:

```
npm install archy
```

# license

MIT