MCPcopy Index your code
hub / github.com/formatjs/formatjs / getFormatter

Function getFormatter

packages/intl/number.ts:41–66  ·  view source on GitHub ↗
(
  {
    locale,
    formats,
    onError,
  }: {
    locale: string

    formats: CustomFormats
    onError: OnErrorFn
  },
  getNumberFormat: Formatters['getNumberFormat'],
  options: Parameters<IntlFormatters['formatNumber']>[1] = {}
)

Source from the content-addressed store, hash-verified

39]
40
41export 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
68export function formatNumber(
69 config: {

Callers 2

formatNumberFunction · 0.70
formatNumberToPartsFunction · 0.70

Calls 2

getNamedFormatFunction · 0.85
filterPropsFunction · 0.85

Tested by

no test coverage detected