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

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-03-28 06:58:18 +0400
committerisaacs <i@izs.me>2012-03-28 06:58:41 +0400
commit23958a401fe729cb151fee3006a745b32868f3de (patch)
treec58c50723a5bf3608e58d081b3c281df1c81dff8 /node_modules/archy
parent57fbc4b55691cff46dd9bf2cb25570f486049c86 (diff)
add dependency on archy from @substack
Diffstat (limited to 'node_modules/archy')
-rw-r--r--node_modules/archy/README.markdown92
-rw-r--r--node_modules/archy/examples/beep.js24
-rw-r--r--node_modules/archy/examples/multi_line.js25
-rw-r--r--node_modules/archy/index.js35
-rw-r--r--node_modules/archy/package.json52
5 files changed, 228 insertions, 0 deletions
diff --git a/node_modules/archy/README.markdown b/node_modules/archy/README.markdown
new file mode 100644
index 000000000..deaba0fd1
--- /dev/null
+++ b/node_modules/archy/README.markdown
@@ -0,0 +1,92 @@
+archy
+=====
+
+Render nested hierarchies `npm ls` style with unicode pipes.
+
+[![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/X11
diff --git a/node_modules/archy/examples/beep.js b/node_modules/archy/examples/beep.js
new file mode 100644
index 000000000..9c0704797
--- /dev/null
+++ b/node_modules/archy/examples/beep.js
@@ -0,0 +1,24 @@
+var archy = require('../');
+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);
diff --git a/node_modules/archy/examples/multi_line.js b/node_modules/archy/examples/multi_line.js
new file mode 100644
index 000000000..8afdfada9
--- /dev/null
+++ b/node_modules/archy/examples/multi_line.js
@@ -0,0 +1,25 @@
+var archy = require('../');
+
+var s = archy({
+ label : 'beep\none\ntwo',
+ nodes : [
+ 'ity',
+ {
+ label : 'boop',
+ nodes : [
+ {
+ label : 'o_O\nwheee',
+ nodes : [
+ {
+ label : 'oh',
+ nodes : [ 'hello', 'puny\nmeat' ]
+ },
+ 'creature'
+ ]
+ },
+ 'party\ntime!'
+ ]
+ }
+ ]
+});
+console.log(s);
diff --git a/node_modules/archy/index.js b/node_modules/archy/index.js
new file mode 100644
index 000000000..869d64e65
--- /dev/null
+++ b/node_modules/archy/index.js
@@ -0,0 +1,35 @@
+module.exports = function archy (obj, prefix, opts) {
+ if (prefix === undefined) prefix = '';
+ if (!opts) opts = {};
+ var chr = function (s) {
+ var chars = {
+ '│' : '|',
+ '└' : '`',
+ '├' : '+',
+ '─' : '-',
+ '┬' : '-'
+ };
+ return opts.unicode === false ? chars[s] : s;
+ };
+
+ if (typeof obj === 'string') obj = { label : obj };
+
+ var nodes = obj.nodes || [];
+ var lines = (obj.label || '').split('\n');
+ var splitter = '\n' + prefix + (nodes.length ? chr('│') : ' ') + ' ';
+
+ return prefix
+ + lines.join(splitter) + '\n'
+ + nodes.map(function (node, ix) {
+ var last = ix === nodes.length - 1;
+ var more = node.nodes && node.nodes.length;
+ var prefix_ = prefix + (last ? ' ' : chr('│')) + ' ';
+
+ return prefix
+ + (last ? chr('└') : chr('├')) + chr('─')
+ + (more ? chr('┬') : chr('─')) + ' '
+ + archy(node, prefix_, opts).slice(prefix.length + 2)
+ ;
+ }).join('')
+ ;
+};
diff --git a/node_modules/archy/package.json b/node_modules/archy/package.json
new file mode 100644
index 000000000..81c3e2669
--- /dev/null
+++ b/node_modules/archy/package.json
@@ -0,0 +1,52 @@
+{
+ "name": "archy",
+ "version": "0.0.2",
+ "description": "render nested hierarchies `npm ls` style with unicode pipes",
+ "main": "index.js",
+ "directories": {
+ "lib": ".",
+ "example": "example",
+ "test": "test"
+ },
+ "devDependencies": {
+ "tap": "~0.2.3"
+ },
+ "scripts": {
+ "test": "tap test"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/substack/node-archy.git"
+ },
+ "keywords": [
+ "hierarchy",
+ "npm ls",
+ "unicode",
+ "pretty",
+ "print"
+ ],
+ "author": {
+ "name": "James Halliday",
+ "email": "mail@substack.net",
+ "url": "http://substack.net"
+ },
+ "license": "MIT/X11",
+ "engine": {
+ "node": ">=0.4"
+ },
+ "_npmUser": {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ },
+ "_id": "archy@0.0.2",
+ "dependencies": {},
+ "optionalDependencies": {},
+ "engines": {
+ "node": "*"
+ },
+ "_engineSupported": true,
+ "_npmVersion": "1.1.13",
+ "_nodeVersion": "v0.7.7-pre",
+ "_defaultsLoaded": true,
+ "_from": "archy@0.0.2"
+}