(
{
locale,
formats,
onError,
}: {
locale: string
formats: CustomFormats
onError: OnErrorFn
},
getNumberFormat: Formatters['getNumberFormat'],
options: Parameters<IntlFormatters['formatNumber']>[1] = {}
)
| 39 | ] |
| 40 | |
| 41 | export function getFormatter( |
| 42 | { |
| 43 | locale, |
| 44 | formats, |
| 45 | onError, |
| 46 | }: { |
| 47 | locale: string |
| 48 | |
| 49 | formats: CustomFormats |
| 50 | onError: OnErrorFn |
| 51 | }, |
| 52 | getNumberFormat: Formatters['getNumberFormat'], |
| 53 | options: Parameters<IntlFormatters['formatNumber']>[1] = {} |
| 54 | ): Intl.NumberFormat { |
| 55 | const {format} = options |
| 56 | const defaults = ((format && |
| 57 | getNamedFormat(formats!, 'number', format, onError)) || |
| 58 | {}) as NumberFormatOptions |
| 59 | const filteredOptions = filterProps( |
| 60 | options, |
| 61 | NUMBER_FORMAT_OPTIONS, |
| 62 | defaults |
| 63 | ) as NumberFormatOptions |
| 64 | |
| 65 | return getNumberFormat(locale, filteredOptions) |
| 66 | } |
| 67 | |
| 68 | export function formatNumber( |
| 69 | config: { |
no test coverage detected