(amount: number, currency: string = 'USD')
| 19 | |
| 20 | // Format currency |
| 21 | export function formatCurrency(amount: number, currency: string = 'USD'): string { |
| 22 | if (currency === 'USD') { |
| 23 | if (amount < 0.01) { |
| 24 | return `$${(amount * 100).toFixed(2)}¢`; |
| 25 | } |
| 26 | return `$${amount.toFixed(4)}`; |
| 27 | } |
| 28 | if (currency === 'CNY') { |
| 29 | return `¥${amount.toFixed(2)}`; |
| 30 | } |
| 31 | return `${amount.toFixed(4)} ${currency}`; |
| 32 | } |
| 33 | |
| 34 | // Format duration in milliseconds |
| 35 | export function formatDuration(ms: number): string { |
no outgoing calls
no test coverage detected