Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
examples/ | 12-May-2024 | - | 51 | 48 | ||
test/ | 12-May-2024 | - | 128 | 122 | ||
.travis.yml | D | 12-May-2024 | 43 | 5 | 4 | |
LICENSE | D | 12-May-2024 | 1 KiB | 19 | 15 | |
README.markdown | D | 12-May-2024 | 1.7 KiB | 89 | 67 | |
index.js | D | 12-May-2024 | 1.1 KiB | 36 | 31 | |
package.json | D | 12-May-2024 | 1.7 KiB | 87 | 86 |
README.markdown
1# archy 2 3Render nested hierarchies `npm ls` style with unicode pipes. 4 5[](http://ci.testling.com/substack/node-archy) 6 7[](http://travis-ci.org/substack/node-archy) 8 9# example 10 11``` js 12var archy = require('archy'); 13var 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}); 35console.log(s); 36``` 37 38output 39 40``` 41beep 42├── ity 43└─┬ boop 44 ├─┬ o_O 45 │ ├─┬ oh 46 │ │ ├── hello 47 │ │ └── puny 48 │ └── human 49 └── party 50 time! 51``` 52 53# methods 54 55var archy = require('archy') 56 57## archy(obj, prefix='', opts={}) 58 59Return 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 64array of the descendents of the current node. 65 66If a node is a string, that string will be used as the `'label'` and an empty 67array of `'nodes'` will be used. 68 69`prefix` gets prepended to all the lines and is used by the algorithm to 70recursively update. 71 72If `'label'` has newlines they will be indented at the present indentation level 73with the current prefix. 74 75To disable unicode results in favor of all-ansi output set `opts.unicode` to 76`false`. 77 78# install 79 80With [npm](http://npmjs.org) do: 81 82``` 83npm install archy 84``` 85 86# license 87 88MIT 89