Refactor: minor changes here and there

This commit is contained in:
SukkaW
2024-11-21 00:10:32 +08:00
parent 484afab42c
commit ff8163eccc
7 changed files with 82 additions and 55 deletions

View File

@@ -148,7 +148,15 @@ export async function whyIsNodeRunning() {
export function printTraceResult(traceResult: TraceResult = rootTraceResult) {
printStats(traceResult.children);
printTree(traceResult, node => `${node.name} ${picocolors.bold(`${(node.end - node.start).toFixed(3)}ms`)}`);
printTree(
traceResult,
node => {
if (node.end - node.start < 0) {
return node.name;
}
return `${node.name} ${picocolors.bold(`${(node.end - node.start).toFixed(3)}ms`)}`;
}
);
}
function printTree(initialTree: TraceResult, printNode: (node: TraceResult, branch: string) => string) {