Sha256: 7e261460730ce150b289df512ebfc68ee6daae3a8d88698d078122e8d85c8d10

Contents?: true

Size: 1.11 KB

Versions: 81

Compression:

Stored size: 1.11 KB

Contents

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('')
    ;
};

Version data entries

81 entries across 80 versions & 7 rubygems

Version Path
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/archy/index.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/archy/index.js
node-compiler-0.9.1 vendor/node/deps/npm/node_modules/archy/index.js
node-compiler-0.9.0 vendor/node-v7.2.1/deps/npm/node_modules/archy/index.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/archy/index.js
node-compiler-0.8.0 vendor/node-v7.2.0/deps/npm/node_modules/archy/index.js
trusty-festivity-extension-2.6 node_modules/bower/node_modules/archy/index.js
node-compiler-0.7.0 vendor/node-v6.9.1/deps/npm/node_modules/archy/index.js
node-compiler-0.7.0 vendor/node-v7.1.0/deps/npm/node_modules/archy/index.js
trusty-festivity-extension-2.5.19 node_modules/bower/node_modules/archy/index.js
trusty-festivity-extension-2.5.18 node_modules/bower/node_modules/archy/index.js
trusty-festivity-extension-2.5.17 node_modules/bower/node_modules/archy/index.js
trusty-festivity-extension-2.5.16 node_modules/bower/node_modules/archy/index.js
trusty-festivity-extension-2.5.15 node_modules/bower/node_modules/archy/index.js
trusty-festivity-extension-2.5.14 node_modules/bower/node_modules/archy/index.js
trusty-festivity-extension-2.5.13 node_modules/bower/node_modules/archy/index.js
trusty-festivity-extension-2.5.12 node_modules/bower/node_modules/archy/index.js
trusty-festivity-extension-2.5.11 node_modules/bower/node_modules/archy/index.js
trusty-festivity-extension-2.5.10 node_modules/bower/node_modules/archy/index.js
trusty-festivity-extension-2.5.9 node_modules/bower/node_modules/archy/index.js