]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/archy/index.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / archy / index.js
diff --git a/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/archy/index.js b/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/archy/index.js
new file mode 100644 (file)
index 0000000..869d64e
--- /dev/null
@@ -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('')
+    ;
+};