node-ejs-renderer/node_modules/@jsonjoy.com/util/lib/print/printTree.js

19 lines
647 B
JavaScript
Raw Permalink Normal View History

2024-06-09 13:55:01 -04:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.printTree = void 0;
const printTree = (tab = '', children) => {
children = children.filter(Boolean);
let str = '';
for (let i = 0; i < children.length; i++) {
const isLast = i >= children.length - 1;
const fn = children[i];
if (!fn)
continue;
const child = fn(tab + `${isLast ? ' ' : '│'} `);
const branch = child ? (isLast ? '└─' : '├─') : '│ ';
str += `\n${tab}${branch} ${child}`;
}
return str;
};
exports.printTree = printTree;
//# sourceMappingURL=printTree.js.map