@formatjs/ecma402-abstract 1.11.8 → 1.11.9

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 (277) hide show
  1. package/262.ts +372 -0
  2. package/BUILD +97 -0
  3. package/CHANGELOG.md +709 -0
  4. package/CanonicalizeLocaleList.ts +8 -0
  5. package/CanonicalizeTimeZoneName.ts +29 -0
  6. package/CoerceOptionsToObject.ts +13 -0
  7. package/DefaultNumberOption.ts +28 -0
  8. package/GetNumberOption.ts +29 -0
  9. package/GetOption.ts +38 -0
  10. package/GetOptionsObject.ts +14 -0
  11. package/IsSanctionedSimpleUnitIdentifier.ts +66 -0
  12. package/IsValidTimeZoneName.ts +27 -0
  13. package/IsWellFormedCurrencyCode.ts +23 -0
  14. package/IsWellFormedUnitIdentifier.ts +32 -0
  15. package/LICENSE.md +0 -0
  16. package/NumberFormat/ComputeExponent.ts +49 -0
  17. package/NumberFormat/ComputeExponentForMagnitude.ts +71 -0
  18. package/NumberFormat/CurrencyDigits.ts +13 -0
  19. package/NumberFormat/FormatNumericToParts.ts +22 -0
  20. package/NumberFormat/FormatNumericToString.ts +71 -0
  21. package/NumberFormat/InitializeNumberFormat.ts +147 -0
  22. package/NumberFormat/PartitionNumberPattern.ts +86 -0
  23. package/NumberFormat/SetNumberFormatDigitOptions.ts +45 -0
  24. package/NumberFormat/SetNumberFormatUnitOptions.ts +77 -0
  25. package/NumberFormat/ToRawFixed.ts +56 -0
  26. package/NumberFormat/ToRawPrecision.ts +86 -0
  27. package/NumberFormat/digit-mapping.generated.ts +1 -0
  28. package/NumberFormat/format_to_parts.ts +571 -0
  29. package/PartitionPattern.ts +38 -0
  30. package/README.md +0 -0
  31. package/SupportedLocales.ts +31 -0
  32. package/data.ts +9 -0
  33. package/index.ts +45 -0
  34. package/package.json +3 -3
  35. package/regex.generated.ts +2 -0
  36. package/scripts/digit-mapping.ts +109 -0
  37. package/scripts/regex-gen.ts +19 -0
  38. package/tests/PartitionPattern.test.ts +38 -0
  39. package/tests/ToRawFixed.test.tsx +41 -0
  40. package/tests/ToRawPrecision.test.tsx +65 -0
  41. package/tsconfig.json +5 -0
  42. package/types/core.ts +11 -0
  43. package/types/date-time.ts +199 -0
  44. package/types/displaynames.ts +48 -0
  45. package/types/list.ts +22 -0
  46. package/types/number.ts +240 -0
  47. package/types/plural-rules.ts +18 -0
  48. package/types/relative-time.ts +74 -0
  49. package/utils.ts +128 -0
  50. package/262.d.ts +0 -92
  51. package/262.d.ts.map +0 -1
  52. package/262.js +0 -362
  53. package/CanonicalizeLocaleList.d.ts +0 -6
  54. package/CanonicalizeLocaleList.d.ts.map +0 -1
  55. package/CanonicalizeLocaleList.js +0 -12
  56. package/CanonicalizeTimeZoneName.d.ts +0 -9
  57. package/CanonicalizeTimeZoneName.d.ts.map +0 -1
  58. package/CanonicalizeTimeZoneName.js +0 -21
  59. package/CoerceOptionsToObject.d.ts +0 -7
  60. package/CoerceOptionsToObject.d.ts.map +0 -1
  61. package/CoerceOptionsToObject.js +0 -16
  62. package/DefaultNumberOption.d.ts +0 -9
  63. package/DefaultNumberOption.d.ts.map +0 -1
  64. package/DefaultNumberOption.js +0 -14
  65. package/GetNumberOption.d.ts +0 -10
  66. package/GetNumberOption.d.ts.map +0 -1
  67. package/GetNumberOption.js +0 -18
  68. package/GetOption.d.ts +0 -10
  69. package/GetOption.d.ts.map +0 -1
  70. package/GetOption.js +0 -35
  71. package/GetOptionsObject.d.ts +0 -7
  72. package/GetOptionsObject.d.ts.map +0 -1
  73. package/GetOptionsObject.js +0 -18
  74. package/IsSanctionedSimpleUnitIdentifier.d.ts +0 -14
  75. package/IsSanctionedSimpleUnitIdentifier.d.ts.map +0 -1
  76. package/IsSanctionedSimpleUnitIdentifier.js +0 -68
  77. package/IsValidTimeZoneName.d.ts +0 -10
  78. package/IsValidTimeZoneName.d.ts.map +0 -1
  79. package/IsValidTimeZoneName.js +0 -23
  80. package/IsWellFormedCurrencyCode.d.ts +0 -5
  81. package/IsWellFormedCurrencyCode.d.ts.map +0 -1
  82. package/IsWellFormedCurrencyCode.js +0 -25
  83. package/IsWellFormedUnitIdentifier.d.ts +0 -6
  84. package/IsWellFormedUnitIdentifier.d.ts.map +0 -1
  85. package/IsWellFormedUnitIdentifier.js +0 -32
  86. package/NumberFormat/ComputeExponent.d.ts +0 -12
  87. package/NumberFormat/ComputeExponent.d.ts.map +0 -1
  88. package/NumberFormat/ComputeExponent.js +0 -43
  89. package/NumberFormat/ComputeExponentForMagnitude.d.ts +0 -10
  90. package/NumberFormat/ComputeExponentForMagnitude.d.ts.map +0 -1
  91. package/NumberFormat/ComputeExponentForMagnitude.js +0 -64
  92. package/NumberFormat/CurrencyDigits.d.ts +0 -7
  93. package/NumberFormat/CurrencyDigits.d.ts.map +0 -1
  94. package/NumberFormat/CurrencyDigits.js +0 -14
  95. package/NumberFormat/FormatNumericToParts.d.ts +0 -5
  96. package/NumberFormat/FormatNumericToParts.d.ts.map +0 -1
  97. package/NumberFormat/FormatNumericToParts.js +0 -18
  98. package/NumberFormat/FormatNumericToString.d.ts +0 -9
  99. package/NumberFormat/FormatNumericToString.d.ts.map +0 -1
  100. package/NumberFormat/FormatNumericToString.js +0 -45
  101. package/NumberFormat/InitializeNumberFormat.d.ts +0 -13
  102. package/NumberFormat/InitializeNumberFormat.d.ts.map +0 -1
  103. package/NumberFormat/InitializeNumberFormat.js +0 -68
  104. package/NumberFormat/PartitionNumberPattern.d.ts +0 -8
  105. package/NumberFormat/PartitionNumberPattern.d.ts.map +0 -1
  106. package/NumberFormat/PartitionNumberPattern.js +0 -80
  107. package/NumberFormat/SetNumberFormatDigitOptions.d.ts +0 -6
  108. package/NumberFormat/SetNumberFormatDigitOptions.d.ts.map +0 -1
  109. package/NumberFormat/SetNumberFormatDigitOptions.js +0 -40
  110. package/NumberFormat/SetNumberFormatUnitOptions.d.ts +0 -8
  111. package/NumberFormat/SetNumberFormatUnitOptions.d.ts.map +0 -1
  112. package/NumberFormat/SetNumberFormatUnitOptions.js +0 -43
  113. package/NumberFormat/ToRawFixed.d.ts +0 -10
  114. package/NumberFormat/ToRawFixed.d.ts.map +0 -1
  115. package/NumberFormat/ToRawFixed.js +0 -55
  116. package/NumberFormat/ToRawPrecision.d.ts +0 -3
  117. package/NumberFormat/ToRawPrecision.d.ts.map +0 -1
  118. package/NumberFormat/ToRawPrecision.js +0 -78
  119. package/NumberFormat/digit-mapping.generated.d.ts +0 -2
  120. package/NumberFormat/digit-mapping.generated.d.ts.map +0 -1
  121. package/NumberFormat/digit-mapping.generated.js +0 -4
  122. package/NumberFormat/format_to_parts.d.ts +0 -22
  123. package/NumberFormat/format_to_parts.d.ts.map +0 -1
  124. package/NumberFormat/format_to_parts.js +0 -424
  125. package/PartitionPattern.d.ts +0 -9
  126. package/PartitionPattern.d.ts.map +0 -1
  127. package/PartitionPattern.js +0 -39
  128. package/SupportedLocales.d.ts +0 -10
  129. package/SupportedLocales.d.ts.map +0 -1
  130. package/SupportedLocales.js +0 -24
  131. package/data.d.ts +0 -6
  132. package/data.d.ts.map +0 -1
  133. package/data.js +0 -17
  134. package/index.d.ts +0 -37
  135. package/index.d.ts.map +0 -1
  136. package/index.js +0 -48
  137. package/lib/262.d.ts +0 -92
  138. package/lib/262.d.ts.map +0 -1
  139. package/lib/262.js +0 -336
  140. package/lib/CanonicalizeLocaleList.d.ts +0 -6
  141. package/lib/CanonicalizeLocaleList.d.ts.map +0 -1
  142. package/lib/CanonicalizeLocaleList.js +0 -8
  143. package/lib/CanonicalizeTimeZoneName.d.ts +0 -9
  144. package/lib/CanonicalizeTimeZoneName.d.ts.map +0 -1
  145. package/lib/CanonicalizeTimeZoneName.js +0 -17
  146. package/lib/CoerceOptionsToObject.d.ts +0 -7
  147. package/lib/CoerceOptionsToObject.d.ts.map +0 -1
  148. package/lib/CoerceOptionsToObject.js +0 -12
  149. package/lib/DefaultNumberOption.d.ts +0 -9
  150. package/lib/DefaultNumberOption.d.ts.map +0 -1
  151. package/lib/DefaultNumberOption.js +0 -10
  152. package/lib/GetNumberOption.d.ts +0 -10
  153. package/lib/GetNumberOption.d.ts.map +0 -1
  154. package/lib/GetNumberOption.js +0 -14
  155. package/lib/GetOption.d.ts +0 -10
  156. package/lib/GetOption.d.ts.map +0 -1
  157. package/lib/GetOption.js +0 -31
  158. package/lib/GetOptionsObject.d.ts +0 -7
  159. package/lib/GetOptionsObject.d.ts.map +0 -1
  160. package/lib/GetOptionsObject.js +0 -14
  161. package/lib/IsSanctionedSimpleUnitIdentifier.d.ts +0 -14
  162. package/lib/IsSanctionedSimpleUnitIdentifier.d.ts.map +0 -1
  163. package/lib/IsSanctionedSimpleUnitIdentifier.js +0 -63
  164. package/lib/IsValidTimeZoneName.d.ts +0 -10
  165. package/lib/IsValidTimeZoneName.d.ts.map +0 -1
  166. package/lib/IsValidTimeZoneName.js +0 -19
  167. package/lib/IsWellFormedCurrencyCode.d.ts +0 -5
  168. package/lib/IsWellFormedCurrencyCode.d.ts.map +0 -1
  169. package/lib/IsWellFormedCurrencyCode.js +0 -21
  170. package/lib/IsWellFormedUnitIdentifier.d.ts +0 -6
  171. package/lib/IsWellFormedUnitIdentifier.d.ts.map +0 -1
  172. package/lib/IsWellFormedUnitIdentifier.js +0 -28
  173. package/lib/NumberFormat/ComputeExponent.d.ts +0 -12
  174. package/lib/NumberFormat/ComputeExponent.d.ts.map +0 -1
  175. package/lib/NumberFormat/ComputeExponent.js +0 -39
  176. package/lib/NumberFormat/ComputeExponentForMagnitude.d.ts +0 -10
  177. package/lib/NumberFormat/ComputeExponentForMagnitude.d.ts.map +0 -1
  178. package/lib/NumberFormat/ComputeExponentForMagnitude.js +0 -60
  179. package/lib/NumberFormat/CurrencyDigits.d.ts +0 -7
  180. package/lib/NumberFormat/CurrencyDigits.d.ts.map +0 -1
  181. package/lib/NumberFormat/CurrencyDigits.js +0 -10
  182. package/lib/NumberFormat/FormatNumericToParts.d.ts +0 -5
  183. package/lib/NumberFormat/FormatNumericToParts.d.ts.map +0 -1
  184. package/lib/NumberFormat/FormatNumericToParts.js +0 -14
  185. package/lib/NumberFormat/FormatNumericToString.d.ts +0 -9
  186. package/lib/NumberFormat/FormatNumericToString.d.ts.map +0 -1
  187. package/lib/NumberFormat/FormatNumericToString.js +0 -41
  188. package/lib/NumberFormat/InitializeNumberFormat.d.ts +0 -13
  189. package/lib/NumberFormat/InitializeNumberFormat.d.ts.map +0 -1
  190. package/lib/NumberFormat/InitializeNumberFormat.js +0 -64
  191. package/lib/NumberFormat/PartitionNumberPattern.d.ts +0 -8
  192. package/lib/NumberFormat/PartitionNumberPattern.d.ts.map +0 -1
  193. package/lib/NumberFormat/PartitionNumberPattern.js +0 -75
  194. package/lib/NumberFormat/SetNumberFormatDigitOptions.d.ts +0 -6
  195. package/lib/NumberFormat/SetNumberFormatDigitOptions.d.ts.map +0 -1
  196. package/lib/NumberFormat/SetNumberFormatDigitOptions.js +0 -36
  197. package/lib/NumberFormat/SetNumberFormatUnitOptions.d.ts +0 -8
  198. package/lib/NumberFormat/SetNumberFormatUnitOptions.d.ts.map +0 -1
  199. package/lib/NumberFormat/SetNumberFormatUnitOptions.js +0 -39
  200. package/lib/NumberFormat/ToRawFixed.d.ts +0 -10
  201. package/lib/NumberFormat/ToRawFixed.d.ts.map +0 -1
  202. package/lib/NumberFormat/ToRawFixed.js +0 -51
  203. package/lib/NumberFormat/ToRawPrecision.d.ts +0 -3
  204. package/lib/NumberFormat/ToRawPrecision.d.ts.map +0 -1
  205. package/lib/NumberFormat/ToRawPrecision.js +0 -74
  206. package/lib/NumberFormat/digit-mapping.generated.d.ts +0 -2
  207. package/lib/NumberFormat/digit-mapping.generated.d.ts.map +0 -1
  208. package/lib/NumberFormat/digit-mapping.generated.js +0 -1
  209. package/lib/NumberFormat/format_to_parts.d.ts +0 -22
  210. package/lib/NumberFormat/format_to_parts.d.ts.map +0 -1
  211. package/lib/NumberFormat/format_to_parts.js +0 -421
  212. package/lib/PartitionPattern.d.ts +0 -9
  213. package/lib/PartitionPattern.d.ts.map +0 -1
  214. package/lib/PartitionPattern.js +0 -35
  215. package/lib/SupportedLocales.d.ts +0 -10
  216. package/lib/SupportedLocales.d.ts.map +0 -1
  217. package/lib/SupportedLocales.js +0 -20
  218. package/lib/data.d.ts +0 -6
  219. package/lib/data.d.ts.map +0 -1
  220. package/lib/data.js +0 -13
  221. package/lib/index.d.ts +0 -37
  222. package/lib/index.d.ts.map +0 -1
  223. package/lib/index.js +0 -34
  224. package/lib/regex.generated.d.ts +0 -2
  225. package/lib/regex.generated.d.ts.map +0 -1
  226. package/lib/regex.generated.js +0 -2
  227. package/lib/types/core.d.ts +0 -11
  228. package/lib/types/core.d.ts.map +0 -1
  229. package/lib/types/core.js +0 -1
  230. package/lib/types/date-time.d.ts +0 -135
  231. package/lib/types/date-time.d.ts.map +0 -1
  232. package/lib/types/date-time.js +0 -6
  233. package/lib/types/displaynames.d.ts +0 -47
  234. package/lib/types/displaynames.d.ts.map +0 -1
  235. package/lib/types/displaynames.js +0 -1
  236. package/lib/types/list.d.ts +0 -19
  237. package/lib/types/list.d.ts.map +0 -1
  238. package/lib/types/list.js +0 -1
  239. package/lib/types/number.d.ts +0 -147
  240. package/lib/types/number.d.ts.map +0 -1
  241. package/lib/types/number.js +0 -1
  242. package/lib/types/plural-rules.d.ts +0 -17
  243. package/lib/types/plural-rules.d.ts.map +0 -1
  244. package/lib/types/plural-rules.js +0 -1
  245. package/lib/types/relative-time.d.ts +0 -41
  246. package/lib/types/relative-time.d.ts.map +0 -1
  247. package/lib/types/relative-time.js +0 -1
  248. package/lib/utils.d.ts +0 -24
  249. package/lib/utils.d.ts.map +0 -1
  250. package/lib/utils.js +0 -78
  251. package/regex.generated.d.ts +0 -2
  252. package/regex.generated.d.ts.map +0 -1
  253. package/regex.generated.js +0 -5
  254. package/types/core.d.ts +0 -11
  255. package/types/core.d.ts.map +0 -1
  256. package/types/core.js +0 -2
  257. package/types/date-time.d.ts +0 -135
  258. package/types/date-time.d.ts.map +0 -1
  259. package/types/date-time.js +0 -9
  260. package/types/displaynames.d.ts +0 -47
  261. package/types/displaynames.d.ts.map +0 -1
  262. package/types/displaynames.js +0 -2
  263. package/types/list.d.ts +0 -19
  264. package/types/list.d.ts.map +0 -1
  265. package/types/list.js +0 -2
  266. package/types/number.d.ts +0 -147
  267. package/types/number.d.ts.map +0 -1
  268. package/types/number.js +0 -2
  269. package/types/plural-rules.d.ts +0 -17
  270. package/types/plural-rules.d.ts.map +0 -1
  271. package/types/plural-rules.js +0 -2
  272. package/types/relative-time.d.ts +0 -41
  273. package/types/relative-time.d.ts.map +0 -1
  274. package/types/relative-time.js +0 -2
  275. package/utils.d.ts +0 -24
  276. package/utils.d.ts.map +0 -1
  277. package/utils.js +0 -90
@@ -1,63 +0,0 @@
1
- /**
2
- * https://tc39.es/ecma402/#table-sanctioned-simple-unit-identifiers
3
- */
4
- export var SANCTIONED_UNITS = [
5
- 'angle-degree',
6
- 'area-acre',
7
- 'area-hectare',
8
- 'concentr-percent',
9
- 'digital-bit',
10
- 'digital-byte',
11
- 'digital-gigabit',
12
- 'digital-gigabyte',
13
- 'digital-kilobit',
14
- 'digital-kilobyte',
15
- 'digital-megabit',
16
- 'digital-megabyte',
17
- 'digital-petabyte',
18
- 'digital-terabit',
19
- 'digital-terabyte',
20
- 'duration-day',
21
- 'duration-hour',
22
- 'duration-millisecond',
23
- 'duration-minute',
24
- 'duration-month',
25
- 'duration-second',
26
- 'duration-week',
27
- 'duration-year',
28
- 'length-centimeter',
29
- 'length-foot',
30
- 'length-inch',
31
- 'length-kilometer',
32
- 'length-meter',
33
- 'length-mile-scandinavian',
34
- 'length-mile',
35
- 'length-millimeter',
36
- 'length-yard',
37
- 'mass-gram',
38
- 'mass-kilogram',
39
- 'mass-ounce',
40
- 'mass-pound',
41
- 'mass-stone',
42
- 'temperature-celsius',
43
- 'temperature-fahrenheit',
44
- 'volume-fluid-ounce',
45
- 'volume-gallon',
46
- 'volume-liter',
47
- 'volume-milliliter',
48
- ];
49
- // In CLDR, the unit name always follows the form `namespace-unit` pattern.
50
- // For example: `digital-bit` instead of `bit`. This function removes the namespace prefix.
51
- export function removeUnitNamespace(unit) {
52
- return unit.slice(unit.indexOf('-') + 1);
53
- }
54
- /**
55
- * https://tc39.es/ecma402/#table-sanctioned-simple-unit-identifiers
56
- */
57
- export var SIMPLE_UNITS = SANCTIONED_UNITS.map(removeUnitNamespace);
58
- /**
59
- * https://tc39.es/ecma402/#sec-issanctionedsimpleunitidentifier
60
- */
61
- export function IsSanctionedSimpleUnitIdentifier(unitIdentifier) {
62
- return SIMPLE_UNITS.indexOf(unitIdentifier) > -1;
63
- }
@@ -1,10 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"IsValidTimeZoneName.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/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"}
@@ -1,19 +0,0 @@
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();
10
- var linkNames = new Set();
11
- Object.keys(tzData)
12
- .map(function (z) { return z.toUpperCase(); })
13
- .forEach(function (z) { return zoneNames.add(z); });
14
- Object.keys(uppercaseLinks).forEach(function (linkName) {
15
- linkNames.add(linkName.toUpperCase());
16
- zoneNames.add(uppercaseLinks[linkName].toUpperCase());
17
- });
18
- return zoneNames.has(uppercasedTz) || linkNames.has(uppercasedTz);
19
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * https://tc39.es/ecma402/#sec-iswellformedcurrencycode
3
- */
4
- export declare function IsWellFormedCurrencyCode(currency: string): boolean;
5
- //# sourceMappingURL=IsWellFormedCurrencyCode.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IsWellFormedCurrencyCode.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/IsWellFormedCurrencyCode.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CASlE"}
@@ -1,21 +0,0 @@
1
- /**
2
- * This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping
3
- * @param str string to convert
4
- */
5
- function toUpperCase(str) {
6
- return str.replace(/([a-z])/g, function (_, c) { return c.toUpperCase(); });
7
- }
8
- var NOT_A_Z_REGEX = /[^A-Z]/;
9
- /**
10
- * https://tc39.es/ecma402/#sec-iswellformedcurrencycode
11
- */
12
- export function IsWellFormedCurrencyCode(currency) {
13
- currency = toUpperCase(currency);
14
- if (currency.length !== 3) {
15
- return false;
16
- }
17
- if (NOT_A_Z_REGEX.test(currency)) {
18
- return false;
19
- }
20
- return true;
21
- }
@@ -1,6 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"IsWellFormedUnitIdentifier.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/IsWellFormedUnitIdentifier.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,WAiBtD"}
@@ -1,28 +0,0 @@
1
- import { IsSanctionedSimpleUnitIdentifier } from './IsSanctionedSimpleUnitIdentifier';
2
- /**
3
- * This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping
4
- * @param str string to convert
5
- */
6
- function toLowerCase(str) {
7
- return str.replace(/([A-Z])/g, function (_, c) { return c.toLowerCase(); });
8
- }
9
- /**
10
- * https://tc39.es/ecma402/#sec-iswellformedunitidentifier
11
- * @param unit
12
- */
13
- export function IsWellFormedUnitIdentifier(unit) {
14
- unit = toLowerCase(unit);
15
- if (IsSanctionedSimpleUnitIdentifier(unit)) {
16
- return true;
17
- }
18
- var units = unit.split('-per-');
19
- if (units.length !== 2) {
20
- return false;
21
- }
22
- var numerator = units[0], denominator = units[1];
23
- if (!IsSanctionedSimpleUnitIdentifier(numerator) ||
24
- !IsSanctionedSimpleUnitIdentifier(denominator)) {
25
- return false;
26
- }
27
- return true;
28
- }
@@ -1,12 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"ComputeExponent.d.ts","sourceRoot":"","sources":["../../../../../../../packages/ecma402-abstract/NumberFormat/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"}
@@ -1,39 +0,0 @@
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
- }
@@ -1,10 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"ComputeExponentForMagnitude.d.ts","sourceRoot":"","sources":["../../../../../../../packages/ecma402-abstract/NumberFormat/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"}
@@ -1,60 +0,0 @@
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
- }
@@ -1,7 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"CurrencyDigits.d.ts","sourceRoot":"","sources":["../../../../../../../packages/ecma402-abstract/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"}
@@ -1,10 +0,0 @@
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
- }
@@ -1,5 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormatNumericToParts.d.ts","sourceRoot":"","sources":["../../../../../../../packages/ecma402-abstract/NumberFormat/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"}
@@ -1,14 +0,0 @@
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,9 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormatNumericToString.d.ts","sourceRoot":"","sources":["../../../../../../../packages/ecma402-abstract/NumberFormat/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"}
@@ -1,41 +0,0 @@
1
- import { SameValue } from '../262';
2
- import { ToRawPrecision } from './ToRawPrecision';
3
- import { repeat } from '../utils';
4
- import { ToRawFixed } from './ToRawFixed';
5
- /**
6
- * https://tc39.es/ecma402/#sec-formatnumberstring
7
- */
8
- export function FormatNumericToString(intlObject, x) {
9
- var isNegative = x < 0 || SameValue(x, -0);
10
- if (isNegative) {
11
- x = -x;
12
- }
13
- var result;
14
- var rourndingType = intlObject.roundingType;
15
- switch (rourndingType) {
16
- case 'significantDigits':
17
- result = ToRawPrecision(x, intlObject.minimumSignificantDigits, intlObject.maximumSignificantDigits);
18
- break;
19
- case 'fractionDigits':
20
- result = ToRawFixed(x, intlObject.minimumFractionDigits, intlObject.maximumFractionDigits);
21
- break;
22
- default:
23
- result = ToRawPrecision(x, 1, 2);
24
- if (result.integerDigitsCount > 1) {
25
- result = ToRawFixed(x, 0, 0);
26
- }
27
- break;
28
- }
29
- x = result.roundedNumber;
30
- var string = result.formattedString;
31
- var int = result.integerDigitsCount;
32
- var minInteger = intlObject.minimumIntegerDigits;
33
- if (int < minInteger) {
34
- var forwardZeros = repeat('0', minInteger - int);
35
- string = forwardZeros + string;
36
- }
37
- if (isNegative) {
38
- x = -x;
39
- }
40
- return { roundedNumber: x, formattedString: string };
41
- }
@@ -1,13 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"InitializeNumberFormat.d.ts","sourceRoot":"","sources":["../../../../../../../packages/ecma402-abstract/NumberFormat/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"}
@@ -1,64 +0,0 @@
1
- import { CanonicalizeLocaleList } from '../CanonicalizeLocaleList';
2
- import { GetOption } from '../GetOption';
3
- import { ResolveLocale } from '@formatjs/intl-localematcher';
4
- import { SetNumberFormatUnitOptions } from './SetNumberFormatUnitOptions';
5
- import { CurrencyDigits } from './CurrencyDigits';
6
- import { SetNumberFormatDigitOptions } from './SetNumberFormatDigitOptions';
7
- import { invariant } from '../utils';
8
- import { CoerceOptionsToObject } from '../CoerceOptionsToObject';
9
- /**
10
- * https://tc39.es/ecma402/#sec-initializenumberformat
11
- */
12
- export function InitializeNumberFormat(nf, locales, opts, _a) {
13
- var getInternalSlots = _a.getInternalSlots, localeData = _a.localeData, availableLocales = _a.availableLocales, numberingSystemNames = _a.numberingSystemNames, getDefaultLocale = _a.getDefaultLocale, currencyDigitsData = _a.currencyDigitsData;
14
- // @ts-ignore
15
- var requestedLocales = CanonicalizeLocaleList(locales);
16
- var options = CoerceOptionsToObject(opts);
17
- var opt = Object.create(null);
18
- var matcher = GetOption(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
19
- opt.localeMatcher = matcher;
20
- var numberingSystem = GetOption(options, 'numberingSystem', 'string', undefined, undefined);
21
- if (numberingSystem !== undefined &&
22
- numberingSystemNames.indexOf(numberingSystem) < 0) {
23
- // 8.a. If numberingSystem does not match the Unicode Locale Identifier type nonterminal,
24
- // throw a RangeError exception.
25
- throw RangeError("Invalid numberingSystems: ".concat(numberingSystem));
26
- }
27
- opt.nu = numberingSystem;
28
- var r = ResolveLocale(availableLocales, requestedLocales, opt,
29
- // [[RelevantExtensionKeys]] slot, which is a constant
30
- ['nu'], localeData, getDefaultLocale);
31
- var dataLocaleData = localeData[r.dataLocale];
32
- invariant(!!dataLocaleData, "Missing locale data for ".concat(r.dataLocale));
33
- var internalSlots = getInternalSlots(nf);
34
- internalSlots.locale = r.locale;
35
- internalSlots.dataLocale = r.dataLocale;
36
- internalSlots.numberingSystem = r.nu;
37
- internalSlots.dataLocaleData = dataLocaleData;
38
- SetNumberFormatUnitOptions(nf, options, { getInternalSlots: getInternalSlots });
39
- var style = internalSlots.style;
40
- var mnfdDefault;
41
- var mxfdDefault;
42
- if (style === 'currency') {
43
- var currency = internalSlots.currency;
44
- var cDigits = CurrencyDigits(currency, { currencyDigitsData: currencyDigitsData });
45
- mnfdDefault = cDigits;
46
- mxfdDefault = cDigits;
47
- }
48
- else {
49
- mnfdDefault = 0;
50
- mxfdDefault = style === 'percent' ? 0 : 3;
51
- }
52
- var notation = GetOption(options, 'notation', 'string', ['standard', 'scientific', 'engineering', 'compact'], 'standard');
53
- internalSlots.notation = notation;
54
- SetNumberFormatDigitOptions(internalSlots, options, mnfdDefault, mxfdDefault, notation);
55
- var compactDisplay = GetOption(options, 'compactDisplay', 'string', ['short', 'long'], 'short');
56
- if (notation === 'compact') {
57
- internalSlots.compactDisplay = compactDisplay;
58
- }
59
- var useGrouping = GetOption(options, 'useGrouping', 'boolean', undefined, true);
60
- internalSlots.useGrouping = useGrouping;
61
- var signDisplay = GetOption(options, 'signDisplay', 'string', ['auto', 'never', 'always', 'exceptZero'], 'auto');
62
- internalSlots.signDisplay = signDisplay;
63
- return nf;
64
- }
@@ -1,8 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"PartitionNumberPattern.d.ts","sourceRoot":"","sources":["../../../../../../../packages/ecma402-abstract/NumberFormat/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"}
@@ -1,75 +0,0 @@
1
- import { FormatNumericToString } from './FormatNumericToString';
2
- import { SameValue } from '../262';
3
- import { ComputeExponent } from './ComputeExponent';
4
- import formatToParts from './format_to_parts';
5
- /**
6
- * https://tc39.es/ecma402/#sec-formatnumberstring
7
- */
8
- export function PartitionNumberPattern(numberFormat, x, _a) {
9
- var _b;
10
- var getInternalSlots = _a.getInternalSlots;
11
- var internalSlots = getInternalSlots(numberFormat);
12
- var pl = internalSlots.pl, dataLocaleData = internalSlots.dataLocaleData, numberingSystem = internalSlots.numberingSystem;
13
- var symbols = dataLocaleData.numbers.symbols[numberingSystem] ||
14
- dataLocaleData.numbers.symbols[dataLocaleData.numbers.nu[0]];
15
- var magnitude = 0;
16
- var exponent = 0;
17
- var n;
18
- if (isNaN(x)) {
19
- n = symbols.nan;
20
- }
21
- else if (!isFinite(x)) {
22
- n = symbols.infinity;
23
- }
24
- else {
25
- if (internalSlots.style === 'percent') {
26
- x *= 100;
27
- }
28
- ;
29
- _b = ComputeExponent(numberFormat, x, {
30
- getInternalSlots: getInternalSlots,
31
- }), exponent = _b[0], magnitude = _b[1];
32
- // Preserve more precision by doing multiplication when exponent is negative.
33
- x = exponent < 0 ? x * Math.pow(10, -exponent) : x / Math.pow(10, exponent);
34
- var formatNumberResult = FormatNumericToString(internalSlots, x);
35
- n = formatNumberResult.formattedString;
36
- x = formatNumberResult.roundedNumber;
37
- }
38
- // Based on https://tc39.es/ecma402/#sec-getnumberformatpattern
39
- // We need to do this before `x` is rounded.
40
- var sign;
41
- var signDisplay = internalSlots.signDisplay;
42
- switch (signDisplay) {
43
- case 'never':
44
- sign = 0;
45
- break;
46
- case 'auto':
47
- if (SameValue(x, 0) || x > 0 || isNaN(x)) {
48
- sign = 0;
49
- }
50
- else {
51
- sign = -1;
52
- }
53
- break;
54
- case 'always':
55
- if (SameValue(x, 0) || x > 0 || isNaN(x)) {
56
- sign = 1;
57
- }
58
- else {
59
- sign = -1;
60
- }
61
- break;
62
- default:
63
- // x === 0 -> x is 0 or x is -0
64
- if (x === 0 || isNaN(x)) {
65
- sign = 0;
66
- }
67
- else if (x > 0) {
68
- sign = 1;
69
- }
70
- else {
71
- sign = -1;
72
- }
73
- }
74
- return formatToParts({ roundedNumber: x, formattedString: n, exponent: exponent, magnitude: magnitude, sign: sign }, internalSlots.dataLocaleData, pl, internalSlots);
75
- }
@@ -1,6 +0,0 @@
1
- import { NumberFormatDigitOptions, NumberFormatNotation, NumberFormatDigitInternalSlots } from '../types/number';
2
- /**
3
- * https://tc39.es/ecma402/#sec-setnfdigitoptions
4
- */
5
- export declare function SetNumberFormatDigitOptions(internalSlots: NumberFormatDigitInternalSlots, opts: NumberFormatDigitOptions, mnfdDefault: number, mxfdDefault: number, notation: NumberFormatNotation): void;
6
- //# sourceMappingURL=SetNumberFormatDigitOptions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SetNumberFormatDigitOptions.d.ts","sourceRoot":"","sources":["../../../../../../../packages/ecma402-abstract/NumberFormat/SetNumberFormatDigitOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,8BAA8B,EAC/B,MAAM,iBAAiB,CAAA;AAIxB;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,8BAA8B,EAC7C,IAAI,EAAE,wBAAwB,EAC9B,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,oBAAoB,QA4B/B"}
@@ -1,36 +0,0 @@
1
- import { GetNumberOption } from '../GetNumberOption';
2
- import { DefaultNumberOption } from '../DefaultNumberOption';
3
- /**
4
- * https://tc39.es/ecma402/#sec-setnfdigitoptions
5
- */
6
- export function SetNumberFormatDigitOptions(internalSlots, opts, mnfdDefault, mxfdDefault, notation) {
7
- var mnid = GetNumberOption(opts, 'minimumIntegerDigits', 1, 21, 1);
8
- var mnfd = opts.minimumFractionDigits;
9
- var mxfd = opts.maximumFractionDigits;
10
- var mnsd = opts.minimumSignificantDigits;
11
- var mxsd = opts.maximumSignificantDigits;
12
- internalSlots.minimumIntegerDigits = mnid;
13
- if (mnsd !== undefined || mxsd !== undefined) {
14
- internalSlots.roundingType = 'significantDigits';
15
- mnsd = DefaultNumberOption(mnsd, 1, 21, 1);
16
- mxsd = DefaultNumberOption(mxsd, mnsd, 21, 21);
17
- internalSlots.minimumSignificantDigits = mnsd;
18
- internalSlots.maximumSignificantDigits = mxsd;
19
- }
20
- else if (mnfd !== undefined || mxfd !== undefined) {
21
- internalSlots.roundingType = 'fractionDigits';
22
- mnfd = DefaultNumberOption(mnfd, 0, 20, mnfdDefault);
23
- var mxfdActualDefault = Math.max(mnfd, mxfdDefault);
24
- mxfd = DefaultNumberOption(mxfd, mnfd, 20, mxfdActualDefault);
25
- internalSlots.minimumFractionDigits = mnfd;
26
- internalSlots.maximumFractionDigits = mxfd;
27
- }
28
- else if (notation === 'compact') {
29
- internalSlots.roundingType = 'compactRounding';
30
- }
31
- else {
32
- internalSlots.roundingType = 'fractionDigits';
33
- internalSlots.minimumFractionDigits = mnfdDefault;
34
- internalSlots.maximumFractionDigits = mxfdDefault;
35
- }
36
- }
@@ -1,8 +0,0 @@
1
- import { NumberFormatInternal, NumberFormatOptions } from '../types/number';
2
- /**
3
- * https://tc39.es/ecma402/#sec-setnumberformatunitoptions
4
- */
5
- export declare function SetNumberFormatUnitOptions(nf: Intl.NumberFormat, options: NumberFormatOptions | undefined, { getInternalSlots, }: {
6
- getInternalSlots(nf: Intl.NumberFormat): NumberFormatInternal;
7
- }): void;
8
- //# sourceMappingURL=SetNumberFormatUnitOptions.d.ts.map