MCPcopy Create free account
hub / github.com/Dimillian/CodexMonitor / formatCompactNumber

Function formatCompactNumber

src/features/home/homeFormatters.ts:3–20  ·  view source on GitHub ↗
(value: number | null | undefined)

Source from the content-addressed store, hash-verified

1import type { AccountSnapshot, LocalUsageDay } from "../../types";
2
3export function formatCompactNumber(value: number | null | undefined) {
4 if (value === null || value === undefined) {
5 return "--";
6 }
7 if (value >= 1_000_000_000) {
8 const scaled = value / 1_000_000_000;
9 return `${scaled.toFixed(scaled >= 10 ? 0 : 1)}b`;
10 }
11 if (value >= 1_000_000) {
12 const scaled = value / 1_000_000;
13 return `${scaled.toFixed(scaled >= 10 ? 0 : 1)}m`;
14 }
15 if (value >= 1_000) {
16 const scaled = value / 1_000;
17 return `${scaled.toFixed(scaled >= 10 ? 0 : 1)}k`;
18 }
19 return String(value);
20}
21
22export function formatCount(value: number | null | undefined) {
23 if (value === null || value === undefined) {

Callers 1

buildHomeUsageViewModelFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected