MCPcopy Create free account
hub / github.com/formatjs/formatjs / formatNumberToParts

Function formatNumberToParts

packages/intl/number.ts:90–111  ·  view source on GitHub ↗
(
  config: {
    locale: string
    formats: CustomFormats
    onError: OnErrorFn
  },
  getNumberFormat: Formatters['getNumberFormat'],
  value: Parameters<IntlFormatters['formatNumber']>[0],
  options: Parameters<IntlFormatters['formatNumber']>[1] = {}
)

Source from the content-addressed store, hash-verified

88}
89
90export 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}

Callers

nothing calls this directly

Calls 2

getFormatterFunction · 0.70
formatToPartsMethod · 0.65

Tested by

no test coverage detected