(
config: {
locale: string
formats: CustomFormats
onError: OnErrorFn
},
getNumberFormat: Formatters['getNumberFormat'],
value: Parameters<IntlFormatters['formatNumber']>[0],
options: Parameters<IntlFormatters['formatNumber']>[1] = {}
)
| 88 | } |
| 89 | |
| 90 | export function formatNumberToParts( |
| 91 | config: { |
| 92 | locale: string |
| 93 | formats: CustomFormats |
| 94 | onError: OnErrorFn |
| 95 | }, |
| 96 | getNumberFormat: Formatters['getNumberFormat'], |
| 97 | value: Parameters<IntlFormatters['formatNumber']>[0], |
| 98 | options: Parameters<IntlFormatters['formatNumber']>[1] = {} |
| 99 | ): Intl.NumberFormatPart[] { |
| 100 | try { |
| 101 | return getFormatter(config, getNumberFormat, options).formatToParts( |
| 102 | value as number |
| 103 | ) |
| 104 | } catch (e) { |
| 105 | config.onError( |
| 106 | new IntlFormatError('Error formatting number.', config.locale, e) |
| 107 | ) |
| 108 | } |
| 109 | |
| 110 | return [] |
| 111 | } |
nothing calls this directly
no test coverage detected