@formatjs/ecma402-abstract 3.0.6 → 3.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/262.d.ts +55 -55
  2. package/262.js +322 -327
  3. package/CanonicalizeLocaleList.d.ts +3 -3
  4. package/CanonicalizeLocaleList.js +5 -5
  5. package/CanonicalizeTimeZoneName.d.ts +13 -6
  6. package/CanonicalizeTimeZoneName.js +88 -15
  7. package/CoerceOptionsToObject.d.ts +4 -4
  8. package/CoerceOptionsToObject.js +9 -9
  9. package/DefaultNumberOption.d.ts +6 -6
  10. package/DefaultNumberOption.js +15 -15
  11. package/GetNumberOption.d.ts +5 -9
  12. package/GetNumberOption.js +10 -10
  13. package/GetOption.d.ts +12 -8
  14. package/GetOption.js +28 -28
  15. package/GetOptionsObject.d.ts +4 -4
  16. package/GetOptionsObject.js +11 -11
  17. package/GetStringOrBooleanOption.d.ts +4 -10
  18. package/GetStringOrBooleanOption.js +28 -28
  19. package/IsSanctionedSimpleUnitIdentifier.d.ts +8 -6
  20. package/IsSanctionedSimpleUnitIdentifier.js +53 -53
  21. package/IsValidTimeZoneName.d.ts +15 -7
  22. package/IsValidTimeZoneName.js +69 -15
  23. package/IsWellFormedCurrencyCode.d.ts +2 -2
  24. package/IsWellFormedCurrencyCode.js +15 -15
  25. package/IsWellFormedUnitIdentifier.d.ts +3 -3
  26. package/IsWellFormedUnitIdentifier.js +21 -22
  27. package/NumberFormat/ApplyUnsignedRoundingMode.d.ts +2 -2
  28. package/NumberFormat/ApplyUnsignedRoundingMode.js +31 -31
  29. package/NumberFormat/CollapseNumberRange.d.ts +6 -6
  30. package/NumberFormat/CollapseNumberRange.js +47 -47
  31. package/NumberFormat/ComputeExponent.d.ts +8 -8
  32. package/NumberFormat/ComputeExponent.js +48 -58
  33. package/NumberFormat/ComputeExponentForMagnitude.d.ts +6 -6
  34. package/NumberFormat/ComputeExponentForMagnitude.js +64 -63
  35. package/NumberFormat/CurrencyDigits.d.ts +3 -3
  36. package/NumberFormat/CurrencyDigits.js +5 -8
  37. package/NumberFormat/FormatApproximately.d.ts +3 -3
  38. package/NumberFormat/FormatApproximately.js +10 -6
  39. package/NumberFormat/FormatNumeric.d.ts +2 -2
  40. package/NumberFormat/FormatNumeric.js +4 -3
  41. package/NumberFormat/FormatNumericRange.d.ts +6 -6
  42. package/NumberFormat/FormatNumericRange.js +7 -9
  43. package/NumberFormat/FormatNumericRangeToParts.d.ts +6 -6
  44. package/NumberFormat/FormatNumericRangeToParts.js +12 -14
  45. package/NumberFormat/FormatNumericToParts.d.ts +3 -3
  46. package/NumberFormat/FormatNumericToParts.js +12 -12
  47. package/NumberFormat/FormatNumericToString.d.ts +7 -7
  48. package/NumberFormat/FormatNumericToString.js +79 -81
  49. package/NumberFormat/GetUnsignedRoundingMode.d.ts +1 -1
  50. package/NumberFormat/GetUnsignedRoundingMode.js +25 -24
  51. package/NumberFormat/InitializeNumberFormat.d.ts +10 -10
  52. package/NumberFormat/InitializeNumberFormat.js +83 -64
  53. package/NumberFormat/PartitionNumberPattern.d.ts +4 -4
  54. package/NumberFormat/PartitionNumberPattern.js +112 -123
  55. package/NumberFormat/PartitionNumberRangePattern.d.ts +6 -6
  56. package/NumberFormat/PartitionNumberRangePattern.js +41 -38
  57. package/NumberFormat/SetNumberFormatDigitOptions.d.ts +3 -3
  58. package/NumberFormat/SetNumberFormatDigitOptions.js +185 -174
  59. package/NumberFormat/SetNumberFormatUnitOptions.d.ts +3 -3
  60. package/NumberFormat/SetNumberFormatUnitOptions.js +62 -48
  61. package/NumberFormat/ToRawFixed.d.ts +7 -7
  62. package/NumberFormat/ToRawFixed.js +103 -107
  63. package/NumberFormat/ToRawPrecision.d.ts +7 -7
  64. package/NumberFormat/ToRawPrecision.js +199 -202
  65. package/NumberFormat/decimal-cache.d.ts +10 -10
  66. package/NumberFormat/decimal-cache.js +13 -13
  67. package/NumberFormat/digit-mapping.generated.js +781 -781
  68. package/NumberFormat/format_to_parts.d.ts +24 -20
  69. package/NumberFormat/format_to_parts.js +446 -420
  70. package/PartitionPattern.d.ts +6 -6
  71. package/PartitionPattern.js +33 -33
  72. package/SupportedLocales.d.ts +6 -6
  73. package/SupportedLocales.js +17 -17
  74. package/ToIntlMathematicalValue.d.ts +1 -1
  75. package/ToIntlMathematicalValue.js +24 -25
  76. package/constants.d.ts +1 -1
  77. package/constants.js +4 -4
  78. package/data.d.ts +1 -1
  79. package/data.js +4 -11
  80. package/index.d.ts +47 -47
  81. package/index.js +45 -45
  82. package/package.json +3 -3
  83. package/regex.generated.d.ts +1 -0
  84. package/regex.generated.js +1 -1
  85. package/types/core.d.ts +5 -5
  86. package/types/date-time.d.ts +123 -128
  87. package/types/date-time.js +6 -6
  88. package/types/displaynames.d.ts +55 -55
  89. package/types/displaynames.js +1 -1
  90. package/types/list.d.ts +11 -11
  91. package/types/list.js +1 -1
  92. package/types/number.d.ts +151 -137
  93. package/types/number.js +2 -1
  94. package/types/plural-rules.d.ts +11 -11
  95. package/types/plural-rules.js +2 -1
  96. package/types/relative-time.d.ts +26 -32
  97. package/types/relative-time.js +2 -1
  98. package/utils.d.ts +40 -14
  99. package/utils.js +63 -116
@@ -1,149 +1,144 @@
1
- export type Formats = Pick<Intl.DateTimeFormatOptions, 'weekday' | 'era' | 'year' | 'month' | 'day' | 'dayPeriod' | 'hour' | 'minute' | 'second' | 'timeZoneName'> & {
2
- fractionalSecondDigits?: 1 | 2 | 3;
3
- hour12?: boolean;
4
- pattern: string;
5
- pattern12: string;
6
- skeleton: string;
7
- rawPattern: string;
8
- rangePatterns: Record<TABLE_2 | 'default', RangePatterns>;
9
- rangePatterns12: Record<TABLE_2 | 'default', RangePatterns>;
1
+ export type Formats = Pick<Intl.DateTimeFormatOptions, "weekday" | "era" | "year" | "month" | "day" | "dayPeriod" | "hour" | "minute" | "second" | "timeZoneName"> & {
2
+ fractionalSecondDigits?: 1 | 2 | 3;
3
+ hour12?: boolean;
4
+ pattern: string;
5
+ pattern12: string;
6
+ skeleton: string;
7
+ rawPattern: string;
8
+ rangePatterns: Record<TABLE_2 | "default", RangePatterns>;
9
+ rangePatterns12: Record<TABLE_2 | "default", RangePatterns>;
10
10
  };
11
11
  export interface IntlDateTimeFormatInternal {
12
- locale: string;
13
- dataLocale: string;
14
- calendar?: string;
15
- dateStyle?: 'full' | 'long' | 'medium' | 'short';
16
- timeStyle?: 'full' | 'long' | 'medium' | 'short';
17
- weekday: 'narrow' | 'short' | 'long';
18
- era: 'narrow' | 'short' | 'long';
19
- year: '2-digit' | 'numeric';
20
- month: '2-digit' | 'numeric' | 'narrow' | 'short' | 'long';
21
- day: '2-digit' | 'numeric';
22
- dayPeriod: 'narrow' | 'short' | 'long';
23
- hour: '2-digit' | 'numeric';
24
- minute: '2-digit' | 'numeric';
25
- second: '2-digit' | 'numeric';
26
- timeZoneName: 'short' | 'long' | 'shortOffset' | 'longOffset' | 'shortGeneric' | 'longGeneric';
27
- fractionalSecondDigits?: 1 | 2 | 3;
28
- hourCycle: string;
29
- numberingSystem: string;
30
- timeZone: string;
31
- pattern: string;
32
- format: Formats;
33
- rangePatterns: Record<TABLE_2 | 'default', RangePatterns>;
34
- boundFormat?: Intl.DateTimeFormat['format'];
12
+ locale: string;
13
+ dataLocale: string;
14
+ calendar?: string;
15
+ dateStyle?: "full" | "long" | "medium" | "short";
16
+ timeStyle?: "full" | "long" | "medium" | "short";
17
+ weekday: "narrow" | "short" | "long";
18
+ era: "narrow" | "short" | "long";
19
+ year: "2-digit" | "numeric";
20
+ month: "2-digit" | "numeric" | "narrow" | "short" | "long";
21
+ day: "2-digit" | "numeric";
22
+ dayPeriod: "narrow" | "short" | "long";
23
+ hour: "2-digit" | "numeric";
24
+ minute: "2-digit" | "numeric";
25
+ second: "2-digit" | "numeric";
26
+ timeZoneName: "short" | "long" | "shortOffset" | "longOffset" | "shortGeneric" | "longGeneric";
27
+ fractionalSecondDigits?: 1 | 2 | 3;
28
+ hourCycle: string;
29
+ numberingSystem: string;
30
+ timeZone: string;
31
+ pattern: string;
32
+ format: Formats;
33
+ rangePatterns: Record<TABLE_2 | "default", RangePatterns>;
34
+ boundFormat?: Intl.DateTimeFormat["format"];
35
35
  }
36
36
  export interface RangePatternPart<T extends RangePatternType = RangePatternType> {
37
- source: T;
38
- pattern: string;
37
+ source: T;
38
+ pattern: string;
39
39
  }
40
- export type RangePatterns = Pick<Intl.DateTimeFormatOptions, 'weekday' | 'era' | 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'timeZoneName'> & {
41
- hour12?: boolean;
42
- patternParts: Array<RangePatternPart>;
40
+ export type RangePatterns = Pick<Intl.DateTimeFormatOptions, "weekday" | "era" | "year" | "month" | "day" | "hour" | "minute" | "second" | "timeZoneName"> & {
41
+ hour12?: boolean;
42
+ patternParts: Array<RangePatternPart>;
43
43
  };
44
44
  export declare enum RangePatternType {
45
- startRange = "startRange",
46
- shared = "shared",
47
- endRange = "endRange"
45
+ startRange = "startRange",
46
+ shared = "shared",
47
+ endRange = "endRange"
48
48
  }
49
- export type TABLE_6 = 'weekday' | 'era' | 'year' | 'month' | 'day' | 'dayPeriod' | 'hour' | 'minute' | 'second' | 'fractionalSecondDigits' | 'timeZoneName';
50
- export type TABLE_2 = 'era' | 'year' | 'month' | 'day' | 'dayPeriod' | 'ampm' | 'hour' | 'minute' | 'second' | 'fractionalSecondDigits';
49
+ export type TABLE_6 = "weekday" | "era" | "year" | "month" | "day" | "dayPeriod" | "hour" | "minute" | "second" | "fractionalSecondDigits" | "timeZoneName";
50
+ export type TABLE_2 = "era" | "year" | "month" | "day" | "dayPeriod" | "ampm" | "hour" | "minute" | "second" | "fractionalSecondDigits";
51
51
  export type TimeZoneNameData = Record<string, {
52
- long?: [string, string];
53
- short?: [string, string];
52
+ long?: [string, string];
53
+ short?: [string, string];
54
54
  }>;
55
55
  export interface EraData {
56
- BC: string;
57
- AD: string;
56
+ BC: string;
57
+ AD: string;
58
58
  }
59
59
  export interface DateTimeFormatLocaleInternalData {
60
- am: string;
61
- pm: string;
62
- weekday: {
63
- narrow: string[];
64
- long: string[];
65
- short: string[];
66
- };
67
- era: {
68
- narrow: EraData;
69
- long: EraData;
70
- short: EraData;
71
- };
72
- month: {
73
- narrow: string[];
74
- long: string[];
75
- short: string[];
76
- };
77
- /**
78
- * Stand-alone month names (used when month appears without other date fields)
79
- * Falls back to format month if not provided
80
- */
81
- monthStandalone?: {
82
- narrow: string[];
83
- long: string[];
84
- short: string[];
85
- };
86
- timeZoneName: TimeZoneNameData;
87
- /**
88
- * So we can construct GMT+08:00
89
- */
90
- gmtFormat: string;
91
- /**
92
- * So we can construct GMT+08:00
93
- */
94
- hourFormat: string;
95
- hourCycle: string;
96
- dateFormat: {
97
- full: Formats;
98
- long: Formats;
99
- medium: Formats;
100
- short: Formats;
101
- };
102
- timeFormat: {
103
- full: Formats;
104
- long: Formats;
105
- medium: Formats;
106
- short: Formats;
107
- };
108
- dateTimeFormat: {
109
- full: string;
110
- long: string;
111
- medium: string;
112
- short: string;
113
- };
114
- /**
115
- * Interval format fallback pattern from CLDR (e.g., "{0} – {1}" for English, "{0}~{1}" for Japanese)
116
- * Used when no specific interval format is available for a given skeleton
117
- */
118
- intervalFormatFallback: string;
119
- formats: Record<string, Formats[]>;
120
- nu: string[];
121
- hc: string[];
122
- ca: string[];
60
+ am: string;
61
+ pm: string;
62
+ weekday: {
63
+ narrow: string[];
64
+ long: string[];
65
+ short: string[];
66
+ };
67
+ era: {
68
+ narrow: EraData;
69
+ long: EraData;
70
+ short: EraData;
71
+ };
72
+ month: {
73
+ narrow: string[];
74
+ long: string[];
75
+ short: string[];
76
+ };
77
+ /**
78
+ * Stand-alone month names (used when month appears without other date fields)
79
+ * Falls back to format month if not provided
80
+ */
81
+ monthStandalone?: {
82
+ narrow: string[];
83
+ long: string[];
84
+ short: string[];
85
+ };
86
+ timeZoneName: TimeZoneNameData;
87
+ /**
88
+ * So we can construct GMT+08:00
89
+ */
90
+ gmtFormat: string;
91
+ /**
92
+ * So we can construct GMT+08:00
93
+ */
94
+ hourFormat: string;
95
+ hourCycle: string;
96
+ dateFormat: {
97
+ full: Formats;
98
+ long: Formats;
99
+ medium: Formats;
100
+ short: Formats;
101
+ };
102
+ timeFormat: {
103
+ full: Formats;
104
+ long: Formats;
105
+ medium: Formats;
106
+ short: Formats;
107
+ };
108
+ dateTimeFormat: {
109
+ full: string;
110
+ long: string;
111
+ medium: string;
112
+ short: string;
113
+ };
114
+ /**
115
+ * Interval format fallback pattern from CLDR (e.g., "{0} – {1}" for English, "{0}~{1}" for Japanese)
116
+ * Used when no specific interval format is available for a given skeleton
117
+ */
118
+ intervalFormatFallback: string;
119
+ formats: Record<string, Formats[]>;
120
+ nu: string[];
121
+ hc: string[];
122
+ ca: string[];
123
123
  }
124
124
  export type IntervalFormatsData = {
125
- intervalFormatFallback: string;
125
+ intervalFormatFallback: string;
126
126
  } & Record<string, Record<string, string>>;
127
- export interface DateTimeFormat extends Omit<Intl.DateTimeFormat, 'resolvedOptions' | 'formatRange' | 'formatRangeToParts' | 'formatToParts'> {
128
- resolvedOptions(): ResolvedDateTimeFormatOptions;
129
- formatToParts(date?: Date | number): IntlDateTimeFormatPart[];
130
- formatRange(startDate: number | Date, endDate: number | Date): string;
131
- formatRangeToParts(startDate: number | Date, endDate: number | Date): IntlDateTimeFormatPart[];
127
+ export interface DateTimeFormat extends Omit<Intl.DateTimeFormat, "resolvedOptions" | "formatRange" | "formatRangeToParts" | "formatToParts"> {
128
+ resolvedOptions(): ResolvedDateTimeFormatOptions;
129
+ formatToParts(date?: Date | number): IntlDateTimeFormatPart[];
130
+ formatRange(startDate: number | Date, endDate: number | Date): string;
131
+ formatRangeToParts(startDate: number | Date, endDate: number | Date): IntlDateTimeFormatPart[];
132
132
  }
133
133
  export interface ResolvedDateTimeFormatOptions extends Intl.ResolvedDateTimeFormatOptions {
134
- dateStyle?: 'full' | 'long' | 'medium' | 'short';
135
- timeStyle?: 'full' | 'long' | 'medium' | 'short';
136
- numberingSystem: string;
134
+ dateStyle?: "full" | "long" | "medium" | "short";
135
+ timeStyle?: "full" | "long" | "medium" | "short";
136
+ numberingSystem: string;
137
137
  }
138
- export type UnpackedZoneData = [
139
- number,
140
- string,
141
- number,
142
- boolean
143
- ];
144
- export type IntlDateTimeFormatPartType = Intl.DateTimeFormatPartTypes | 'ampm' | 'relatedYear' | 'yearName' | 'unknown' | 'fractionalSecondDigits';
138
+ export type UnpackedZoneData = [number, string, number, boolean];
139
+ export type IntlDateTimeFormatPartType = Intl.DateTimeFormatPartTypes | "ampm" | "relatedYear" | "yearName" | "unknown" | "fractionalSecondDigits";
145
140
  export interface IntlDateTimeFormatPart {
146
- type: IntlDateTimeFormatPartType;
147
- value: string | undefined;
148
- source?: RangePatternType;
141
+ type: IntlDateTimeFormatPartType;
142
+ value: string | undefined;
143
+ source?: RangePatternType;
149
144
  }
@@ -1,6 +1,6 @@
1
- export var RangePatternType;
2
- (function (RangePatternType) {
3
- RangePatternType["startRange"] = "startRange";
4
- RangePatternType["shared"] = "shared";
5
- RangePatternType["endRange"] = "endRange";
6
- })(RangePatternType || (RangePatternType = {}));
1
+ export let RangePatternType = /* @__PURE__ */ function(RangePatternType) {
2
+ RangePatternType["startRange"] = "startRange";
3
+ RangePatternType["shared"] = "shared";
4
+ RangePatternType["endRange"] = "endRange";
5
+ return RangePatternType;
6
+ }({});
@@ -1,4 +1,4 @@
1
- import { LocaleData } from './core.js';
1
+ import { type LocaleData } from "./core.js";
2
2
  type LanguageTag = string;
3
3
  type RegionCode = string;
4
4
  type ScriptCode = string;
@@ -6,60 +6,60 @@ type CurrencyCode = string;
6
6
  type CalendarCode = string;
7
7
  type DateTimeFieldCode = string;
8
8
  export interface DisplayNamesData {
9
- /**
10
- * Note that for style fields, `short` and `narrow` might not exist.
11
- * At runtime, the fallback order will be narrow -> short -> long.
12
- */
13
- types: {
14
- /**
15
- * Maps language subtag like `zh-CN` to their display names.
16
- */
17
- language: {
18
- dialect: {
19
- narrow: Record<LanguageTag, string>;
20
- short: Record<LanguageTag, string>;
21
- long: Record<LanguageTag, string>;
22
- };
23
- standard: {
24
- narrow: Record<LanguageTag, string>;
25
- short: Record<LanguageTag, string>;
26
- long: Record<LanguageTag, string>;
27
- };
28
- };
29
- region: {
30
- narrow: Record<RegionCode, string>;
31
- short: Record<RegionCode, string>;
32
- long: Record<RegionCode, string>;
33
- };
34
- script: {
35
- narrow: Record<ScriptCode, string>;
36
- short: Record<ScriptCode, string>;
37
- long: Record<ScriptCode, string>;
38
- };
39
- currency: {
40
- narrow: Record<CurrencyCode, string>;
41
- short: Record<CurrencyCode, string>;
42
- long: Record<CurrencyCode, string>;
43
- };
44
- calendar: {
45
- narrow: Record<CalendarCode, string>;
46
- short: Record<CalendarCode, string>;
47
- long: Record<CalendarCode, string>;
48
- };
49
- dateTimeField: {
50
- narrow: Record<DateTimeFieldCode, string>;
51
- short: Record<DateTimeFieldCode, string>;
52
- long: Record<DateTimeFieldCode, string>;
53
- };
54
- };
55
- /**
56
- * Not in spec, but we need this to display both language and region in display name.
57
- * e.g. zh-Hans-SG + "{0}({1})" -> 简体中文(新加坡)
58
- * Here {0} is replaced by language display name and {1} is replaced by region display name.
59
- */
60
- patterns: {
61
- locale: string;
62
- };
9
+ /**
10
+ * Note that for style fields, `short` and `narrow` might not exist.
11
+ * At runtime, the fallback order will be narrow -> short -> long.
12
+ */
13
+ types: {
14
+ /**
15
+ * Maps language subtag like `zh-CN` to their display names.
16
+ */
17
+ language: {
18
+ dialect: {
19
+ narrow: Record<LanguageTag, string>;
20
+ short: Record<LanguageTag, string>;
21
+ long: Record<LanguageTag, string>;
22
+ };
23
+ standard: {
24
+ narrow: Record<LanguageTag, string>;
25
+ short: Record<LanguageTag, string>;
26
+ long: Record<LanguageTag, string>;
27
+ };
28
+ };
29
+ region: {
30
+ narrow: Record<RegionCode, string>;
31
+ short: Record<RegionCode, string>;
32
+ long: Record<RegionCode, string>;
33
+ };
34
+ script: {
35
+ narrow: Record<ScriptCode, string>;
36
+ short: Record<ScriptCode, string>;
37
+ long: Record<ScriptCode, string>;
38
+ };
39
+ currency: {
40
+ narrow: Record<CurrencyCode, string>;
41
+ short: Record<CurrencyCode, string>;
42
+ long: Record<CurrencyCode, string>;
43
+ };
44
+ calendar: {
45
+ narrow: Record<CalendarCode, string>;
46
+ short: Record<CalendarCode, string>;
47
+ long: Record<CalendarCode, string>;
48
+ };
49
+ dateTimeField: {
50
+ narrow: Record<DateTimeFieldCode, string>;
51
+ short: Record<DateTimeFieldCode, string>;
52
+ long: Record<DateTimeFieldCode, string>;
53
+ };
54
+ };
55
+ /**
56
+ * Not in spec, but we need this to display both language and region in display name.
57
+ * e.g. zh-Hans-SG + "{0}({1})" -> 简体中文(新加坡)
58
+ * Here {0} is replaced by language display name and {1} is replaced by region display name.
59
+ */
60
+ patterns: {
61
+ locale: string;
62
+ };
63
63
  }
64
64
  export type DisplayNamesLocaleData = LocaleData<DisplayNamesData>;
65
65
  export {};
@@ -1 +1 @@
1
- export {};
1
+ import "./core.js";
package/types/list.d.ts CHANGED
@@ -1,18 +1,18 @@
1
- import { LocaleData } from './core.js';
1
+ import { type LocaleData } from "./core.js";
2
2
  export type ListPatternLocaleData = LocaleData<ListPatternFieldsData>;
3
3
  export interface ListPatternFieldsData {
4
- conjunction?: ListPatternData;
5
- disjunction?: ListPatternData;
6
- unit?: ListPatternData;
4
+ conjunction?: ListPatternData;
5
+ disjunction?: ListPatternData;
6
+ unit?: ListPatternData;
7
7
  }
8
8
  export interface ListPattern {
9
- start: string;
10
- middle: string;
11
- end: string;
12
- pair: string;
9
+ start: string;
10
+ middle: string;
11
+ end: string;
12
+ pair: string;
13
13
  }
14
14
  export interface ListPatternData {
15
- long: ListPattern;
16
- short?: ListPattern;
17
- narrow?: ListPattern;
15
+ long: ListPattern;
16
+ short?: ListPattern;
17
+ narrow?: ListPattern;
18
18
  }
package/types/list.js CHANGED
@@ -1 +1 @@
1
- export {};
1
+ import "./core.js";