"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/archy/index.js" (7 Feb 2017, 1140 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 module.exports = function archy (obj, prefix, opts) {
    2     if (prefix === undefined) prefix = '';
    3     if (!opts) opts = {};
    4     var chr = function (s) {
    5         var chars = {
    6             '│' : '|',
    7             '└' : '`',
    8             '├' : '+',
    9             '─' : '-',
   10             '┬' : '-'
   11         };
   12         return opts.unicode === false ? chars[s] : s;
   13     };
   14     
   15     if (typeof obj === 'string') obj = { label : obj };
   16     
   17     var nodes = obj.nodes || [];
   18     var lines = (obj.label || '').split('\n');
   19     var splitter = '\n' + prefix + (nodes.length ? chr('│') : ' ') + ' ';
   20     
   21     return prefix
   22         + lines.join(splitter) + '\n'
   23         + nodes.map(function (node, ix) {
   24             var last = ix === nodes.length - 1;
   25             var more = node.nodes && node.nodes.length;
   26             var prefix_ = prefix + (last ? ' ' : chr('│')) + ' ';
   27             
   28             return prefix
   29                 + (last ? chr('└') : chr('├')) + chr('─')
   30                 + (more ? chr('┬') : chr('─')) + ' '
   31                 + archy(node, prefix_, opts).slice(prefix.length + 2)
   32             ;
   33         }).join('')
   34     ;
   35 };