(num: number, decimals: number = 0)
| 8 | |
| 9 | // Format numbers |
| 10 | export function formatNumber(num: number, decimals: number = 0): string { |
| 11 | if (num >= 1_000_000) { |
| 12 | return (num / 1_000_000).toFixed(decimals) + 'M'; |
| 13 | } |
| 14 | if (num >= 1_000) { |
| 15 | return (num / 1_000).toFixed(decimals) + 'K'; |
| 16 | } |
| 17 | return num.toFixed(decimals); |
| 18 | } |
| 19 | |
| 20 | // Format currency |
| 21 | export function formatCurrency(amount: number, currency: string = 'USD'): string { |
no outgoing calls
no test coverage detected