parse-skeleton.d.ts 988 B

1234567891011121314151617181920212223242526
  1. import { NumberFormatError } from './errors.js';
  2. import { Skeleton } from './types/skeleton.js';
  3. /**
  4. * Parse an {@link
  5. * https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md
  6. * | ICU NumberFormatter skeleton} string into a {@link Skeleton} structure.
  7. *
  8. * @public
  9. * @param src - The skeleton string
  10. * @param onError - Called when the parser encounters a syntax error. The
  11. * function will still return a {@link Skeleton}, but it may not contain
  12. * information for all tokens. If not defined, the error will be thrown
  13. * instead.
  14. *
  15. * @example
  16. * ```js
  17. * import { parseNumberSkeleton } from '@messageformat/number-skeleton'
  18. *
  19. * parseNumberSkeleton('compact-short currency/GBP', console.error)
  20. * // {
  21. * // notation: { style: 'compact-short' },
  22. * // unit: { style: 'currency', currency: 'GBP' }
  23. * // }
  24. * ```
  25. */
  26. export declare function parseNumberSkeleton(src: string, onError?: (err: NumberFormatError) => void): Skeleton;