The best way to control Claude Code, Codex and more from any computer or phone

main
ts 15 lines 442 Bytes
Raw
1 export function formatContextWindowTokens(value: number | null): string {
2 if (value === null || !Number.isFinite(value)) {
3 return "0";
4 }
5 if (value < 1_000) {
6 return `${Math.round(value)}`;
7 }
8 if (value < 10_000) {
9 return `${(value / 1_000).toFixed(1).replace(/\.0$/, "")}k`;
10 }
11 if (value < 999_500) {
12 return `${Math.round(value / 1_000)}k`;
13 }
14 return `${(value / 1_000_000).toFixed(1).replace(/\.0$/, "")}m`;
15 }