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

Function getNamedFormat

packages/intl/utils.ts:172–192  ·  view source on GitHub ↗
(
  formats: CustomFormats,
  type: T,
  name: string,
  onError: OnErrorFn
)

Source from the content-addressed store, hash-verified

170}
171
172export function getNamedFormat<T extends keyof CustomFormats>(
173 formats: CustomFormats,
174 type: T,
175 name: string,
176 onError: OnErrorFn
177):
178 | NumberFormatOptions
179 | Intl.DateTimeFormatOptions
180 | Intl.RelativeTimeFormatOptions
181 | undefined {
182 const formatType = formats && formats[type]
183 let format
184 if (formatType) {
185 format = formatType[name]
186 }
187 if (format) {
188 return format
189 }
190
191 onError(new UnsupportedFormatterError(`No ${type} format named: ${name}`))
192}

Callers 3

getFormatterFunction · 0.85
getFormatterFunction · 0.85
getFormatterFunction · 0.85

Calls 1

onErrorFunction · 0.85

Tested by

no test coverage detected