The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 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 | } |