(balance = 0, toUnit: string, withFormatting = false)
| 397 | * @returns {string} |
| 398 | */ |
| 399 | export function formatBalanceWithoutSuffix(balance = 0, toUnit: string, withFormatting = false): string | number { |
| 400 | if (toUnit === undefined) { |
| 401 | return balance; |
| 402 | } |
| 403 | if (toUnit === BitcoinUnit.BTC) { |
| 404 | const value = new BigNumber(balance).dividedBy(100000000).toFixed(8); |
| 405 | return removeTrailingZeros(value); |
| 406 | } else if (toUnit === BitcoinUnit.SATS) { |
| 407 | return withFormatting ? new Intl.NumberFormat().format(balance).toString() : String(balance); |
| 408 | } else { |
| 409 | console.debug('[UnitSwitch/Fiat] formatBalanceWithoutSuffix to fiat', { balance, unit: toUnit, withFormatting }); |
| 410 | return satoshiToLocalCurrency(balance); |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | /** |
| 415 | * Should be used when we need a simple string to be put in text input, for example |
no test coverage detected