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

Function createDefaultFormatters

packages/intl-messageformat/core.ts:81–102  ·  view source on GitHub ↗
(
  cache: FormatterCache = {
    number: {},
    dateTime: {},
    pluralRules: {},
  }
)

Source from the content-addressed store, hash-verified

79}
80
81function createDefaultFormatters(
82 cache: FormatterCache = {
83 number: {},
84 dateTime: {},
85 pluralRules: {},
86 }
87): Formatters {
88 return {
89 getNumberFormat: memoize((...args) => new Intl.NumberFormat(...args), {
90 cache: createFastMemoizeCache(cache.number),
91 strategy: strategies.variadic,
92 }),
93 getDateTimeFormat: memoize((...args) => new Intl.DateTimeFormat(...args), {
94 cache: createFastMemoizeCache(cache.dateTime),
95 strategy: strategies.variadic,
96 }),
97 getPluralRules: memoize((...args) => new Intl.PluralRules(...args), {
98 cache: createFastMemoizeCache(cache.pluralRules),
99 strategy: strategies.variadic,
100 }),
101 }
102}
103
104export class IntlMessageFormat {
105 private readonly ast: MessageFormatElement[]

Callers 1

constructorMethod · 0.85

Calls 2

memoizeFunction · 0.90
createFastMemoizeCacheFunction · 0.70

Tested by

no test coverage detected