11cb0ef41Sopenharmony_cimodule.exports = function archy (obj, prefix, opts) {
21cb0ef41Sopenharmony_ci    if (prefix === undefined) prefix = '';
31cb0ef41Sopenharmony_ci    if (!opts) opts = {};
41cb0ef41Sopenharmony_ci    var chr = function (s) {
51cb0ef41Sopenharmony_ci        var chars = {
61cb0ef41Sopenharmony_ci            '│' : '|',
71cb0ef41Sopenharmony_ci            '└' : '`',
81cb0ef41Sopenharmony_ci            '├' : '+',
91cb0ef41Sopenharmony_ci            '─' : '-',
101cb0ef41Sopenharmony_ci            '┬' : '-'
111cb0ef41Sopenharmony_ci        };
121cb0ef41Sopenharmony_ci        return opts.unicode === false ? chars[s] : s;
131cb0ef41Sopenharmony_ci    };
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci    if (typeof obj === 'string') obj = { label : obj };
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci    var nodes = obj.nodes || [];
181cb0ef41Sopenharmony_ci    var lines = (obj.label || '').split('\n');
191cb0ef41Sopenharmony_ci    var splitter = '\n' + prefix + (nodes.length ? chr('│') : ' ') + ' ';
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ci    return prefix
221cb0ef41Sopenharmony_ci        + lines.join(splitter) + '\n'
231cb0ef41Sopenharmony_ci        + nodes.map(function (node, ix) {
241cb0ef41Sopenharmony_ci            var last = ix === nodes.length - 1;
251cb0ef41Sopenharmony_ci            var more = node.nodes && node.nodes.length;
261cb0ef41Sopenharmony_ci            var prefix_ = prefix + (last ? ' ' : chr('│')) + ' ';
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ci            return prefix
291cb0ef41Sopenharmony_ci                + (last ? chr('└') : chr('├')) + chr('─')
301cb0ef41Sopenharmony_ci                + (more ? chr('┬') : chr('─')) + ' '
311cb0ef41Sopenharmony_ci                + archy(node, prefix_, opts).slice(prefix.length + 2)
321cb0ef41Sopenharmony_ci            ;
331cb0ef41Sopenharmony_ci        }).join('')
341cb0ef41Sopenharmony_ci    ;
351cb0ef41Sopenharmony_ci};
36