(value, currency, rate = 1, exact = false)
| 77 | }; |
| 78 | |
| 79 | function formatCost(value, currency, rate = 1, exact = false) { |
| 80 | const n = (Number(value) || 0) * (Number(rate) || 1); |
| 81 | const abs = Math.abs(n); |
| 82 | const symbol = currency?.symbol || '$'; |
| 83 | if (!exact && abs >= 1000) return `${symbol}${(n / 1000).toFixed(abs >= 10000 ? 0 : 1)}k`; |
| 84 | const parts = n.toFixed(2).split('.'); |
| 85 | parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ','); |
| 86 | return `${symbol}${parts.join('.')}`; |
| 87 | } |
| 88 | |
| 89 | function formatTokensCompact(n) { |
| 90 | const v = Number(n) || 0; |
no outgoing calls