inference-server
Version:
Libraries and server to build AI applications. Adapters to various native bindings allowing local inference. Integrate it with your application, or use as a microservice.
23 lines • 992 B
JavaScript
import chalk from 'chalk';
export function renderTreeView(tree, prefix = '', isLast = true) {
const output = [];
for (let i = 0; i < tree.length; i++) {
const item = tree[i];
const isLastItem = i === tree.length - 1;
const branch = isLastItem ? '└── ' : '├── ';
const childPrefix = prefix + (isLastItem ? ' ' : '│ ');
const color = item.isModelLocation ? chalk.blue : chalk.gray;
if (item.type === 'directory') {
output.push(`${prefix}${branch}${color(item.name)} ${chalk.yellow(`(${item.sizeFormatted})`)}`);
if (item.children) {
const childLines = renderTreeView(item.children, childPrefix, isLastItem);
output.push(...childLines);
}
}
else {
output.push(`${prefix}${branch}${color(item.name)} ${chalk.yellow(`(${item.sizeFormatted})`)}`);
}
}
return output;
}
//# sourceMappingURL=renderTreeView.js.map