runtime.d.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * A set of utility functions that are called by the compiled Javascript
  3. * functions, these are included locally in the output of {@link MessageFormat.compile compile()}.
  4. */
  5. /** @private */
  6. export declare function _nf(lc: string): Intl.NumberFormat;
  7. /**
  8. * Utility function for `#` in plural rules
  9. *
  10. * @param lc The current locale
  11. * @param value The value to operate on
  12. * @param offset An offset, set by the surrounding context
  13. * @returns The result of applying the offset to the input value
  14. */
  15. export declare function number(lc: string, value: number, offset: number): string;
  16. /**
  17. * Strict utility function for `#` in plural rules
  18. *
  19. * Will throw an Error if `value` or `offset` are non-numeric.
  20. *
  21. * @param lc The current locale
  22. * @param value The value to operate on
  23. * @param offset An offset, set by the surrounding context
  24. * @param name The name of the argument, used for error reporting
  25. * @returns The result of applying the offset to the input value
  26. */
  27. export declare function strictNumber(lc: string, value: number, offset: number, name: string): string;
  28. /**
  29. * Utility function for `{N, plural|selectordinal, ...}`
  30. *
  31. * @param value The key to use to find a pluralization rule
  32. * @param offset An offset to apply to `value`
  33. * @param lcfunc A locale function from `pluralFuncs`
  34. * @param data The object from which results are looked up
  35. * @param isOrdinal If true, use ordinal rather than cardinal rules
  36. * @returns The result of the pluralization
  37. */
  38. export declare function plural(value: number, offset: number, lcfunc: (value: number, isOrdinal?: boolean) => string, data: {
  39. [key: string]: unknown;
  40. }, isOrdinal?: boolean): unknown;
  41. /**
  42. * Utility function for `{N, select, ...}`
  43. *
  44. * @param value The key to use to find a selection
  45. * @param data The object from which results are looked up
  46. * @returns The result of the select statement
  47. */
  48. export declare function select(value: string, data: {
  49. [key: string]: unknown;
  50. }): unknown;
  51. /**
  52. * Checks that all required arguments are set to defined values
  53. *
  54. * Throws on failure; otherwise returns undefined
  55. *
  56. * @param keys The required keys
  57. * @param data The data object being checked
  58. */
  59. export declare function reqArgs(keys: string[], data: {
  60. [key: string]: unknown;
  61. }): void;