parseNumberSkeleton() function

Parse an ICU NumberFormatter skeleton string into a Skeleton structure.

Signature:

export declare function parseNumberSkeleton(src: string, onError?: (err: NumberFormatError) => void): Skeleton;

Parameters

Parameter Type Description
src string The skeleton string
onError (err: NumberFormatError) => void (Optional) Called when the parser encounters a syntax error. The function will still return a Skeleton, but it may not contain information for all tokens. If not defined, the error will be thrown instead.

Returns:

Skeleton

Example

import { parseNumberSkeleton } from '@messageformat/number-skeleton'

parseNumberSkeleton('compact-short currency/GBP', console.error)
// {
//   notation: { style: 'compact-short' },
//   unit: { style: 'currency', currency: 'GBP' }
// }