Phase 3: Split computed-stats.ts by responsibility

This commit is contained in:
Unknown
2026-04-24 13:20:10 +02:00
parent a528feb8e2
commit b3291c3b5e
6 changed files with 555 additions and 490 deletions
+19
View File
@@ -0,0 +1,19 @@
// ─── Number Formatting Functions ────────────────────────────────────────────────
/**
* Format a number with K, M, B suffixes for large numbers
*/
export function fmt(n: number): string {
if (!isFinite(n) || isNaN(n)) return '0';
if (n >= 1e9) return (n / 1e9).toFixed(2) + 'B';
if (n >= 1e6) return (n / 1e6).toFixed(2) + 'M';
if (n >= 1e3) return (n / 1e3).toFixed(1) + 'K';
return Math.floor(n).toString();
}
/**
* Format a number with a fixed number of decimal places
*/
export function fmtDec(n: number, d: number = 1): string {
return isFinite(n) ? n.toFixed(d) : '0';
}