Comparing version 0.0.1 to 0.0.2
25
index.js
@@ -1,7 +0,20 @@ | ||
module.exports = function archy (obj, prefix) { | ||
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 ? '│' : ' ') + ' '; | ||
var splitter = '\n' + prefix + (nodes.length ? chr('│') : ' ') + ' '; | ||
@@ -13,8 +26,8 @@ return prefix | ||
var more = node.nodes && node.nodes.length; | ||
var prefix_ = prefix + (last ? ' ' : '│') + ' '; | ||
var prefix_ = prefix + (last ? ' ' : chr('│')) + ' '; | ||
return prefix | ||
+ (last ? '└' : '├') + '─' | ||
+ (more ? '┬' : '─') + ' ' | ||
+ archy(node, prefix_).slice(prefix.length + 2) | ||
+ (last ? chr('└') : chr('├')) + chr('─') | ||
+ (more ? chr('┬') : chr('─')) + ' ' | ||
+ archy(node, prefix_, opts).slice(prefix.length + 2) | ||
; | ||
@@ -21,0 +34,0 @@ }).join('') |
{ | ||
"name" : "archy", | ||
"version" : "0.0.1", | ||
"version" : "0.0.2", | ||
"description" : "render nested hierarchies `npm ls` style with unicode pipes", | ||
@@ -5,0 +5,0 @@ "main" : "index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7132
9
201
93