feat(client): step token figures up to billions in fmt
Values at 1e9 and above rendered as four-digit M figures (1055.9M); fmt now steps to a one-decimal B suffix, same style as k and M.
This commit is contained in:
1 parent
0003ceabaa
commit
77839c8d3f
2 files changed
+7
-3
No files matched your search
@@ -1,9 +1,10 @@
|
||||
/** `fmt`: the k/M suffix style shared by bars/details/stats; `fmtTime`: local HH:MM:SS. */
|
||||
/** `fmt`: the k/M/B suffix style shared by bars/details/stats; `fmtTime`: local HH:MM:SS. */
|
||||
|
||||
export function fmt(n: number | null | undefined): string {
|
||||
if (n === undefined || n === null || isNaN(n)) return '—'
|
||||
const sign = n < 0 ? '-' : ''
|
||||
const a = Math.abs(n)
|
||||
if (a >= 1e9) return sign + (a / 1e9).toFixed(1) + 'B'
|
||||
if (a >= 1e6) return sign + (a / 1e6).toFixed(1) + 'M'
|
||||
if (a >= 1000) return sign + (a / 1000).toFixed(1) + 'k'
|
||||
return sign + String(Math.round(a))
|
||||
|
||||
Reference in new issue
Block a user