(input: number, type: FormatterType, conversionRate?: number)
| 448 | } |
| 449 | |
| 450 | function getFormatterRule(input: number, type: FormatterType, conversionRate?: number): FormatterRule { |
| 451 | const rules = Array.isArray(type) ? type : TYPE_TO_FORMATTER_RULES[type] |
| 452 | for (const rule of rules) { |
| 453 | const shouldConvertInput = rule.formatterOptions.currency && conversionRate |
| 454 | const convertedInput = shouldConvertInput ? input * conversionRate : input |
| 455 | |
| 456 | if ( |
| 457 | (rule.exact !== undefined && convertedInput === rule.exact) || |
| 458 | (rule.upperBound !== undefined && convertedInput < rule.upperBound) |
| 459 | ) { |
| 460 | return rule |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | throw new Error(`formatter for type ${type} not configured correctly`) |
| 465 | } |
| 466 | |
| 467 | interface FormatNumberOptions { |
| 468 | input: Nullish<number> |
no outgoing calls
no test coverage detected
searching dependent graphs…