Render nested hierarchies npm ls
style with unicode pipes.
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!
var archy = require('archy')
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
.
With npm do:
npm install archy
MIT
# 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
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 19553 | swellard | Move and rename clients | ||
//guest/perforce_software/helix-web-services/main/source/clients/2016.1.0/javascript/node_modules/archy/readme.markdown | |||||
#1 | 18810 | tjuricek |
First-pass at JavaScript client SDK. JavaScript requires Node with Gulp to "browserfy" the library. It's the easiest way I found to use the swagger-js project; bundle up a wrapping method. There is no JavaScript reference guide. The swagger-js doesn't really document what they do very well, actually. Overall I'm not particularly impressed by swagger-js, it was hard to even figure out what the right method syntax was. We may want to invest time in doing it better. This required setting CORS response headers, which are currently defaulted to a fairly insecure setting. |