( formats: CustomFormats, type: T, name: string, onError: OnErrorFn )
| 170 | } |
| 171 | |
| 172 | export 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 | } |
no test coverage detected