MCPcopy Create free account
hub / github.com/AmazingAng/PolyWorld / fmtBal

Function fmtBal

src/components/WalletButton.tsx:31–37  ·  view source on GitHub ↗

Format dollar amount: 3 significant digits with k/m suffix on mobile, full on desktop

(v: number)

Source from the content-addressed store, hash-verified

29
30/** Format dollar amount: 3 significant digits with k/m suffix on mobile, full on desktop */
31function fmtBal(v: number): string {
32 if (window.innerWidth > 768) return `$${v.toFixed(2)}`;
33 const abs = Math.abs(v);
34 if (abs >= 1e6) return `$${+(v / 1e6).toPrecision(3)}m`;
35 if (abs >= 1e3) return `$${+(v / 1e3).toPrecision(3)}k`;
36 return `$${Math.round(v)}`;
37}
38
39interface WalletButtonProps {
40 onRefresh?: () => void;

Callers 1

WalletButtonFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected