@formatjs/ecma402-abstract 1.11.9 → 1.11.10

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 (275) hide show
  1. package/262.d.ts +92 -0
  2. package/262.d.ts.map +1 -0
  3. package/262.js +362 -0
  4. package/CanonicalizeLocaleList.d.ts +6 -0
  5. package/CanonicalizeLocaleList.d.ts.map +1 -0
  6. package/CanonicalizeLocaleList.js +12 -0
  7. package/CanonicalizeTimeZoneName.d.ts +9 -0
  8. package/CanonicalizeTimeZoneName.d.ts.map +1 -0
  9. package/CanonicalizeTimeZoneName.js +21 -0
  10. package/CoerceOptionsToObject.d.ts +7 -0
  11. package/CoerceOptionsToObject.d.ts.map +1 -0
  12. package/CoerceOptionsToObject.js +16 -0
  13. package/DefaultNumberOption.d.ts +9 -0
  14. package/DefaultNumberOption.d.ts.map +1 -0
  15. package/DefaultNumberOption.js +14 -0
  16. package/GetNumberOption.d.ts +10 -0
  17. package/GetNumberOption.d.ts.map +1 -0
  18. package/GetNumberOption.js +18 -0
  19. package/GetOption.d.ts +10 -0
  20. package/GetOption.d.ts.map +1 -0
  21. package/GetOption.js +35 -0
  22. package/GetOptionsObject.d.ts +7 -0
  23. package/GetOptionsObject.d.ts.map +1 -0
  24. package/GetOptionsObject.js +18 -0
  25. package/IsSanctionedSimpleUnitIdentifier.d.ts +14 -0
  26. package/IsSanctionedSimpleUnitIdentifier.d.ts.map +1 -0
  27. package/IsSanctionedSimpleUnitIdentifier.js +68 -0
  28. package/IsValidTimeZoneName.d.ts +10 -0
  29. package/IsValidTimeZoneName.d.ts.map +1 -0
  30. package/IsValidTimeZoneName.js +23 -0
  31. package/IsWellFormedCurrencyCode.d.ts +5 -0
  32. package/IsWellFormedCurrencyCode.d.ts.map +1 -0
  33. package/IsWellFormedCurrencyCode.js +25 -0
  34. package/IsWellFormedUnitIdentifier.d.ts +6 -0
  35. package/IsWellFormedUnitIdentifier.d.ts.map +1 -0
  36. package/IsWellFormedUnitIdentifier.js +32 -0
  37. package/NumberFormat/ComputeExponent.d.ts +12 -0
  38. package/NumberFormat/ComputeExponent.d.ts.map +1 -0
  39. package/NumberFormat/ComputeExponent.js +43 -0
  40. package/NumberFormat/ComputeExponentForMagnitude.d.ts +10 -0
  41. package/NumberFormat/ComputeExponentForMagnitude.d.ts.map +1 -0
  42. package/NumberFormat/ComputeExponentForMagnitude.js +64 -0
  43. package/NumberFormat/CurrencyDigits.d.ts +7 -0
  44. package/NumberFormat/CurrencyDigits.d.ts.map +1 -0
  45. package/NumberFormat/CurrencyDigits.js +14 -0
  46. package/NumberFormat/FormatNumericToParts.d.ts +5 -0
  47. package/NumberFormat/FormatNumericToParts.d.ts.map +1 -0
  48. package/NumberFormat/FormatNumericToParts.js +18 -0
  49. package/NumberFormat/FormatNumericToString.d.ts +9 -0
  50. package/NumberFormat/FormatNumericToString.d.ts.map +1 -0
  51. package/NumberFormat/FormatNumericToString.js +45 -0
  52. package/NumberFormat/InitializeNumberFormat.d.ts +13 -0
  53. package/NumberFormat/InitializeNumberFormat.d.ts.map +1 -0
  54. package/NumberFormat/InitializeNumberFormat.js +68 -0
  55. package/NumberFormat/PartitionNumberPattern.d.ts +8 -0
  56. package/NumberFormat/PartitionNumberPattern.d.ts.map +1 -0
  57. package/NumberFormat/PartitionNumberPattern.js +80 -0
  58. package/NumberFormat/SetNumberFormatDigitOptions.d.ts +6 -0
  59. package/NumberFormat/SetNumberFormatDigitOptions.d.ts.map +1 -0
  60. package/NumberFormat/SetNumberFormatDigitOptions.js +40 -0
  61. package/NumberFormat/SetNumberFormatUnitOptions.d.ts +8 -0
  62. package/NumberFormat/SetNumberFormatUnitOptions.d.ts.map +1 -0
  63. package/NumberFormat/SetNumberFormatUnitOptions.js +43 -0
  64. package/NumberFormat/ToRawFixed.d.ts +10 -0
  65. package/NumberFormat/ToRawFixed.d.ts.map +1 -0
  66. package/NumberFormat/ToRawFixed.js +55 -0
  67. package/NumberFormat/ToRawPrecision.d.ts +3 -0
  68. package/NumberFormat/ToRawPrecision.d.ts.map +1 -0
  69. package/NumberFormat/ToRawPrecision.js +78 -0
  70. package/NumberFormat/digit-mapping.generated.d.ts +2 -0
  71. package/NumberFormat/digit-mapping.generated.d.ts.map +1 -0
  72. package/NumberFormat/digit-mapping.generated.js +4 -0
  73. package/NumberFormat/format_to_parts.d.ts +22 -0
  74. package/NumberFormat/format_to_parts.d.ts.map +1 -0
  75. package/NumberFormat/format_to_parts.js +424 -0
  76. package/PartitionPattern.d.ts +9 -0
  77. package/PartitionPattern.d.ts.map +1 -0
  78. package/PartitionPattern.js +39 -0
  79. package/SupportedLocales.d.ts +10 -0
  80. package/SupportedLocales.d.ts.map +1 -0
  81. package/SupportedLocales.js +24 -0
  82. package/data.d.ts +6 -0
  83. package/data.d.ts.map +1 -0
  84. package/data.js +17 -0
  85. package/index.d.ts +37 -0
  86. package/index.d.ts.map +1 -0
  87. package/index.js +48 -0
  88. package/lib/262.d.ts +92 -0
  89. package/lib/262.d.ts.map +1 -0
  90. package/lib/262.js +336 -0
  91. package/lib/CanonicalizeLocaleList.d.ts +6 -0
  92. package/lib/CanonicalizeLocaleList.d.ts.map +1 -0
  93. package/lib/CanonicalizeLocaleList.js +8 -0
  94. package/lib/CanonicalizeTimeZoneName.d.ts +9 -0
  95. package/lib/CanonicalizeTimeZoneName.d.ts.map +1 -0
  96. package/lib/CanonicalizeTimeZoneName.js +17 -0
  97. package/lib/CoerceOptionsToObject.d.ts +7 -0
  98. package/lib/CoerceOptionsToObject.d.ts.map +1 -0
  99. package/lib/CoerceOptionsToObject.js +12 -0
  100. package/lib/DefaultNumberOption.d.ts +9 -0
  101. package/lib/DefaultNumberOption.d.ts.map +1 -0
  102. package/lib/DefaultNumberOption.js +10 -0
  103. package/lib/GetNumberOption.d.ts +10 -0
  104. package/lib/GetNumberOption.d.ts.map +1 -0
  105. package/lib/GetNumberOption.js +14 -0
  106. package/lib/GetOption.d.ts +10 -0
  107. package/lib/GetOption.d.ts.map +1 -0
  108. package/lib/GetOption.js +31 -0
  109. package/lib/GetOptionsObject.d.ts +7 -0
  110. package/lib/GetOptionsObject.d.ts.map +1 -0
  111. package/lib/GetOptionsObject.js +14 -0
  112. package/lib/IsSanctionedSimpleUnitIdentifier.d.ts +14 -0
  113. package/lib/IsSanctionedSimpleUnitIdentifier.d.ts.map +1 -0
  114. package/lib/IsSanctionedSimpleUnitIdentifier.js +63 -0
  115. package/lib/IsValidTimeZoneName.d.ts +10 -0
  116. package/lib/IsValidTimeZoneName.d.ts.map +1 -0
  117. package/lib/IsValidTimeZoneName.js +19 -0
  118. package/lib/IsWellFormedCurrencyCode.d.ts +5 -0
  119. package/lib/IsWellFormedCurrencyCode.d.ts.map +1 -0
  120. package/lib/IsWellFormedCurrencyCode.js +21 -0
  121. package/lib/IsWellFormedUnitIdentifier.d.ts +6 -0
  122. package/lib/IsWellFormedUnitIdentifier.d.ts.map +1 -0
  123. package/lib/IsWellFormedUnitIdentifier.js +28 -0
  124. package/lib/NumberFormat/ComputeExponent.d.ts +12 -0
  125. package/lib/NumberFormat/ComputeExponent.d.ts.map +1 -0
  126. package/lib/NumberFormat/ComputeExponent.js +39 -0
  127. package/lib/NumberFormat/ComputeExponentForMagnitude.d.ts +10 -0
  128. package/lib/NumberFormat/ComputeExponentForMagnitude.d.ts.map +1 -0
  129. package/lib/NumberFormat/ComputeExponentForMagnitude.js +60 -0
  130. package/lib/NumberFormat/CurrencyDigits.d.ts +7 -0
  131. package/lib/NumberFormat/CurrencyDigits.d.ts.map +1 -0
  132. package/lib/NumberFormat/CurrencyDigits.js +10 -0
  133. package/lib/NumberFormat/FormatNumericToParts.d.ts +5 -0
  134. package/lib/NumberFormat/FormatNumericToParts.d.ts.map +1 -0
  135. package/lib/NumberFormat/FormatNumericToParts.js +14 -0
  136. package/lib/NumberFormat/FormatNumericToString.d.ts +9 -0
  137. package/lib/NumberFormat/FormatNumericToString.d.ts.map +1 -0
  138. package/lib/NumberFormat/FormatNumericToString.js +41 -0
  139. package/lib/NumberFormat/InitializeNumberFormat.d.ts +13 -0
  140. package/lib/NumberFormat/InitializeNumberFormat.d.ts.map +1 -0
  141. package/lib/NumberFormat/InitializeNumberFormat.js +64 -0
  142. package/lib/NumberFormat/PartitionNumberPattern.d.ts +8 -0
  143. package/lib/NumberFormat/PartitionNumberPattern.d.ts.map +1 -0
  144. package/lib/NumberFormat/PartitionNumberPattern.js +75 -0
  145. package/lib/NumberFormat/SetNumberFormatDigitOptions.d.ts +6 -0
  146. package/lib/NumberFormat/SetNumberFormatDigitOptions.d.ts.map +1 -0
  147. package/lib/NumberFormat/SetNumberFormatDigitOptions.js +36 -0
  148. package/lib/NumberFormat/SetNumberFormatUnitOptions.d.ts +8 -0
  149. package/lib/NumberFormat/SetNumberFormatUnitOptions.d.ts.map +1 -0
  150. package/lib/NumberFormat/SetNumberFormatUnitOptions.js +39 -0
  151. package/lib/NumberFormat/ToRawFixed.d.ts +10 -0
  152. package/lib/NumberFormat/ToRawFixed.d.ts.map +1 -0
  153. package/lib/NumberFormat/ToRawFixed.js +51 -0
  154. package/lib/NumberFormat/ToRawPrecision.d.ts +3 -0
  155. package/lib/NumberFormat/ToRawPrecision.d.ts.map +1 -0
  156. package/lib/NumberFormat/ToRawPrecision.js +74 -0
  157. package/lib/NumberFormat/digit-mapping.generated.d.ts +2 -0
  158. package/lib/NumberFormat/digit-mapping.generated.d.ts.map +1 -0
  159. package/lib/NumberFormat/digit-mapping.generated.js +1 -0
  160. package/lib/NumberFormat/format_to_parts.d.ts +22 -0
  161. package/lib/NumberFormat/format_to_parts.d.ts.map +1 -0
  162. package/lib/NumberFormat/format_to_parts.js +421 -0
  163. package/lib/PartitionPattern.d.ts +9 -0
  164. package/lib/PartitionPattern.d.ts.map +1 -0
  165. package/lib/PartitionPattern.js +35 -0
  166. package/lib/SupportedLocales.d.ts +10 -0
  167. package/lib/SupportedLocales.d.ts.map +1 -0
  168. package/lib/SupportedLocales.js +20 -0
  169. package/lib/data.d.ts +6 -0
  170. package/lib/data.d.ts.map +1 -0
  171. package/lib/data.js +13 -0
  172. package/lib/index.d.ts +37 -0
  173. package/lib/index.d.ts.map +1 -0
  174. package/lib/index.js +34 -0
  175. package/lib/regex.generated.d.ts +2 -0
  176. package/lib/regex.generated.d.ts.map +1 -0
  177. package/lib/regex.generated.js +2 -0
  178. package/lib/types/core.d.ts +11 -0
  179. package/lib/types/core.d.ts.map +1 -0
  180. package/lib/types/core.js +1 -0
  181. package/lib/types/date-time.d.ts +135 -0
  182. package/lib/types/date-time.d.ts.map +1 -0
  183. package/lib/types/date-time.js +6 -0
  184. package/lib/types/displaynames.d.ts +47 -0
  185. package/lib/types/displaynames.d.ts.map +1 -0
  186. package/lib/types/displaynames.js +1 -0
  187. package/lib/types/list.d.ts +19 -0
  188. package/lib/types/list.d.ts.map +1 -0
  189. package/lib/types/list.js +1 -0
  190. package/lib/types/number.d.ts +147 -0
  191. package/lib/types/number.d.ts.map +1 -0
  192. package/lib/types/number.js +1 -0
  193. package/lib/types/plural-rules.d.ts +17 -0
  194. package/lib/types/plural-rules.d.ts.map +1 -0
  195. package/lib/types/plural-rules.js +1 -0
  196. package/lib/types/relative-time.d.ts +41 -0
  197. package/lib/types/relative-time.d.ts.map +1 -0
  198. package/lib/types/relative-time.js +1 -0
  199. package/lib/utils.d.ts +24 -0
  200. package/lib/utils.d.ts.map +1 -0
  201. package/lib/utils.js +78 -0
  202. package/package.json +2 -2
  203. package/regex.generated.d.ts +2 -0
  204. package/regex.generated.d.ts.map +1 -0
  205. package/regex.generated.js +5 -0
  206. package/types/core.d.ts +11 -0
  207. package/types/core.d.ts.map +1 -0
  208. package/types/core.js +2 -0
  209. package/types/date-time.d.ts +135 -0
  210. package/types/date-time.d.ts.map +1 -0
  211. package/types/date-time.js +9 -0
  212. package/types/displaynames.d.ts +47 -0
  213. package/types/displaynames.d.ts.map +1 -0
  214. package/types/displaynames.js +2 -0
  215. package/types/list.d.ts +19 -0
  216. package/types/list.d.ts.map +1 -0
  217. package/types/list.js +2 -0
  218. package/types/number.d.ts +147 -0
  219. package/types/number.d.ts.map +1 -0
  220. package/types/number.js +2 -0
  221. package/types/plural-rules.d.ts +17 -0
  222. package/types/plural-rules.d.ts.map +1 -0
  223. package/types/plural-rules.js +2 -0
  224. package/types/relative-time.d.ts +41 -0
  225. package/types/relative-time.d.ts.map +1 -0
  226. package/types/relative-time.js +2 -0
  227. package/utils.d.ts +24 -0
  228. package/utils.d.ts.map +1 -0
  229. package/utils.js +90 -0
  230. package/262.ts +0 -372
  231. package/BUILD +0 -97
  232. package/CHANGELOG.md +0 -709
  233. package/CanonicalizeLocaleList.ts +0 -8
  234. package/CanonicalizeTimeZoneName.ts +0 -29
  235. package/CoerceOptionsToObject.ts +0 -13
  236. package/DefaultNumberOption.ts +0 -28
  237. package/GetNumberOption.ts +0 -29
  238. package/GetOption.ts +0 -38
  239. package/GetOptionsObject.ts +0 -14
  240. package/IsSanctionedSimpleUnitIdentifier.ts +0 -66
  241. package/IsValidTimeZoneName.ts +0 -27
  242. package/IsWellFormedCurrencyCode.ts +0 -23
  243. package/IsWellFormedUnitIdentifier.ts +0 -32
  244. package/NumberFormat/ComputeExponent.ts +0 -49
  245. package/NumberFormat/ComputeExponentForMagnitude.ts +0 -71
  246. package/NumberFormat/CurrencyDigits.ts +0 -13
  247. package/NumberFormat/FormatNumericToParts.ts +0 -22
  248. package/NumberFormat/FormatNumericToString.ts +0 -71
  249. package/NumberFormat/InitializeNumberFormat.ts +0 -147
  250. package/NumberFormat/PartitionNumberPattern.ts +0 -86
  251. package/NumberFormat/SetNumberFormatDigitOptions.ts +0 -45
  252. package/NumberFormat/SetNumberFormatUnitOptions.ts +0 -77
  253. package/NumberFormat/ToRawFixed.ts +0 -56
  254. package/NumberFormat/ToRawPrecision.ts +0 -86
  255. package/NumberFormat/digit-mapping.generated.ts +0 -1
  256. package/NumberFormat/format_to_parts.ts +0 -571
  257. package/PartitionPattern.ts +0 -38
  258. package/SupportedLocales.ts +0 -31
  259. package/data.ts +0 -9
  260. package/index.ts +0 -45
  261. package/regex.generated.ts +0 -2
  262. package/scripts/digit-mapping.ts +0 -109
  263. package/scripts/regex-gen.ts +0 -19
  264. package/tests/PartitionPattern.test.ts +0 -38
  265. package/tests/ToRawFixed.test.tsx +0 -41
  266. package/tests/ToRawPrecision.test.tsx +0 -65
  267. package/tsconfig.json +0 -5
  268. package/types/core.ts +0 -11
  269. package/types/date-time.ts +0 -199
  270. package/types/displaynames.ts +0 -48
  271. package/types/list.ts +0 -22
  272. package/types/number.ts +0 -240
  273. package/types/plural-rules.ts +0 -18
  274. package/types/relative-time.ts +0 -74
  275. package/utils.ts +0 -128
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetOptionsObject = void 0;
4
+ /**
5
+ * https://tc39.es/ecma402/#sec-getoptionsobject
6
+ * @param options
7
+ * @returns
8
+ */
9
+ function GetOptionsObject(options) {
10
+ if (typeof options === 'undefined') {
11
+ return Object.create(null);
12
+ }
13
+ if (typeof options === 'object') {
14
+ return options;
15
+ }
16
+ throw new TypeError('Options must be an object');
17
+ }
18
+ exports.GetOptionsObject = GetOptionsObject;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * https://tc39.es/ecma402/#table-sanctioned-simple-unit-identifiers
3
+ */
4
+ export declare const SANCTIONED_UNITS: string[];
5
+ export declare function removeUnitNamespace(unit: string): string;
6
+ /**
7
+ * https://tc39.es/ecma402/#table-sanctioned-simple-unit-identifiers
8
+ */
9
+ export declare const SIMPLE_UNITS: string[];
10
+ /**
11
+ * https://tc39.es/ecma402/#sec-issanctionedsimpleunitidentifier
12
+ */
13
+ export declare function IsSanctionedSimpleUnitIdentifier(unitIdentifier: string): boolean;
14
+ //# sourceMappingURL=IsSanctionedSimpleUnitIdentifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IsSanctionedSimpleUnitIdentifier.d.ts","sourceRoot":"","sources":["IsSanctionedSimpleUnitIdentifier.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,gBAAgB,UA4C5B,CAAA;AAID,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,UAE/C;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,UAA4C,CAAA;AAErE;;GAEG;AACH,wBAAgB,gCAAgC,CAAC,cAAc,EAAE,MAAM,WAEtE"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IsSanctionedSimpleUnitIdentifier = exports.SIMPLE_UNITS = exports.removeUnitNamespace = exports.SANCTIONED_UNITS = void 0;
4
+ /**
5
+ * https://tc39.es/ecma402/#table-sanctioned-simple-unit-identifiers
6
+ */
7
+ exports.SANCTIONED_UNITS = [
8
+ 'angle-degree',
9
+ 'area-acre',
10
+ 'area-hectare',
11
+ 'concentr-percent',
12
+ 'digital-bit',
13
+ 'digital-byte',
14
+ 'digital-gigabit',
15
+ 'digital-gigabyte',
16
+ 'digital-kilobit',
17
+ 'digital-kilobyte',
18
+ 'digital-megabit',
19
+ 'digital-megabyte',
20
+ 'digital-petabyte',
21
+ 'digital-terabit',
22
+ 'digital-terabyte',
23
+ 'duration-day',
24
+ 'duration-hour',
25
+ 'duration-millisecond',
26
+ 'duration-minute',
27
+ 'duration-month',
28
+ 'duration-second',
29
+ 'duration-week',
30
+ 'duration-year',
31
+ 'length-centimeter',
32
+ 'length-foot',
33
+ 'length-inch',
34
+ 'length-kilometer',
35
+ 'length-meter',
36
+ 'length-mile-scandinavian',
37
+ 'length-mile',
38
+ 'length-millimeter',
39
+ 'length-yard',
40
+ 'mass-gram',
41
+ 'mass-kilogram',
42
+ 'mass-ounce',
43
+ 'mass-pound',
44
+ 'mass-stone',
45
+ 'temperature-celsius',
46
+ 'temperature-fahrenheit',
47
+ 'volume-fluid-ounce',
48
+ 'volume-gallon',
49
+ 'volume-liter',
50
+ 'volume-milliliter',
51
+ ];
52
+ // In CLDR, the unit name always follows the form `namespace-unit` pattern.
53
+ // For example: `digital-bit` instead of `bit`. This function removes the namespace prefix.
54
+ function removeUnitNamespace(unit) {
55
+ return unit.slice(unit.indexOf('-') + 1);
56
+ }
57
+ exports.removeUnitNamespace = removeUnitNamespace;
58
+ /**
59
+ * https://tc39.es/ecma402/#table-sanctioned-simple-unit-identifiers
60
+ */
61
+ exports.SIMPLE_UNITS = exports.SANCTIONED_UNITS.map(removeUnitNamespace);
62
+ /**
63
+ * https://tc39.es/ecma402/#sec-issanctionedsimpleunitidentifier
64
+ */
65
+ function IsSanctionedSimpleUnitIdentifier(unitIdentifier) {
66
+ return exports.SIMPLE_UNITS.indexOf(unitIdentifier) > -1;
67
+ }
68
+ exports.IsSanctionedSimpleUnitIdentifier = IsSanctionedSimpleUnitIdentifier;
@@ -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, string>;
9
+ }): boolean;
10
+ //# sourceMappingURL=IsValidTimeZoneName.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IsValidTimeZoneName.d.ts","sourceRoot":"","sources":["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,CAAA;IAC/B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACvC,GACA,OAAO,CAYT"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IsValidTimeZoneName = void 0;
4
+ /**
5
+ * https://tc39.es/ecma402/#sec-isvalidtimezonename
6
+ * @param tz
7
+ * @param implDetails implementation details
8
+ */
9
+ function IsValidTimeZoneName(tz, _a) {
10
+ var tzData = _a.tzData, uppercaseLinks = _a.uppercaseLinks;
11
+ var uppercasedTz = tz.toUpperCase();
12
+ var zoneNames = new Set();
13
+ var linkNames = new Set();
14
+ Object.keys(tzData)
15
+ .map(function (z) { return z.toUpperCase(); })
16
+ .forEach(function (z) { return zoneNames.add(z); });
17
+ Object.keys(uppercaseLinks).forEach(function (linkName) {
18
+ linkNames.add(linkName.toUpperCase());
19
+ zoneNames.add(uppercaseLinks[linkName].toUpperCase());
20
+ });
21
+ return zoneNames.has(uppercasedTz) || linkNames.has(uppercasedTz);
22
+ }
23
+ exports.IsValidTimeZoneName = IsValidTimeZoneName;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * https://tc39.es/ecma402/#sec-iswellformedcurrencycode
3
+ */
4
+ export declare function IsWellFormedCurrencyCode(currency: string): boolean;
5
+ //# sourceMappingURL=IsWellFormedCurrencyCode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IsWellFormedCurrencyCode.d.ts","sourceRoot":"","sources":["IsWellFormedCurrencyCode.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CASlE"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IsWellFormedCurrencyCode = void 0;
4
+ /**
5
+ * This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping
6
+ * @param str string to convert
7
+ */
8
+ function toUpperCase(str) {
9
+ return str.replace(/([a-z])/g, function (_, c) { return c.toUpperCase(); });
10
+ }
11
+ var NOT_A_Z_REGEX = /[^A-Z]/;
12
+ /**
13
+ * https://tc39.es/ecma402/#sec-iswellformedcurrencycode
14
+ */
15
+ function IsWellFormedCurrencyCode(currency) {
16
+ currency = toUpperCase(currency);
17
+ if (currency.length !== 3) {
18
+ return false;
19
+ }
20
+ if (NOT_A_Z_REGEX.test(currency)) {
21
+ return false;
22
+ }
23
+ return true;
24
+ }
25
+ exports.IsWellFormedCurrencyCode = IsWellFormedCurrencyCode;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * https://tc39.es/ecma402/#sec-iswellformedunitidentifier
3
+ * @param unit
4
+ */
5
+ export declare function IsWellFormedUnitIdentifier(unit: string): boolean;
6
+ //# sourceMappingURL=IsWellFormedUnitIdentifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IsWellFormedUnitIdentifier.d.ts","sourceRoot":"","sources":["IsWellFormedUnitIdentifier.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,WAiBtD"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IsWellFormedUnitIdentifier = void 0;
4
+ var IsSanctionedSimpleUnitIdentifier_1 = require("./IsSanctionedSimpleUnitIdentifier");
5
+ /**
6
+ * This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping
7
+ * @param str string to convert
8
+ */
9
+ function toLowerCase(str) {
10
+ return str.replace(/([A-Z])/g, function (_, c) { return c.toLowerCase(); });
11
+ }
12
+ /**
13
+ * https://tc39.es/ecma402/#sec-iswellformedunitidentifier
14
+ * @param unit
15
+ */
16
+ function IsWellFormedUnitIdentifier(unit) {
17
+ unit = toLowerCase(unit);
18
+ if ((0, IsSanctionedSimpleUnitIdentifier_1.IsSanctionedSimpleUnitIdentifier)(unit)) {
19
+ return true;
20
+ }
21
+ var units = unit.split('-per-');
22
+ if (units.length !== 2) {
23
+ return false;
24
+ }
25
+ var numerator = units[0], denominator = units[1];
26
+ if (!(0, IsSanctionedSimpleUnitIdentifier_1.IsSanctionedSimpleUnitIdentifier)(numerator) ||
27
+ !(0, IsSanctionedSimpleUnitIdentifier_1.IsSanctionedSimpleUnitIdentifier)(denominator)) {
28
+ return false;
29
+ }
30
+ return true;
31
+ }
32
+ exports.IsWellFormedUnitIdentifier = IsWellFormedUnitIdentifier;
@@ -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":["ComputeExponent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,oBAAoB,EAAC,MAAM,iBAAiB,CAAA;AAEpD;;;;;;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,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ComputeExponent = void 0;
4
+ var utils_1 = require("../utils");
5
+ var ComputeExponentForMagnitude_1 = require("./ComputeExponentForMagnitude");
6
+ var FormatNumericToString_1 = require("./FormatNumericToString");
7
+ /**
8
+ * The abstract operation ComputeExponent computes an exponent (power of ten) by which to scale x
9
+ * according to the number formatting settings. It handles cases such as 999 rounding up to 1000,
10
+ * requiring a different exponent.
11
+ *
12
+ * NOT IN SPEC: it returns [exponent, magnitude].
13
+ */
14
+ function ComputeExponent(numberFormat, x, _a) {
15
+ var getInternalSlots = _a.getInternalSlots;
16
+ if (x === 0) {
17
+ return [0, 0];
18
+ }
19
+ if (x < 0) {
20
+ x = -x;
21
+ }
22
+ var magnitude = (0, utils_1.getMagnitude)(x);
23
+ var exponent = (0, ComputeExponentForMagnitude_1.ComputeExponentForMagnitude)(numberFormat, magnitude, {
24
+ getInternalSlots: getInternalSlots,
25
+ });
26
+ // Preserve more precision by doing multiplication when exponent is negative.
27
+ x = exponent < 0 ? x * Math.pow(10, -exponent) : x / Math.pow(10, exponent);
28
+ var formatNumberResult = (0, FormatNumericToString_1.FormatNumericToString)(getInternalSlots(numberFormat), x);
29
+ if (formatNumberResult.roundedNumber === 0) {
30
+ return [exponent, magnitude];
31
+ }
32
+ var newMagnitude = (0, utils_1.getMagnitude)(formatNumberResult.roundedNumber);
33
+ if (newMagnitude === magnitude - exponent) {
34
+ return [exponent, magnitude];
35
+ }
36
+ return [
37
+ (0, ComputeExponentForMagnitude_1.ComputeExponentForMagnitude)(numberFormat, magnitude + 1, {
38
+ getInternalSlots: getInternalSlots,
39
+ }),
40
+ magnitude + 1,
41
+ ];
42
+ }
43
+ exports.ComputeExponent = ComputeExponent;
@@ -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":["ComputeExponentForMagnitude.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAmB,MAAM,iBAAiB,CAAA;AAEtE;;;;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,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ComputeExponentForMagnitude = void 0;
4
+ /**
5
+ * The abstract operation ComputeExponentForMagnitude computes an exponent by which to scale a
6
+ * number of the given magnitude (power of ten of the most significant digit) according to the
7
+ * locale and the desired notation (scientific, engineering, or compact).
8
+ */
9
+ function ComputeExponentForMagnitude(numberFormat, magnitude, _a) {
10
+ var getInternalSlots = _a.getInternalSlots;
11
+ var internalSlots = getInternalSlots(numberFormat);
12
+ var notation = internalSlots.notation, dataLocaleData = internalSlots.dataLocaleData, numberingSystem = internalSlots.numberingSystem;
13
+ switch (notation) {
14
+ case 'standard':
15
+ return 0;
16
+ case 'scientific':
17
+ return magnitude;
18
+ case 'engineering':
19
+ return Math.floor(magnitude / 3) * 3;
20
+ default: {
21
+ // Let exponent be an implementation- and locale-dependent (ILD) integer by which to scale a
22
+ // number of the given magnitude in compact notation for the current locale.
23
+ var compactDisplay = internalSlots.compactDisplay, style = internalSlots.style, currencyDisplay = internalSlots.currencyDisplay;
24
+ var thresholdMap = void 0;
25
+ if (style === 'currency' && currencyDisplay !== 'name') {
26
+ var currency = dataLocaleData.numbers.currency[numberingSystem] ||
27
+ dataLocaleData.numbers.currency[dataLocaleData.numbers.nu[0]];
28
+ thresholdMap = currency.short;
29
+ }
30
+ else {
31
+ var decimal = dataLocaleData.numbers.decimal[numberingSystem] ||
32
+ dataLocaleData.numbers.decimal[dataLocaleData.numbers.nu[0]];
33
+ thresholdMap = compactDisplay === 'long' ? decimal.long : decimal.short;
34
+ }
35
+ if (!thresholdMap) {
36
+ return 0;
37
+ }
38
+ var num = String(Math.pow(10, magnitude));
39
+ var thresholds = Object.keys(thresholdMap); // TODO: this can be pre-processed
40
+ if (num < thresholds[0]) {
41
+ return 0;
42
+ }
43
+ if (num > thresholds[thresholds.length - 1]) {
44
+ return thresholds[thresholds.length - 1].length - 1;
45
+ }
46
+ var i = thresholds.indexOf(num);
47
+ if (i === -1) {
48
+ return 0;
49
+ }
50
+ // See https://unicode.org/reports/tr35/tr35-numbers.html#Compact_Number_Formats
51
+ // Special handling if the pattern is precisely `0`.
52
+ var magnitudeKey = thresholds[i];
53
+ // TODO: do we need to handle plural here?
54
+ var compactPattern = thresholdMap[magnitudeKey].other;
55
+ if (compactPattern === '0') {
56
+ return 0;
57
+ }
58
+ // Example: in zh-TW, `10000000` maps to `0000萬`. So we need to return 8 - 4 = 4 here.
59
+ return (magnitudeKey.length -
60
+ thresholdMap[magnitudeKey].other.match(/0+/)[0].length);
61
+ }
62
+ }
63
+ }
64
+ exports.ComputeExponentForMagnitude = ComputeExponentForMagnitude;
@@ -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":["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,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CurrencyDigits = void 0;
4
+ var _262_1 = require("../262");
5
+ /**
6
+ * https://tc39.es/ecma402/#sec-currencydigits
7
+ */
8
+ function CurrencyDigits(c, _a) {
9
+ var currencyDigitsData = _a.currencyDigitsData;
10
+ return (0, _262_1.HasOwnProperty)(currencyDigitsData, c)
11
+ ? currencyDigitsData[c]
12
+ : 2;
13
+ }
14
+ exports.CurrencyDigits = CurrencyDigits;
@@ -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":["FormatNumericToParts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,oBAAoB,EAAE,gBAAgB,EAAC,MAAM,iBAAiB,CAAA;AAEtE,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,CAAA;CAC9D,GACA,gBAAgB,EAAE,CAWpB"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FormatNumericToParts = void 0;
4
+ var PartitionNumberPattern_1 = require("./PartitionNumberPattern");
5
+ var _262_1 = require("../262");
6
+ function FormatNumericToParts(nf, x, implDetails) {
7
+ var parts = (0, PartitionNumberPattern_1.PartitionNumberPattern)(nf, x, implDetails);
8
+ var result = (0, _262_1.ArrayCreate)(0);
9
+ for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
10
+ var part = parts_1[_i];
11
+ result.push({
12
+ type: part.type,
13
+ value: part.value,
14
+ });
15
+ }
16
+ return result;
17
+ }
18
+ exports.FormatNumericToParts = FormatNumericToParts;
@@ -0,0 +1,9 @@
1
+ import { NumberFormatDigitInternalSlots } from '../types/number';
2
+ /**
3
+ * https://tc39.es/ecma402/#sec-formatnumberstring
4
+ */
5
+ export declare function FormatNumericToString(intlObject: Pick<NumberFormatDigitInternalSlots, 'roundingType' | 'minimumSignificantDigits' | 'maximumSignificantDigits' | 'minimumIntegerDigits' | 'minimumFractionDigits' | 'maximumFractionDigits'>, x: number): {
6
+ roundedNumber: number;
7
+ formattedString: string;
8
+ };
9
+ //# sourceMappingURL=FormatNumericToString.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormatNumericToString.d.ts","sourceRoot":"","sources":["FormatNumericToString.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,8BAA8B,EAE/B,MAAM,iBAAiB,CAAA;AAGxB;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,IAAI,CACd,8BAA8B,EAC5B,cAAc,GACd,0BAA0B,GAC1B,0BAA0B,GAC1B,sBAAsB,GACtB,uBAAuB,GACvB,uBAAuB,CAC1B,EACD,CAAC,EAAE,MAAM;;;EAgDV"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FormatNumericToString = void 0;
4
+ var _262_1 = require("../262");
5
+ var ToRawPrecision_1 = require("./ToRawPrecision");
6
+ var utils_1 = require("../utils");
7
+ var ToRawFixed_1 = require("./ToRawFixed");
8
+ /**
9
+ * https://tc39.es/ecma402/#sec-formatnumberstring
10
+ */
11
+ function FormatNumericToString(intlObject, x) {
12
+ var isNegative = x < 0 || (0, _262_1.SameValue)(x, -0);
13
+ if (isNegative) {
14
+ x = -x;
15
+ }
16
+ var result;
17
+ var rourndingType = intlObject.roundingType;
18
+ switch (rourndingType) {
19
+ case 'significantDigits':
20
+ result = (0, ToRawPrecision_1.ToRawPrecision)(x, intlObject.minimumSignificantDigits, intlObject.maximumSignificantDigits);
21
+ break;
22
+ case 'fractionDigits':
23
+ result = (0, ToRawFixed_1.ToRawFixed)(x, intlObject.minimumFractionDigits, intlObject.maximumFractionDigits);
24
+ break;
25
+ default:
26
+ result = (0, ToRawPrecision_1.ToRawPrecision)(x, 1, 2);
27
+ if (result.integerDigitsCount > 1) {
28
+ result = (0, ToRawFixed_1.ToRawFixed)(x, 0, 0);
29
+ }
30
+ break;
31
+ }
32
+ x = result.roundedNumber;
33
+ var string = result.formattedString;
34
+ var int = result.integerDigitsCount;
35
+ var minInteger = intlObject.minimumIntegerDigits;
36
+ if (int < minInteger) {
37
+ var forwardZeros = (0, utils_1.repeat)('0', minInteger - int);
38
+ string = forwardZeros + string;
39
+ }
40
+ if (isNegative) {
41
+ x = -x;
42
+ }
43
+ return { roundedNumber: x, formattedString: string };
44
+ }
45
+ exports.FormatNumericToString = FormatNumericToString;
@@ -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 | ReadonlyArray<string> | undefined, opts: NumberFormatOptions | undefined, { getInternalSlots, localeData, availableLocales, numberingSystemNames, getDefaultLocale, currencyDigitsData, }: {
6
+ getInternalSlots(nf: Intl.NumberFormat): NumberFormatInternal;
7
+ localeData: Record<string, NumberFormatLocaleInternalData | undefined>;
8
+ availableLocales: Set<string>;
9
+ numberingSystemNames: ReadonlyArray<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":["InitializeNumberFormat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,8BAA8B,EAC/B,MAAM,iBAAiB,CAAA;AAUxB;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,IAAI,CAAC,YAAY,EACrB,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,EACnD,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,CAAA;IAC7D,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,8BAA8B,GAAG,SAAS,CAAC,CAAA;IACtE,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC7B,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC3C,gBAAgB,IAAI,MAAM,CAAA;IAC1B,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC3C,qBA+GF"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InitializeNumberFormat = void 0;
4
+ var CanonicalizeLocaleList_1 = require("../CanonicalizeLocaleList");
5
+ var GetOption_1 = require("../GetOption");
6
+ var intl_localematcher_1 = require("@formatjs/intl-localematcher");
7
+ var SetNumberFormatUnitOptions_1 = require("./SetNumberFormatUnitOptions");
8
+ var CurrencyDigits_1 = require("./CurrencyDigits");
9
+ var SetNumberFormatDigitOptions_1 = require("./SetNumberFormatDigitOptions");
10
+ var utils_1 = require("../utils");
11
+ var CoerceOptionsToObject_1 = require("../CoerceOptionsToObject");
12
+ /**
13
+ * https://tc39.es/ecma402/#sec-initializenumberformat
14
+ */
15
+ function InitializeNumberFormat(nf, locales, opts, _a) {
16
+ var getInternalSlots = _a.getInternalSlots, localeData = _a.localeData, availableLocales = _a.availableLocales, numberingSystemNames = _a.numberingSystemNames, getDefaultLocale = _a.getDefaultLocale, currencyDigitsData = _a.currencyDigitsData;
17
+ // @ts-ignore
18
+ var requestedLocales = (0, CanonicalizeLocaleList_1.CanonicalizeLocaleList)(locales);
19
+ var options = (0, CoerceOptionsToObject_1.CoerceOptionsToObject)(opts);
20
+ var opt = Object.create(null);
21
+ var matcher = (0, GetOption_1.GetOption)(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
22
+ opt.localeMatcher = matcher;
23
+ var numberingSystem = (0, GetOption_1.GetOption)(options, 'numberingSystem', 'string', undefined, undefined);
24
+ if (numberingSystem !== undefined &&
25
+ numberingSystemNames.indexOf(numberingSystem) < 0) {
26
+ // 8.a. If numberingSystem does not match the Unicode Locale Identifier type nonterminal,
27
+ // throw a RangeError exception.
28
+ throw RangeError("Invalid numberingSystems: ".concat(numberingSystem));
29
+ }
30
+ opt.nu = numberingSystem;
31
+ var r = (0, intl_localematcher_1.ResolveLocale)(availableLocales, requestedLocales, opt,
32
+ // [[RelevantExtensionKeys]] slot, which is a constant
33
+ ['nu'], localeData, getDefaultLocale);
34
+ var dataLocaleData = localeData[r.dataLocale];
35
+ (0, utils_1.invariant)(!!dataLocaleData, "Missing locale data for ".concat(r.dataLocale));
36
+ var internalSlots = getInternalSlots(nf);
37
+ internalSlots.locale = r.locale;
38
+ internalSlots.dataLocale = r.dataLocale;
39
+ internalSlots.numberingSystem = r.nu;
40
+ internalSlots.dataLocaleData = dataLocaleData;
41
+ (0, SetNumberFormatUnitOptions_1.SetNumberFormatUnitOptions)(nf, options, { getInternalSlots: getInternalSlots });
42
+ var style = internalSlots.style;
43
+ var mnfdDefault;
44
+ var mxfdDefault;
45
+ if (style === 'currency') {
46
+ var currency = internalSlots.currency;
47
+ var cDigits = (0, CurrencyDigits_1.CurrencyDigits)(currency, { currencyDigitsData: currencyDigitsData });
48
+ mnfdDefault = cDigits;
49
+ mxfdDefault = cDigits;
50
+ }
51
+ else {
52
+ mnfdDefault = 0;
53
+ mxfdDefault = style === 'percent' ? 0 : 3;
54
+ }
55
+ var notation = (0, GetOption_1.GetOption)(options, 'notation', 'string', ['standard', 'scientific', 'engineering', 'compact'], 'standard');
56
+ internalSlots.notation = notation;
57
+ (0, SetNumberFormatDigitOptions_1.SetNumberFormatDigitOptions)(internalSlots, options, mnfdDefault, mxfdDefault, notation);
58
+ var compactDisplay = (0, GetOption_1.GetOption)(options, 'compactDisplay', 'string', ['short', 'long'], 'short');
59
+ if (notation === 'compact') {
60
+ internalSlots.compactDisplay = compactDisplay;
61
+ }
62
+ var useGrouping = (0, GetOption_1.GetOption)(options, 'useGrouping', 'boolean', undefined, true);
63
+ internalSlots.useGrouping = useGrouping;
64
+ var signDisplay = (0, GetOption_1.GetOption)(options, 'signDisplay', 'string', ['auto', 'never', 'always', 'exceptZero'], 'auto');
65
+ internalSlots.signDisplay = signDisplay;
66
+ return nf;
67
+ }
68
+ exports.InitializeNumberFormat = InitializeNumberFormat;
@@ -0,0 +1,8 @@
1
+ import { NumberFormatInternal } from '../types/number';
2
+ /**
3
+ * https://tc39.es/ecma402/#sec-formatnumberstring
4
+ */
5
+ export declare function PartitionNumberPattern(numberFormat: Intl.NumberFormat, x: number, { getInternalSlots, }: {
6
+ getInternalSlots(nf: Intl.NumberFormat): NumberFormatInternal;
7
+ }): import("../types/number").NumberFormatPart[];
8
+ //# sourceMappingURL=PartitionNumberPattern.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PartitionNumberPattern.d.ts","sourceRoot":"","sources":["PartitionNumberPattern.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,iBAAiB,CAAA;AAMpD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,CAAC,EAAE,MAAM,EACT,EACE,gBAAgB,GACjB,EAAE;IACD,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAA;CAC9D,gDAqEF"}