Phase 3: Split computed-stats.ts by responsibility
This commit is contained in:
@@ -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';
|
||||
}
|
||||
Reference in New Issue
Block a user