@formatjs/ecma402-abstract 1.0.3 → 1.2.2

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 (242) hide show
  1. package/262.d.ts +79 -0
  2. package/262.d.ts.map +1 -0
  3. package/262.js +336 -0
  4. package/_validate_dist-base_options.optionsvalid.d.ts +2 -1
  5. package/_validate_dist-esm_options.optionsvalid.d.ts +2 -1
  6. package/index.d.ts +33 -0
  7. package/index.d.ts.map +1 -1
  8. package/index.js +52 -11
  9. package/lib/262.d.ts +79 -0
  10. package/lib/262.d.ts.map +1 -0
  11. package/lib/262.js +312 -0
  12. package/lib/index.d.ts +33 -0
  13. package/lib/index.d.ts.map +1 -1
  14. package/lib/index.js +33 -0
  15. package/lib/src/CanonicalizeLocaleList.d.ts +6 -0
  16. package/lib/src/CanonicalizeLocaleList.d.ts.map +1 -0
  17. package/lib/src/CanonicalizeLocaleList.js +8 -0
  18. package/lib/src/CanonicalizeTimeZoneName.d.ts +9 -0
  19. package/lib/src/CanonicalizeTimeZoneName.d.ts.map +1 -0
  20. package/lib/src/CanonicalizeTimeZoneName.js +17 -0
  21. package/lib/src/DateTimeFormat/BasicFormatMatcher.d.ts +8 -0
  22. package/lib/src/DateTimeFormat/BasicFormatMatcher.d.ts.map +1 -0
  23. package/lib/src/DateTimeFormat/BasicFormatMatcher.js +61 -0
  24. package/lib/src/DateTimeFormat/BestFitFormatMatcher.d.ts +17 -0
  25. package/lib/src/DateTimeFormat/BestFitFormatMatcher.d.ts.map +1 -0
  26. package/lib/src/DateTimeFormat/BestFitFormatMatcher.js +119 -0
  27. package/lib/src/DateTimeFormat/DateTimeStyleFormat.d.ts +3 -0
  28. package/lib/src/DateTimeFormat/DateTimeStyleFormat.d.ts.map +1 -0
  29. package/lib/src/DateTimeFormat/DateTimeStyleFormat.js +50 -0
  30. package/lib/src/DateTimeFormat/FormatDateTime.d.ts +8 -0
  31. package/lib/src/DateTimeFormat/FormatDateTime.d.ts.map +1 -0
  32. package/lib/src/DateTimeFormat/FormatDateTime.js +15 -0
  33. package/lib/src/DateTimeFormat/FormatDateTimeToParts.d.ts +10 -0
  34. package/lib/src/DateTimeFormat/FormatDateTimeToParts.d.ts.map +1 -0
  35. package/lib/src/DateTimeFormat/FormatDateTimeToParts.js +21 -0
  36. package/lib/src/DateTimeFormat/InitializeDateTimeFormat.d.ts +18 -0
  37. package/lib/src/DateTimeFormat/InitializeDateTimeFormat.d.ts.map +1 -0
  38. package/lib/src/DateTimeFormat/InitializeDateTimeFormat.js +163 -0
  39. package/lib/src/DateTimeFormat/PartitionDateTimePattern.d.ts +13 -0
  40. package/lib/src/DateTimeFormat/PartitionDateTimePattern.d.ts.map +1 -0
  41. package/lib/src/DateTimeFormat/PartitionDateTimePattern.js +176 -0
  42. package/lib/src/DateTimeFormat/ToDateTimeOptions.d.ts +9 -0
  43. package/lib/src/DateTimeFormat/ToDateTimeOptions.d.ts.map +1 -0
  44. package/lib/src/DateTimeFormat/ToDateTimeOptions.js +57 -0
  45. package/lib/src/DateTimeFormat/ToLocalTime.d.ts +24 -0
  46. package/lib/src/DateTimeFormat/ToLocalTime.d.ts.map +1 -0
  47. package/lib/src/DateTimeFormat/ToLocalTime.js +49 -0
  48. package/lib/src/DateTimeFormat/skeleton.d.ts +9 -0
  49. package/lib/src/DateTimeFormat/skeleton.d.ts.map +1 -0
  50. package/lib/src/DateTimeFormat/skeleton.js +163 -0
  51. package/lib/src/DateTimeFormat/utils.d.ts +10 -0
  52. package/lib/src/DateTimeFormat/utils.d.ts.map +1 -0
  53. package/lib/src/DateTimeFormat/utils.js +18 -0
  54. package/lib/src/DisplayNames/CanonicalCodeForDisplayNames.d.ts +2 -0
  55. package/lib/src/DisplayNames/CanonicalCodeForDisplayNames.d.ts.map +1 -0
  56. package/lib/src/DisplayNames/CanonicalCodeForDisplayNames.js +33 -0
  57. package/lib/src/GetOption.js +1 -1
  58. package/lib/src/IsValidTimeZoneName.d.ts +10 -0
  59. package/lib/src/IsValidTimeZoneName.d.ts.map +1 -0
  60. package/lib/src/IsValidTimeZoneName.js +11 -0
  61. package/lib/src/NumberFormat/ComputeExponent.d.ts +12 -0
  62. package/lib/src/NumberFormat/ComputeExponent.d.ts.map +1 -0
  63. package/lib/src/NumberFormat/ComputeExponent.js +39 -0
  64. package/lib/src/NumberFormat/ComputeExponentForMagnitude.d.ts +10 -0
  65. package/lib/src/NumberFormat/ComputeExponentForMagnitude.d.ts.map +1 -0
  66. package/lib/src/NumberFormat/ComputeExponentForMagnitude.js +60 -0
  67. package/lib/src/NumberFormat/CurrencyDigits.d.ts +7 -0
  68. package/lib/src/NumberFormat/CurrencyDigits.d.ts.map +1 -0
  69. package/lib/src/NumberFormat/CurrencyDigits.js +10 -0
  70. package/lib/src/NumberFormat/FormatNumericToParts.d.ts +5 -0
  71. package/lib/src/NumberFormat/FormatNumericToParts.d.ts.map +1 -0
  72. package/lib/src/NumberFormat/FormatNumericToParts.js +14 -0
  73. package/lib/src/NumberFormat/FormatNumericToString.js +1 -1
  74. package/lib/src/NumberFormat/InitializeNumberFormat.d.ts +13 -0
  75. package/lib/src/NumberFormat/InitializeNumberFormat.d.ts.map +1 -0
  76. package/lib/src/NumberFormat/InitializeNumberFormat.js +71 -0
  77. package/lib/src/NumberFormat/PartitionNumberPattern.d.ts +8 -0
  78. package/lib/src/NumberFormat/PartitionNumberPattern.d.ts.map +1 -0
  79. package/lib/src/NumberFormat/PartitionNumberPattern.js +74 -0
  80. package/lib/src/NumberFormat/SetNumberFormatUnitOptions.d.ts +8 -0
  81. package/lib/src/NumberFormat/SetNumberFormatUnitOptions.d.ts.map +1 -0
  82. package/lib/src/NumberFormat/SetNumberFormatUnitOptions.js +39 -0
  83. package/lib/src/NumberFormat/digit-mapping.json +1 -0
  84. package/lib/src/NumberFormat/format_to_parts.d.ts +22 -0
  85. package/lib/src/NumberFormat/format_to_parts.d.ts.map +1 -0
  86. package/lib/src/NumberFormat/format_to_parts.js +421 -0
  87. package/lib/src/PluralRules/GetOperands.d.ts +32 -0
  88. package/lib/src/PluralRules/GetOperands.d.ts.map +1 -0
  89. package/lib/src/PluralRules/GetOperands.js +47 -0
  90. package/lib/src/PluralRules/InitializePluralRules.d.ts +9 -0
  91. package/lib/src/PluralRules/InitializePluralRules.d.ts.map +1 -0
  92. package/lib/src/PluralRules/InitializePluralRules.js +20 -0
  93. package/lib/src/PluralRules/ResolvePlural.d.ts +13 -0
  94. package/lib/src/PluralRules/ResolvePlural.d.ts.map +1 -0
  95. package/lib/src/PluralRules/ResolvePlural.js +25 -0
  96. package/lib/src/RelativeTimeFormat/FormatRelativeTime.d.ts +5 -0
  97. package/lib/src/RelativeTimeFormat/FormatRelativeTime.d.ts.map +1 -0
  98. package/lib/src/RelativeTimeFormat/FormatRelativeTime.js +10 -0
  99. package/lib/src/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts +5 -0
  100. package/lib/src/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts.map +1 -0
  101. package/lib/src/RelativeTimeFormat/FormatRelativeTimeToParts.js +18 -0
  102. package/lib/src/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts +9 -0
  103. package/lib/src/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts.map +1 -0
  104. package/lib/src/RelativeTimeFormat/InitializeRelativeTimeFormat.js +32 -0
  105. package/lib/src/RelativeTimeFormat/MakePartsList.d.ts +3 -0
  106. package/lib/src/RelativeTimeFormat/MakePartsList.d.ts.map +1 -0
  107. package/lib/src/RelativeTimeFormat/MakePartsList.js +27 -0
  108. package/lib/src/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts +5 -0
  109. package/lib/src/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts.map +1 -0
  110. package/lib/src/RelativeTimeFormat/PartitionRelativeTimePattern.js +54 -0
  111. package/lib/src/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts +7 -0
  112. package/lib/src/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts.map +1 -0
  113. package/lib/src/RelativeTimeFormat/SingularRelativeTimeUnit.js +36 -0
  114. package/lib/src/SupportedLocales.js +1 -1
  115. package/lib/src/data.js +1 -1
  116. package/lib/types/core.js +1 -0
  117. package/lib/types/date-time.d.ts +112 -0
  118. package/lib/types/date-time.d.ts.map +1 -0
  119. package/lib/types/date-time.js +1 -0
  120. package/lib/types/displaynames.js +1 -0
  121. package/lib/types/list.js +1 -0
  122. package/lib/types/number.d.ts +44 -0
  123. package/lib/types/number.d.ts.map +1 -1
  124. package/lib/types/number.js +1 -0
  125. package/lib/types/plural-rules.d.ts +6 -0
  126. package/lib/types/plural-rules.d.ts.map +1 -1
  127. package/lib/types/plural-rules.js +1 -0
  128. package/lib/types/relative-time.d.ts +63 -0
  129. package/lib/types/relative-time.d.ts.map +1 -1
  130. package/lib/types/relative-time.js +1 -0
  131. package/package.json +2 -6
  132. package/src/CanonicalizeLocaleList.d.ts +6 -0
  133. package/src/CanonicalizeLocaleList.d.ts.map +1 -0
  134. package/src/CanonicalizeLocaleList.js +12 -0
  135. package/src/CanonicalizeTimeZoneName.d.ts +9 -0
  136. package/src/CanonicalizeTimeZoneName.d.ts.map +1 -0
  137. package/src/CanonicalizeTimeZoneName.js +21 -0
  138. package/src/DateTimeFormat/BasicFormatMatcher.d.ts +8 -0
  139. package/src/DateTimeFormat/BasicFormatMatcher.d.ts.map +1 -0
  140. package/src/DateTimeFormat/BasicFormatMatcher.js +65 -0
  141. package/src/DateTimeFormat/BestFitFormatMatcher.d.ts +17 -0
  142. package/src/DateTimeFormat/BestFitFormatMatcher.d.ts.map +1 -0
  143. package/src/DateTimeFormat/BestFitFormatMatcher.js +124 -0
  144. package/src/DateTimeFormat/DateTimeStyleFormat.d.ts +3 -0
  145. package/src/DateTimeFormat/DateTimeStyleFormat.d.ts.map +1 -0
  146. package/src/DateTimeFormat/DateTimeStyleFormat.js +54 -0
  147. package/src/DateTimeFormat/FormatDateTime.d.ts +8 -0
  148. package/src/DateTimeFormat/FormatDateTime.d.ts.map +1 -0
  149. package/src/DateTimeFormat/FormatDateTime.js +19 -0
  150. package/src/DateTimeFormat/FormatDateTimeToParts.d.ts +10 -0
  151. package/src/DateTimeFormat/FormatDateTimeToParts.d.ts.map +1 -0
  152. package/src/DateTimeFormat/FormatDateTimeToParts.js +25 -0
  153. package/src/DateTimeFormat/InitializeDateTimeFormat.d.ts +18 -0
  154. package/src/DateTimeFormat/InitializeDateTimeFormat.d.ts.map +1 -0
  155. package/src/DateTimeFormat/InitializeDateTimeFormat.js +167 -0
  156. package/src/DateTimeFormat/PartitionDateTimePattern.d.ts +13 -0
  157. package/src/DateTimeFormat/PartitionDateTimePattern.d.ts.map +1 -0
  158. package/src/DateTimeFormat/PartitionDateTimePattern.js +180 -0
  159. package/src/DateTimeFormat/ToDateTimeOptions.d.ts +9 -0
  160. package/src/DateTimeFormat/ToDateTimeOptions.d.ts.map +1 -0
  161. package/src/DateTimeFormat/ToDateTimeOptions.js +61 -0
  162. package/src/DateTimeFormat/ToLocalTime.d.ts +24 -0
  163. package/src/DateTimeFormat/ToLocalTime.d.ts.map +1 -0
  164. package/src/DateTimeFormat/ToLocalTime.js +53 -0
  165. package/src/DateTimeFormat/skeleton.d.ts +9 -0
  166. package/src/DateTimeFormat/skeleton.d.ts.map +1 -0
  167. package/src/DateTimeFormat/skeleton.js +167 -0
  168. package/src/DateTimeFormat/utils.d.ts +10 -0
  169. package/src/DateTimeFormat/utils.d.ts.map +1 -0
  170. package/src/DateTimeFormat/utils.js +21 -0
  171. package/src/DisplayNames/CanonicalCodeForDisplayNames.d.ts +2 -0
  172. package/src/DisplayNames/CanonicalCodeForDisplayNames.d.ts.map +1 -0
  173. package/src/DisplayNames/CanonicalCodeForDisplayNames.js +37 -0
  174. package/src/GetOption.js +2 -5
  175. package/src/IsValidTimeZoneName.d.ts +10 -0
  176. package/src/IsValidTimeZoneName.d.ts.map +1 -0
  177. package/src/IsValidTimeZoneName.js +15 -0
  178. package/src/NumberFormat/ComputeExponent.d.ts +12 -0
  179. package/src/NumberFormat/ComputeExponent.d.ts.map +1 -0
  180. package/src/NumberFormat/ComputeExponent.js +43 -0
  181. package/src/NumberFormat/ComputeExponentForMagnitude.d.ts +10 -0
  182. package/src/NumberFormat/ComputeExponentForMagnitude.d.ts.map +1 -0
  183. package/src/NumberFormat/ComputeExponentForMagnitude.js +64 -0
  184. package/src/NumberFormat/CurrencyDigits.d.ts +7 -0
  185. package/src/NumberFormat/CurrencyDigits.d.ts.map +1 -0
  186. package/src/NumberFormat/CurrencyDigits.js +14 -0
  187. package/src/NumberFormat/FormatNumericToParts.d.ts +5 -0
  188. package/src/NumberFormat/FormatNumericToParts.d.ts.map +1 -0
  189. package/src/NumberFormat/FormatNumericToParts.js +18 -0
  190. package/src/NumberFormat/FormatNumericToString.js +2 -5
  191. package/src/NumberFormat/InitializeNumberFormat.d.ts +13 -0
  192. package/src/NumberFormat/InitializeNumberFormat.d.ts.map +1 -0
  193. package/src/NumberFormat/InitializeNumberFormat.js +75 -0
  194. package/src/NumberFormat/PartitionNumberPattern.d.ts +8 -0
  195. package/src/NumberFormat/PartitionNumberPattern.d.ts.map +1 -0
  196. package/src/NumberFormat/PartitionNumberPattern.js +81 -0
  197. package/src/NumberFormat/SetNumberFormatUnitOptions.d.ts +8 -0
  198. package/src/NumberFormat/SetNumberFormatUnitOptions.d.ts.map +1 -0
  199. package/src/NumberFormat/SetNumberFormatUnitOptions.js +43 -0
  200. package/src/NumberFormat/digit-mapping.json +1 -0
  201. package/src/NumberFormat/format_to_parts.d.ts +22 -0
  202. package/src/NumberFormat/format_to_parts.d.ts.map +1 -0
  203. package/src/NumberFormat/format_to_parts.js +443 -0
  204. package/src/PluralRules/GetOperands.d.ts +32 -0
  205. package/src/PluralRules/GetOperands.d.ts.map +1 -0
  206. package/src/PluralRules/GetOperands.js +51 -0
  207. package/src/PluralRules/InitializePluralRules.d.ts +9 -0
  208. package/src/PluralRules/InitializePluralRules.d.ts.map +1 -0
  209. package/src/PluralRules/InitializePluralRules.js +24 -0
  210. package/src/PluralRules/ResolvePlural.d.ts +13 -0
  211. package/src/PluralRules/ResolvePlural.d.ts.map +1 -0
  212. package/src/PluralRules/ResolvePlural.js +29 -0
  213. package/src/RelativeTimeFormat/FormatRelativeTime.d.ts +5 -0
  214. package/src/RelativeTimeFormat/FormatRelativeTime.d.ts.map +1 -0
  215. package/src/RelativeTimeFormat/FormatRelativeTime.js +14 -0
  216. package/src/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts +5 -0
  217. package/src/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts.map +1 -0
  218. package/src/RelativeTimeFormat/FormatRelativeTimeToParts.js +22 -0
  219. package/src/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts +9 -0
  220. package/src/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts.map +1 -0
  221. package/src/RelativeTimeFormat/InitializeRelativeTimeFormat.js +36 -0
  222. package/src/RelativeTimeFormat/MakePartsList.d.ts +3 -0
  223. package/src/RelativeTimeFormat/MakePartsList.d.ts.map +1 -0
  224. package/src/RelativeTimeFormat/MakePartsList.js +31 -0
  225. package/src/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts +5 -0
  226. package/src/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts.map +1 -0
  227. package/src/RelativeTimeFormat/PartitionRelativeTimePattern.js +58 -0
  228. package/src/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts +7 -0
  229. package/src/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts.map +1 -0
  230. package/src/RelativeTimeFormat/SingularRelativeTimeUnit.js +40 -0
  231. package/src/SupportedLocales.js +2 -5
  232. package/src/data.js +1 -1
  233. package/types/date-time.d.ts +112 -0
  234. package/types/date-time.d.ts.map +1 -0
  235. package/types/date-time.js +2 -0
  236. package/types/number.d.ts +44 -0
  237. package/types/number.d.ts.map +1 -1
  238. package/types/plural-rules.d.ts +6 -0
  239. package/types/plural-rules.d.ts.map +1 -1
  240. package/types/relative-time.d.ts +63 -0
  241. package/types/relative-time.d.ts.map +1 -1
  242. package/types.js +1 -1
@@ -0,0 +1,57 @@
1
+ import { ToObject } from '../../262';
2
+ /**
3
+ * https://tc39.es/ecma402/#sec-todatetimeoptions
4
+ * @param options
5
+ * @param required
6
+ * @param defaults
7
+ */
8
+ export function ToDateTimeOptions(options, required, defaults) {
9
+ if (options === undefined) {
10
+ options = null;
11
+ }
12
+ else {
13
+ options = ToObject(options);
14
+ }
15
+ options = Object.create(options);
16
+ var needDefaults = true;
17
+ if (required === 'date' || required === 'any') {
18
+ for (var _i = 0, _a = ['weekday', 'year', 'month', 'day']; _i < _a.length; _i++) {
19
+ var prop = _a[_i];
20
+ var value = options[prop];
21
+ if (value !== undefined) {
22
+ needDefaults = false;
23
+ }
24
+ }
25
+ }
26
+ if (required === 'time' || required === 'any') {
27
+ for (var _b = 0, _c = ['hour', 'minute', 'second']; _b < _c.length; _b++) {
28
+ var prop = _c[_b];
29
+ var value = options[prop];
30
+ if (value !== undefined) {
31
+ needDefaults = false;
32
+ }
33
+ }
34
+ }
35
+ if (options.dateStyle !== undefined || options.timeStyle !== undefined) {
36
+ needDefaults = false;
37
+ }
38
+ if (required === 'date' && options.timeStyle) {
39
+ throw new TypeError('Intl.DateTimeFormat date was required but timeStyle was included');
40
+ }
41
+ if (required === 'time' && options.dateStyle) {
42
+ throw new TypeError('Intl.DateTimeFormat time was required but dateStyle was included');
43
+ }
44
+ if (needDefaults && (defaults === 'date' || defaults === 'all')) {
45
+ for (var _d = 0, _e = ['year', 'month', 'day']; _d < _e.length; _d++) {
46
+ var prop = _e[_d];
47
+ options[prop] = 'numeric';
48
+ }
49
+ }
50
+ if (needDefaults && (defaults === 'time' || defaults === 'all')) {
51
+ for (var _f = 0, _g = ['hour', 'minute', 'second']; _f < _g.length; _f++) {
52
+ var prop = _g[_f];
53
+ options[prop] = 'numeric';
54
+ }
55
+ }
56
+ return options;
57
+ }
@@ -0,0 +1,24 @@
1
+ import { UnpackedZoneData } from '../../types/date-time';
2
+ /**
3
+ * https://tc39.es/ecma402/#sec-tolocaltime
4
+ * @param t
5
+ * @param calendar
6
+ * @param timeZone
7
+ */
8
+ export declare function ToLocalTime(t: number, calendar: string, timeZone: string, { tzData }: {
9
+ tzData: Record<string, UnpackedZoneData[]>;
10
+ }): {
11
+ weekday: number;
12
+ era: string;
13
+ year: number;
14
+ relatedYear: undefined;
15
+ yearName: undefined;
16
+ month: number;
17
+ day: number;
18
+ hour: number;
19
+ minute: number;
20
+ second: number;
21
+ inDST: boolean;
22
+ timeZoneOffset: number;
23
+ };
24
+ //# sourceMappingURL=ToLocalTime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToLocalTime.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/ecma402-abstract/src/DateTimeFormat/ToLocalTime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAkCvD;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,EAAC,MAAM,EAAC,EAAE;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAA;CAAC,GACrD;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,SAAS,CAAC;IACvB,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;CACxB,CAyBA"}
@@ -0,0 +1,49 @@
1
+ import { invariant } from '../utils';
2
+ import { Type, YearFromTime, WeekDay, MonthFromTime, DateFromTime, HourFromTime, MinFromTime, SecFromTime, } from '../../262';
3
+ function getApplicableZoneData(t, timeZone, tzData) {
4
+ var _a;
5
+ var zoneData = tzData[timeZone];
6
+ // We don't have data for this so just say it's UTC
7
+ if (!zoneData) {
8
+ return [0, false];
9
+ }
10
+ var i = 0;
11
+ var offset = 0;
12
+ var dst = false;
13
+ for (; i <= zoneData.length; i++) {
14
+ if (i === zoneData.length || zoneData[i][0] * 1e3 >= t) {
15
+ _a = zoneData[i - 1], offset = _a[2], dst = _a[3];
16
+ break;
17
+ }
18
+ }
19
+ return [offset * 1e3, dst];
20
+ }
21
+ /**
22
+ * https://tc39.es/ecma402/#sec-tolocaltime
23
+ * @param t
24
+ * @param calendar
25
+ * @param timeZone
26
+ */
27
+ export function ToLocalTime(t, calendar, timeZone, _a) {
28
+ var tzData = _a.tzData;
29
+ invariant(Type(t) === 'Number', 'invalid time');
30
+ invariant(calendar === 'gregory', 'We only support Gregory calendar right now');
31
+ var _b = getApplicableZoneData(t, timeZone, tzData), timeZoneOffset = _b[0], inDST = _b[1];
32
+ var tz = t + timeZoneOffset;
33
+ var year = YearFromTime(tz);
34
+ return {
35
+ weekday: WeekDay(tz),
36
+ era: year < 0 ? 'BC' : 'AD',
37
+ year: year,
38
+ relatedYear: undefined,
39
+ yearName: undefined,
40
+ month: MonthFromTime(tz),
41
+ day: DateFromTime(tz),
42
+ hour: HourFromTime(tz),
43
+ minute: MinFromTime(tz),
44
+ second: SecFromTime(tz),
45
+ inDST: inDST,
46
+ // IMPORTANT: Not in spec
47
+ timeZoneOffset: timeZoneOffset,
48
+ };
49
+ }
@@ -0,0 +1,9 @@
1
+ import { Formats } from '../../types/date-time';
2
+ /**
3
+ * Parse Date time skeleton into Intl.DateTimeFormatOptions
4
+ * Ref: https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
5
+ * @public
6
+ * @param skeleton skeleton string
7
+ */
8
+ export declare function parseDateTimeSkeleton(skeleton: string, pattern?: string): Formats;
9
+ //# sourceMappingURL=skeleton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skeleton.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/ecma402-abstract/src/DateTimeFormat/skeleton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAiJ9C;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,MAAiB,GACzB,OAAO,CAqCT"}
@@ -0,0 +1,163 @@
1
+ /**
2
+ * https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
3
+ * Credit: https://github.com/caridy/intl-datetimeformat-pattern/blob/master/index.js
4
+ * with some tweaks
5
+ */
6
+ var DATE_TIME_REGEX = /(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;
7
+ // trim patterns after transformations
8
+ var expPatternTrimmer = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
9
+ function matchSkeletonPattern(match, result) {
10
+ if (result === void 0) { result = {
11
+ pattern: '',
12
+ pattern12: '',
13
+ skeleton: '',
14
+ rawPattern: '',
15
+ }; }
16
+ var len = match.length;
17
+ switch (match[0]) {
18
+ // Era
19
+ case 'G':
20
+ result.era = len === 4 ? 'long' : len === 5 ? 'narrow' : 'short';
21
+ return '{era}';
22
+ // Year
23
+ case 'y':
24
+ case 'Y':
25
+ case 'u':
26
+ case 'U':
27
+ case 'r':
28
+ result.year = len === 2 ? '2-digit' : 'numeric';
29
+ return '{year}';
30
+ // Quarter
31
+ case 'q':
32
+ case 'Q':
33
+ throw new RangeError('`w/Q` (quarter) patterns are not supported');
34
+ // Month
35
+ case 'M':
36
+ case 'L':
37
+ result.month = ['numeric', '2-digit', 'short', 'long', 'narrow'][len - 1];
38
+ return '{month}';
39
+ // Week
40
+ case 'w':
41
+ case 'W':
42
+ throw new RangeError('`w/W` (week of year) patterns are not supported');
43
+ case 'd':
44
+ result.day = ['numeric', '2-digit'][len - 1];
45
+ return '{day}';
46
+ case 'D':
47
+ case 'F':
48
+ case 'g':
49
+ result.day = 'numeric';
50
+ return '{day}';
51
+ // Weekday
52
+ case 'E':
53
+ result.weekday = len === 4 ? 'long' : len === 5 ? 'narrow' : 'short';
54
+ return '{weekday}';
55
+ case 'e':
56
+ result.weekday = [
57
+ 'numeric',
58
+ '2-digit',
59
+ 'short',
60
+ 'long',
61
+ 'narrow',
62
+ 'short',
63
+ ][len - 1];
64
+ return '{weekday}';
65
+ case 'c':
66
+ result.weekday = [
67
+ 'numeric',
68
+ undefined,
69
+ 'short',
70
+ 'long',
71
+ 'narrow',
72
+ 'short',
73
+ ][len - 1];
74
+ return '{weekday}';
75
+ // Period
76
+ case 'a': // AM, PM
77
+ case 'b': // am, pm, noon, midnight
78
+ case 'B': // flexible day periods
79
+ result.hour12 = true;
80
+ return '{ampm}';
81
+ // Hour
82
+ case 'h':
83
+ result.hour = ['numeric', '2-digit'][len - 1];
84
+ return '{hour}';
85
+ case 'H':
86
+ result.hour = ['numeric', '2-digit'][len - 1];
87
+ return '{hour}';
88
+ case 'K':
89
+ result.hour = ['numeric', '2-digit'][len - 1];
90
+ return '{hour}';
91
+ case 'k':
92
+ result.hour = ['numeric', '2-digit'][len - 1];
93
+ return '{hour}';
94
+ case 'j':
95
+ case 'J':
96
+ case 'C':
97
+ throw new RangeError('`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead');
98
+ // Minute
99
+ case 'm':
100
+ result.minute = ['numeric', '2-digit'][len - 1];
101
+ return '{minute}';
102
+ // Second
103
+ case 's':
104
+ result.second = ['numeric', '2-digit'][len - 1];
105
+ return '{second}';
106
+ case 'S':
107
+ case 'A':
108
+ result.second = 'numeric';
109
+ return '{second}';
110
+ // Zone
111
+ case 'z': // 1..3, 4: specific non-location format
112
+ case 'Z': // 1..3, 4, 5: The ISO8601 varios formats
113
+ case 'O': // 1, 4: miliseconds in day short, long
114
+ case 'v': // 1, 4: generic non-location format
115
+ case 'V': // 1, 2, 3, 4: time zone ID or city
116
+ case 'X': // 1, 2, 3, 4: The ISO8601 varios formats
117
+ case 'x': // 1, 2, 3, 4: The ISO8601 varios formats
118
+ result.timeZoneName = len < 4 ? 'short' : 'long';
119
+ return '{timeZoneName}';
120
+ }
121
+ return '';
122
+ }
123
+ /**
124
+ * Parse Date time skeleton into Intl.DateTimeFormatOptions
125
+ * Ref: https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
126
+ * @public
127
+ * @param skeleton skeleton string
128
+ */
129
+ export function parseDateTimeSkeleton(skeleton, pattern) {
130
+ if (pattern === void 0) { pattern = skeleton; }
131
+ var result = {
132
+ pattern: '',
133
+ pattern12: '',
134
+ skeleton: skeleton,
135
+ rawPattern: pattern,
136
+ };
137
+ var literals = [];
138
+ // Use skeleton to populate result, but use mapped pattern to populate pattern
139
+ result.pattern12 = pattern
140
+ // Double apostrophe
141
+ .replace(/'{2}/g, '{apostrophe}')
142
+ // Apostrophe-escaped
143
+ .replace(/'(.*?)'/g, function (_, literal) {
144
+ literals.push(literal);
145
+ return "$$" + (literals.length - 1) + "$$";
146
+ })
147
+ .replace(DATE_TIME_REGEX, matchSkeletonPattern);
148
+ skeleton.replace(DATE_TIME_REGEX, function (m) { return matchSkeletonPattern(m, result); });
149
+ //Restore literals
150
+ if (literals.length) {
151
+ result.pattern12 = result.pattern12
152
+ .replace(/\$\$(\d+)\$\$/g, function (_, i) {
153
+ return literals[+i];
154
+ })
155
+ .replace(/\{apostrophe\}/g, "'");
156
+ }
157
+ // Handle apostrophe-escaped things
158
+ result.pattern = result.pattern12
159
+ .replace(/([\s\uFEFF\xA0])\{ampm\}([\s\uFEFF\xA0])/, '$1')
160
+ .replace('{ampm}', '')
161
+ .replace(expPatternTrimmer, '');
162
+ return result;
163
+ }
@@ -0,0 +1,10 @@
1
+ import { IntlDateTimeFormatInternal, TABLE_6 } from '../../types/date-time';
2
+ export declare const DATE_TIME_PROPS: Array<keyof Pick<IntlDateTimeFormatInternal, TABLE_6>>;
3
+ export declare const removalPenalty = 120;
4
+ export declare const additionPenalty = 20;
5
+ export declare const differentNumericTypePenalty = 15;
6
+ export declare const longLessPenalty = 8;
7
+ export declare const longMorePenalty = 6;
8
+ export declare const shortLessPenalty = 6;
9
+ export declare const shortMorePenalty = 3;
10
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/ecma402-abstract/src/DateTimeFormat/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,0BAA0B,EAAE,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAE1E,eAAO,MAAM,eAAe,EAAE,KAAK,CACjC,MAAM,IAAI,CAAC,0BAA0B,EAAE,OAAO,CAAC,CAWhD,CAAC;AAEF,eAAO,MAAM,cAAc,MAAM,CAAC;AAClC,eAAO,MAAM,eAAe,KAAK,CAAC;AAClC,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAC9C,eAAO,MAAM,eAAe,IAAI,CAAC;AACjC,eAAO,MAAM,eAAe,IAAI,CAAC;AACjC,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,eAAO,MAAM,gBAAgB,IAAI,CAAC"}
@@ -0,0 +1,18 @@
1
+ export var DATE_TIME_PROPS = [
2
+ 'weekday',
3
+ 'era',
4
+ 'year',
5
+ 'month',
6
+ 'day',
7
+ 'hour',
8
+ 'minute',
9
+ 'second',
10
+ 'timeZoneName',
11
+ ];
12
+ export var removalPenalty = 120;
13
+ export var additionPenalty = 20;
14
+ export var differentNumericTypePenalty = 15;
15
+ export var longLessPenalty = 8;
16
+ export var longMorePenalty = 6;
17
+ export var shortLessPenalty = 6;
18
+ export var shortMorePenalty = 3;
@@ -0,0 +1,2 @@
1
+ export declare function CanonicalCodeForDisplayNames(type: 'language' | 'region' | 'script' | 'currency', code: string): any;
2
+ //# sourceMappingURL=CanonicalCodeForDisplayNames.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CanonicalCodeForDisplayNames.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/ecma402-abstract/src/DisplayNames/CanonicalCodeForDisplayNames.ts"],"names":[],"mappings":"AAcA,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,EACnD,IAAI,EAAE,MAAM,OAsBb"}
@@ -0,0 +1,33 @@
1
+ import { CanonicalizeLocaleList } from '../CanonicalizeLocaleList';
2
+ import { invariant } from '../utils';
3
+ import { IsWellFormedCurrencyCode } from '../IsWellFormedCurrencyCode';
4
+ var UNICODE_REGION_SUBTAG_REGEX = /^([a-z]{2}|[0-9]{3})$/i;
5
+ var ALPHA_4 = /^[a-z]{4}$/i;
6
+ function isUnicodeRegionSubtag(region) {
7
+ return UNICODE_REGION_SUBTAG_REGEX.test(region);
8
+ }
9
+ function isUnicodeScriptSubtag(script) {
10
+ return ALPHA_4.test(script);
11
+ }
12
+ export function CanonicalCodeForDisplayNames(type, code) {
13
+ if (type === 'language') {
14
+ return CanonicalizeLocaleList([code])[0];
15
+ }
16
+ if (type === 'region') {
17
+ if (!isUnicodeRegionSubtag(code)) {
18
+ throw RangeError('invalid region');
19
+ }
20
+ return code.toUpperCase();
21
+ }
22
+ if (type === 'script') {
23
+ if (!isUnicodeScriptSubtag(code)) {
24
+ throw RangeError('invalid script');
25
+ }
26
+ return "" + code[0].toUpperCase() + code.slice(1);
27
+ }
28
+ invariant(type === 'currency', 'invalid type');
29
+ if (!IsWellFormedCurrencyCode(code)) {
30
+ throw RangeError('invalid currency');
31
+ }
32
+ return code.toUpperCase();
33
+ }
@@ -1,4 +1,4 @@
1
- import ToString from 'es-abstract/2019/ToString';
1
+ import { ToString } from '../262';
2
2
  /**
3
3
  * https://tc39.es/ecma402/#sec-getoption
4
4
  * @param opts
@@ -0,0 +1,10 @@
1
+ /**
2
+ * https://tc39.es/ecma402/#sec-isvalidtimezonename
3
+ * @param tz
4
+ * @param implDetails implementation details
5
+ */
6
+ export declare function IsValidTimeZoneName(tz: string, { tzData, uppercaseLinks, }: {
7
+ tzData: Record<string, unknown>;
8
+ uppercaseLinks: Record<string, unknown>;
9
+ }): boolean;
10
+ //# sourceMappingURL=IsValidTimeZoneName.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IsValidTimeZoneName.d.ts","sourceRoot":"","sources":["../../../../../../../packages/ecma402-abstract/src/IsValidTimeZoneName.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,MAAM,EACV,EACE,MAAM,EACN,cAAc,GACf,EAAE;IACD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC,GACA,OAAO,CAIT"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * https://tc39.es/ecma402/#sec-isvalidtimezonename
3
+ * @param tz
4
+ * @param implDetails implementation details
5
+ */
6
+ export function IsValidTimeZoneName(tz, _a) {
7
+ var tzData = _a.tzData, uppercaseLinks = _a.uppercaseLinks;
8
+ var uppercasedTz = tz.toUpperCase();
9
+ var zoneNames = new Set(Object.keys(tzData).map(function (z) { return z.toUpperCase(); }));
10
+ return zoneNames.has(uppercasedTz) || uppercasedTz in uppercaseLinks;
11
+ }
@@ -0,0 +1,12 @@
1
+ import { NumberFormatInternal } from '../../types/number';
2
+ /**
3
+ * The abstract operation ComputeExponent computes an exponent (power of ten) by which to scale x
4
+ * according to the number formatting settings. It handles cases such as 999 rounding up to 1000,
5
+ * requiring a different exponent.
6
+ *
7
+ * NOT IN SPEC: it returns [exponent, magnitude].
8
+ */
9
+ export declare function ComputeExponent(numberFormat: Intl.NumberFormat, x: number, { getInternalSlots, }: {
10
+ getInternalSlots(nf: Intl.NumberFormat): NumberFormatInternal;
11
+ }): [number, number];
12
+ //# sourceMappingURL=ComputeExponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComputeExponent.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/ecma402-abstract/src/NumberFormat/ComputeExponent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,oBAAoB,EAAC,MAAM,oBAAoB,CAAC;AAExD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,CAAC,EAAE,MAAM,EACT,EACE,gBAAgB,GACjB,EAAE;IAAC,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAA;CAAC,GACjE,CAAC,MAAM,EAAE,MAAM,CAAC,CA8BlB"}
@@ -0,0 +1,39 @@
1
+ import { getMagnitude } from '../utils';
2
+ import { ComputeExponentForMagnitude } from './ComputeExponentForMagnitude';
3
+ import { FormatNumericToString } from './FormatNumericToString';
4
+ /**
5
+ * The abstract operation ComputeExponent computes an exponent (power of ten) by which to scale x
6
+ * according to the number formatting settings. It handles cases such as 999 rounding up to 1000,
7
+ * requiring a different exponent.
8
+ *
9
+ * NOT IN SPEC: it returns [exponent, magnitude].
10
+ */
11
+ export function ComputeExponent(numberFormat, x, _a) {
12
+ var getInternalSlots = _a.getInternalSlots;
13
+ if (x === 0) {
14
+ return [0, 0];
15
+ }
16
+ if (x < 0) {
17
+ x = -x;
18
+ }
19
+ var magnitude = getMagnitude(x);
20
+ var exponent = ComputeExponentForMagnitude(numberFormat, magnitude, {
21
+ getInternalSlots: getInternalSlots,
22
+ });
23
+ // Preserve more precision by doing multiplication when exponent is negative.
24
+ x = exponent < 0 ? x * Math.pow(10, -exponent) : x / Math.pow(10, exponent);
25
+ var formatNumberResult = FormatNumericToString(getInternalSlots(numberFormat), x);
26
+ if (formatNumberResult.roundedNumber === 0) {
27
+ return [exponent, magnitude];
28
+ }
29
+ var newMagnitude = getMagnitude(formatNumberResult.roundedNumber);
30
+ if (newMagnitude === magnitude - exponent) {
31
+ return [exponent, magnitude];
32
+ }
33
+ return [
34
+ ComputeExponentForMagnitude(numberFormat, magnitude + 1, {
35
+ getInternalSlots: getInternalSlots,
36
+ }),
37
+ magnitude + 1,
38
+ ];
39
+ }
@@ -0,0 +1,10 @@
1
+ import { NumberFormatInternal } from '../../types/number';
2
+ /**
3
+ * The abstract operation ComputeExponentForMagnitude computes an exponent by which to scale a
4
+ * number of the given magnitude (power of ten of the most significant digit) according to the
5
+ * locale and the desired notation (scientific, engineering, or compact).
6
+ */
7
+ export declare function ComputeExponentForMagnitude(numberFormat: Intl.NumberFormat, magnitude: number, { getInternalSlots, }: {
8
+ getInternalSlots(nf: Intl.NumberFormat): NumberFormatInternal;
9
+ }): number;
10
+ //# sourceMappingURL=ComputeExponentForMagnitude.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComputeExponentForMagnitude.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/ecma402-abstract/src/NumberFormat/ComputeExponentForMagnitude.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAmB,MAAM,oBAAoB,CAAC;AAE1E;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,SAAS,EAAE,MAAM,EACjB,EACE,gBAAgB,GACjB,EAAE;IAAC,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAA;CAAC,GACjE,MAAM,CAyDR"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * The abstract operation ComputeExponentForMagnitude computes an exponent by which to scale a
3
+ * number of the given magnitude (power of ten of the most significant digit) according to the
4
+ * locale and the desired notation (scientific, engineering, or compact).
5
+ */
6
+ export function ComputeExponentForMagnitude(numberFormat, magnitude, _a) {
7
+ var getInternalSlots = _a.getInternalSlots;
8
+ var internalSlots = getInternalSlots(numberFormat);
9
+ var notation = internalSlots.notation, dataLocaleData = internalSlots.dataLocaleData, numberingSystem = internalSlots.numberingSystem;
10
+ switch (notation) {
11
+ case 'standard':
12
+ return 0;
13
+ case 'scientific':
14
+ return magnitude;
15
+ case 'engineering':
16
+ return Math.floor(magnitude / 3) * 3;
17
+ default: {
18
+ // Let exponent be an implementation- and locale-dependent (ILD) integer by which to scale a
19
+ // number of the given magnitude in compact notation for the current locale.
20
+ var compactDisplay = internalSlots.compactDisplay, style = internalSlots.style, currencyDisplay = internalSlots.currencyDisplay;
21
+ var thresholdMap = void 0;
22
+ if (style === 'currency' && currencyDisplay !== 'name') {
23
+ var currency = dataLocaleData.numbers.currency[numberingSystem] ||
24
+ dataLocaleData.numbers.currency[dataLocaleData.numbers.nu[0]];
25
+ thresholdMap = currency.short;
26
+ }
27
+ else {
28
+ var decimal = dataLocaleData.numbers.decimal[numberingSystem] ||
29
+ dataLocaleData.numbers.decimal[dataLocaleData.numbers.nu[0]];
30
+ thresholdMap = compactDisplay === 'long' ? decimal.long : decimal.short;
31
+ }
32
+ if (!thresholdMap) {
33
+ return 0;
34
+ }
35
+ var num = String(Math.pow(10, magnitude));
36
+ var thresholds = Object.keys(thresholdMap); // TODO: this can be pre-processed
37
+ if (num < thresholds[0]) {
38
+ return 0;
39
+ }
40
+ if (num > thresholds[thresholds.length - 1]) {
41
+ return thresholds[thresholds.length - 1].length - 1;
42
+ }
43
+ var i = thresholds.indexOf(num);
44
+ if (i === -1) {
45
+ return 0;
46
+ }
47
+ // See https://unicode.org/reports/tr35/tr35-numbers.html#Compact_Number_Formats
48
+ // Special handling if the pattern is precisely `0`.
49
+ var magnitudeKey = thresholds[i];
50
+ // TODO: do we need to handle plural here?
51
+ var compactPattern = thresholdMap[magnitudeKey].other;
52
+ if (compactPattern === '0') {
53
+ return 0;
54
+ }
55
+ // Example: in zh-TW, `10000000` maps to `0000萬`. So we need to return 8 - 4 = 4 here.
56
+ return (magnitudeKey.length -
57
+ thresholdMap[magnitudeKey].other.match(/0+/)[0].length);
58
+ }
59
+ }
60
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * https://tc39.es/ecma402/#sec-currencydigits
3
+ */
4
+ export declare function CurrencyDigits(c: string, { currencyDigitsData }: {
5
+ currencyDigitsData: Record<string, number>;
6
+ }): number;
7
+ //# sourceMappingURL=CurrencyDigits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CurrencyDigits.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/ecma402-abstract/src/NumberFormat/CurrencyDigits.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,cAAc,CAC5B,CAAC,EAAE,MAAM,EACT,EAAC,kBAAkB,EAAC,EAAE;IAAC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAC,GACjE,MAAM,CAIR"}
@@ -0,0 +1,10 @@
1
+ import { HasOwnProperty } from '../../262';
2
+ /**
3
+ * https://tc39.es/ecma402/#sec-currencydigits
4
+ */
5
+ export function CurrencyDigits(c, _a) {
6
+ var currencyDigitsData = _a.currencyDigitsData;
7
+ return HasOwnProperty(currencyDigitsData, c)
8
+ ? currencyDigitsData[c]
9
+ : 2;
10
+ }
@@ -0,0 +1,5 @@
1
+ import { NumberFormatInternal, NumberFormatPart } from '../../types/number';
2
+ export declare function FormatNumericToParts(nf: Intl.NumberFormat, x: number, implDetails: {
3
+ getInternalSlots(nf: Intl.NumberFormat): NumberFormatInternal;
4
+ }): NumberFormatPart[];
5
+ //# sourceMappingURL=FormatNumericToParts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormatNumericToParts.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/ecma402-abstract/src/NumberFormat/FormatNumericToParts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,oBAAoB,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAE1E,wBAAgB,oBAAoB,CAClC,EAAE,EAAE,IAAI,CAAC,YAAY,EACrB,CAAC,EAAE,MAAM,EACT,WAAW,EAAE;IACX,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAC;CAC/D,GACA,gBAAgB,EAAE,CAWpB"}
@@ -0,0 +1,14 @@
1
+ import { PartitionNumberPattern } from './PartitionNumberPattern';
2
+ import { ArrayCreate } from '../../262';
3
+ export function FormatNumericToParts(nf, x, implDetails) {
4
+ var parts = PartitionNumberPattern(nf, x, implDetails);
5
+ var result = ArrayCreate(0);
6
+ for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
7
+ var part = parts_1[_i];
8
+ result.push({
9
+ type: part.type,
10
+ value: part.value,
11
+ });
12
+ }
13
+ return result;
14
+ }
@@ -1,4 +1,4 @@
1
- import SameValue from 'es-abstract/5/SameValue';
1
+ import { SameValue } from '../../262';
2
2
  import { ToRawPrecision } from './ToRawPrecision';
3
3
  import { repeat } from '../utils';
4
4
  import { ToRawFixed } from './ToRawFixed';
@@ -0,0 +1,13 @@
1
+ import { NumberFormatInternal, NumberFormatOptions, NumberFormatLocaleInternalData } from '../../types/number';
2
+ /**
3
+ * https://tc39.es/ecma402/#sec-initializenumberformat
4
+ */
5
+ export declare function InitializeNumberFormat(nf: Intl.NumberFormat, locales: string | string[] | undefined, opts: NumberFormatOptions | undefined, { getInternalSlots, localeData, availableLocales, numberingSystemNames, getDefaultLocale, currencyDigitsData, }: {
6
+ getInternalSlots(nf: Intl.NumberFormat): NumberFormatInternal;
7
+ localeData: Record<string, NumberFormatLocaleInternalData>;
8
+ availableLocales: string[];
9
+ numberingSystemNames: string[];
10
+ getDefaultLocale(): string;
11
+ currencyDigitsData: Record<string, number>;
12
+ }): Intl.NumberFormat;
13
+ //# sourceMappingURL=InitializeNumberFormat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InitializeNumberFormat.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/ecma402-abstract/src/NumberFormat/InitializeNumberFormat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,8BAA8B,EAC/B,MAAM,oBAAoB,CAAC;AAmB5B;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,IAAI,CAAC,YAAY,EACrB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EACtC,IAAI,EAAE,mBAAmB,GAAG,SAAS,EACrC,EACE,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,GACnB,EAAE;IACD,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAC;IAC9D,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,8BAA8B,CAAC,CAAC;IAC3D,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,gBAAgB,IAAI,MAAM,CAAC;IAC3B,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5C,qBAgHF"}