@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,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SetNumberFormatDigitOptions = void 0;
4
- var GetNumberOption_1 = require("../GetNumberOption");
5
- var DefaultNumberOption_1 = require("../DefaultNumberOption");
6
- /**
7
- * https://tc39.es/ecma402/#sec-setnfdigitoptions
8
- */
9
- function SetNumberFormatDigitOptions(internalSlots, opts, mnfdDefault, mxfdDefault, notation) {
10
- var mnid = (0, GetNumberOption_1.GetNumberOption)(opts, 'minimumIntegerDigits', 1, 21, 1);
11
- var mnfd = opts.minimumFractionDigits;
12
- var mxfd = opts.maximumFractionDigits;
13
- var mnsd = opts.minimumSignificantDigits;
14
- var mxsd = opts.maximumSignificantDigits;
15
- internalSlots.minimumIntegerDigits = mnid;
16
- if (mnsd !== undefined || mxsd !== undefined) {
17
- internalSlots.roundingType = 'significantDigits';
18
- mnsd = (0, DefaultNumberOption_1.DefaultNumberOption)(mnsd, 1, 21, 1);
19
- mxsd = (0, DefaultNumberOption_1.DefaultNumberOption)(mxsd, mnsd, 21, 21);
20
- internalSlots.minimumSignificantDigits = mnsd;
21
- internalSlots.maximumSignificantDigits = mxsd;
22
- }
23
- else if (mnfd !== undefined || mxfd !== undefined) {
24
- internalSlots.roundingType = 'fractionDigits';
25
- mnfd = (0, DefaultNumberOption_1.DefaultNumberOption)(mnfd, 0, 20, mnfdDefault);
26
- var mxfdActualDefault = Math.max(mnfd, mxfdDefault);
27
- mxfd = (0, DefaultNumberOption_1.DefaultNumberOption)(mxfd, mnfd, 20, mxfdActualDefault);
28
- internalSlots.minimumFractionDigits = mnfd;
29
- internalSlots.maximumFractionDigits = mxfd;
30
- }
31
- else if (notation === 'compact') {
32
- internalSlots.roundingType = 'compactRounding';
33
- }
34
- else {
35
- internalSlots.roundingType = 'fractionDigits';
36
- internalSlots.minimumFractionDigits = mnfdDefault;
37
- internalSlots.maximumFractionDigits = mxfdDefault;
38
- }
39
- }
40
- exports.SetNumberFormatDigitOptions = SetNumberFormatDigitOptions;
@@ -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
@@ -1 +0,0 @@
1
- {"version":3,"file":"SetNumberFormatUnitOptions.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/NumberFormat/SetNumberFormatUnitOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAE,mBAAmB,EAAC,MAAM,iBAAiB,CAAA;AAKzE;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,EAAE,EAAE,IAAI,CAAC,YAAY,EACrB,OAAO,iCAA2C,EAClD,EACE,gBAAgB,GACjB,EAAE;IAAC,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAA;CAAC,QA+DnE"}
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SetNumberFormatUnitOptions = void 0;
4
- var GetOption_1 = require("../GetOption");
5
- var IsWellFormedCurrencyCode_1 = require("../IsWellFormedCurrencyCode");
6
- var IsWellFormedUnitIdentifier_1 = require("../IsWellFormedUnitIdentifier");
7
- /**
8
- * https://tc39.es/ecma402/#sec-setnumberformatunitoptions
9
- */
10
- function SetNumberFormatUnitOptions(nf, options, _a) {
11
- if (options === void 0) { options = Object.create(null); }
12
- var getInternalSlots = _a.getInternalSlots;
13
- var internalSlots = getInternalSlots(nf);
14
- var style = (0, GetOption_1.GetOption)(options, 'style', 'string', ['decimal', 'percent', 'currency', 'unit'], 'decimal');
15
- internalSlots.style = style;
16
- var currency = (0, GetOption_1.GetOption)(options, 'currency', 'string', undefined, undefined);
17
- if (currency !== undefined && !(0, IsWellFormedCurrencyCode_1.IsWellFormedCurrencyCode)(currency)) {
18
- throw RangeError('Malformed currency code');
19
- }
20
- if (style === 'currency' && currency === undefined) {
21
- throw TypeError('currency cannot be undefined');
22
- }
23
- var currencyDisplay = (0, GetOption_1.GetOption)(options, 'currencyDisplay', 'string', ['code', 'symbol', 'narrowSymbol', 'name'], 'symbol');
24
- var currencySign = (0, GetOption_1.GetOption)(options, 'currencySign', 'string', ['standard', 'accounting'], 'standard');
25
- var unit = (0, GetOption_1.GetOption)(options, 'unit', 'string', undefined, undefined);
26
- if (unit !== undefined && !(0, IsWellFormedUnitIdentifier_1.IsWellFormedUnitIdentifier)(unit)) {
27
- throw RangeError('Invalid unit argument for Intl.NumberFormat()');
28
- }
29
- if (style === 'unit' && unit === undefined) {
30
- throw TypeError('unit cannot be undefined');
31
- }
32
- var unitDisplay = (0, GetOption_1.GetOption)(options, 'unitDisplay', 'string', ['short', 'narrow', 'long'], 'short');
33
- if (style === 'currency') {
34
- internalSlots.currency = currency.toUpperCase();
35
- internalSlots.currencyDisplay = currencyDisplay;
36
- internalSlots.currencySign = currencySign;
37
- }
38
- if (style === 'unit') {
39
- internalSlots.unit = unit;
40
- internalSlots.unitDisplay = unitDisplay;
41
- }
42
- }
43
- exports.SetNumberFormatUnitOptions = SetNumberFormatUnitOptions;
@@ -1,10 +0,0 @@
1
- import { RawNumberFormatResult } from '../types/number';
2
- /**
3
- * TODO: dedup with intl-pluralrules and support BigInt
4
- * https://tc39.es/ecma402/#sec-torawfixed
5
- * @param x a finite non-negative Number or BigInt
6
- * @param minFraction and integer between 0 and 20
7
- * @param maxFraction and integer between 0 and 20
8
- */
9
- export declare function ToRawFixed(x: number, minFraction: number, maxFraction: number): RawNumberFormatResult;
10
- //# sourceMappingURL=ToRawFixed.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ToRawFixed.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/NumberFormat/ToRawFixed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,qBAAqB,EAAC,MAAM,iBAAiB,CAAA;AAGrD;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,CAAC,EAAE,MAAM,EACT,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,qBAAqB,CAyCvB"}
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ToRawFixed = void 0;
4
- var utils_1 = require("../utils");
5
- /**
6
- * TODO: dedup with intl-pluralrules and support BigInt
7
- * https://tc39.es/ecma402/#sec-torawfixed
8
- * @param x a finite non-negative Number or BigInt
9
- * @param minFraction and integer between 0 and 20
10
- * @param maxFraction and integer between 0 and 20
11
- */
12
- function ToRawFixed(x, minFraction, maxFraction) {
13
- var f = maxFraction;
14
- var n = Math.round(x * Math.pow(10, f));
15
- var xFinal = n / Math.pow(10, f);
16
- // n is a positive integer, but it is possible to be greater than 1e21.
17
- // In such case we will go the slow path.
18
- // See also: https://tc39.es/ecma262/#sec-numeric-types-number-tostring
19
- var m;
20
- if (n < 1e21) {
21
- m = n.toString();
22
- }
23
- else {
24
- m = n.toString();
25
- var _a = m.split('e'), mantissa = _a[0], exponent = _a[1];
26
- m = mantissa.replace('.', '');
27
- m = m + (0, utils_1.repeat)('0', Math.max(+exponent - m.length + 1, 0));
28
- }
29
- var int;
30
- if (f !== 0) {
31
- var k = m.length;
32
- if (k <= f) {
33
- var z = (0, utils_1.repeat)('0', f + 1 - k);
34
- m = z + m;
35
- k = f + 1;
36
- }
37
- var a = m.slice(0, k - f);
38
- var b = m.slice(k - f);
39
- m = "".concat(a, ".").concat(b);
40
- int = a.length;
41
- }
42
- else {
43
- int = m.length;
44
- }
45
- var cut = maxFraction - minFraction;
46
- while (cut > 0 && m[m.length - 1] === '0') {
47
- m = m.slice(0, -1);
48
- cut--;
49
- }
50
- if (m[m.length - 1] === '.') {
51
- m = m.slice(0, -1);
52
- }
53
- return { formattedString: m, roundedNumber: xFinal, integerDigitsCount: int };
54
- }
55
- exports.ToRawFixed = ToRawFixed;
@@ -1,3 +0,0 @@
1
- import { RawNumberFormatResult } from '../types/number';
2
- export declare function ToRawPrecision(x: number, minPrecision: number, maxPrecision: number): RawNumberFormatResult;
3
- //# sourceMappingURL=ToRawPrecision.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ToRawPrecision.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/NumberFormat/ToRawPrecision.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,qBAAqB,EAAC,MAAM,iBAAiB,CAAA;AAGrD,wBAAgB,cAAc,CAC5B,CAAC,EAAE,MAAM,EACT,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,GACnB,qBAAqB,CA8EvB"}
@@ -1,78 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ToRawPrecision = void 0;
4
- var utils_1 = require("../utils");
5
- function ToRawPrecision(x, minPrecision, maxPrecision) {
6
- var p = maxPrecision;
7
- var m;
8
- var e;
9
- var xFinal;
10
- if (x === 0) {
11
- m = (0, utils_1.repeat)('0', p);
12
- e = 0;
13
- xFinal = 0;
14
- }
15
- else {
16
- var xToString = x.toString();
17
- // If xToString is formatted as scientific notation, the number is either very small or very
18
- // large. If the precision of the formatted string is lower that requested max precision, we
19
- // should still infer them from the formatted string, otherwise the formatted result might have
20
- // precision loss (e.g. 1e41 will not have 0 in every trailing digits).
21
- var xToStringExponentIndex = xToString.indexOf('e');
22
- var _a = xToString.split('e'), xToStringMantissa = _a[0], xToStringExponent = _a[1];
23
- var xToStringMantissaWithoutDecimalPoint = xToStringMantissa.replace('.', '');
24
- if (xToStringExponentIndex >= 0 &&
25
- xToStringMantissaWithoutDecimalPoint.length <= p) {
26
- e = +xToStringExponent;
27
- m =
28
- xToStringMantissaWithoutDecimalPoint +
29
- (0, utils_1.repeat)('0', p - xToStringMantissaWithoutDecimalPoint.length);
30
- xFinal = x;
31
- }
32
- else {
33
- e = (0, utils_1.getMagnitude)(x);
34
- var decimalPlaceOffset = e - p + 1;
35
- // n is the integer containing the required precision digits. To derive the formatted string,
36
- // we will adjust its decimal place in the logic below.
37
- var n = Math.round(adjustDecimalPlace(x, decimalPlaceOffset));
38
- // The rounding caused the change of magnitude, so we should increment `e` by 1.
39
- if (adjustDecimalPlace(n, p - 1) >= 10) {
40
- e = e + 1;
41
- // Divide n by 10 to swallow one precision.
42
- n = Math.floor(n / 10);
43
- }
44
- m = n.toString();
45
- // Equivalent of n * 10 ** (e - p + 1)
46
- xFinal = adjustDecimalPlace(n, p - 1 - e);
47
- }
48
- }
49
- var int;
50
- if (e >= p - 1) {
51
- m = m + (0, utils_1.repeat)('0', e - p + 1);
52
- int = e + 1;
53
- }
54
- else if (e >= 0) {
55
- m = "".concat(m.slice(0, e + 1), ".").concat(m.slice(e + 1));
56
- int = e + 1;
57
- }
58
- else {
59
- m = "0.".concat((0, utils_1.repeat)('0', -e - 1)).concat(m);
60
- int = 1;
61
- }
62
- if (m.indexOf('.') >= 0 && maxPrecision > minPrecision) {
63
- var cut = maxPrecision - minPrecision;
64
- while (cut > 0 && m[m.length - 1] === '0') {
65
- m = m.slice(0, -1);
66
- cut--;
67
- }
68
- if (m[m.length - 1] === '.') {
69
- m = m.slice(0, -1);
70
- }
71
- }
72
- return { formattedString: m, roundedNumber: xFinal, integerDigitsCount: int };
73
- // x / (10 ** magnitude), but try to preserve as much floating point precision as possible.
74
- function adjustDecimalPlace(x, magnitude) {
75
- return magnitude < 0 ? x * Math.pow(10, -magnitude) : x / Math.pow(10, magnitude);
76
- }
77
- }
78
- exports.ToRawPrecision = ToRawPrecision;
@@ -1,2 +0,0 @@
1
- export declare const digitMapping: Record<string, ReadonlyArray<string>>;
2
- //# sourceMappingURL=digit-mapping.generated.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"digit-mapping.generated.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/NumberFormat/digit-mapping.generated.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAA67G,CAAC"}
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.digitMapping = void 0;
4
- exports.digitMapping = { "adlm": ["𞥐", "𞥑", "𞥒", "𞥓", "𞥔", "𞥕", "𞥖", "𞥗", "𞥘", "𞥙"], "ahom": ["𑜰", "𑜱", "𑜲", "𑜳", "𑜴", "𑜵", "𑜶", "𑜷", "𑜸", "𑜹"], "arab": ["٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"], "arabext": ["۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"], "bali": ["᭐", "᭑", "᭒", "᭓", "᭔", "᭕", "᭖", "᭗", "᭘", "᭙"], "beng": ["০", "১", "২", "৩", "৪", "৫", "৬", "৭", "৮", "৯"], "bhks": ["𑱐", "𑱑", "𑱒", "𑱓", "𑱔", "𑱕", "𑱖", "𑱗", "𑱘", "𑱙"], "brah": ["𑁦", "𑁧", "𑁨", "𑁩", "𑁪", "𑁫", "𑁬", "𑁭", "𑁮", "𑁯"], "cakm": ["𑄶", "𑄷", "𑄸", "𑄹", "𑄺", "𑄻", "𑄼", "𑄽", "𑄾", "𑄿"], "cham": ["꩐", "꩑", "꩒", "꩓", "꩔", "꩕", "꩖", "꩗", "꩘", "꩙"], "deva": ["०", "१", "२", "३", "४", "५", "६", "७", "८", "९"], "diak": ["𑥐", "𑥑", "𑥒", "𑥓", "𑥔", "𑥕", "𑥖", "𑥗", "𑥘", "𑥙"], "fullwide": ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], "gong": ["𑶠", "𑶡", "𑶢", "𑶣", "𑶤", "𑶥", "𑶦", "𑶧", "𑶨", "𑶩"], "gonm": ["𑵐", "𑵑", "𑵒", "𑵓", "𑵔", "𑵕", "𑵖", "𑵗", "𑵘", "𑵙"], "gujr": ["૦", "૧", "૨", "૩", "૪", "૫", "૬", "૭", "૮", "૯"], "guru": ["੦", "੧", "੨", "੩", "੪", "੫", "੬", "੭", "੮", "੯"], "hanidec": ["〇", "一", "二", "三", "四", "五", "六", "七", "八", "九"], "hmng": ["𖭐", "𖭑", "𖭒", "𖭓", "𖭔", "𖭕", "𖭖", "𖭗", "𖭘", "𖭙"], "hmnp": ["𞅀", "𞅁", "𞅂", "𞅃", "𞅄", "𞅅", "𞅆", "𞅇", "𞅈", "𞅉"], "java": ["꧐", "꧑", "꧒", "꧓", "꧔", "꧕", "꧖", "꧗", "꧘", "꧙"], "kali": ["꤀", "꤁", "꤂", "꤃", "꤄", "꤅", "꤆", "꤇", "꤈", "꤉"], "khmr": ["០", "១", "២", "៣", "៤", "៥", "៦", "៧", "៨", "៩"], "knda": ["೦", "೧", "೨", "೩", "೪", "೫", "೬", "೭", "೮", "೯"], "lana": ["᪀", "᪁", "᪂", "᪃", "᪄", "᪅", "᪆", "᪇", "᪈", "᪉"], "lanatham": ["᪐", "᪑", "᪒", "᪓", "᪔", "᪕", "᪖", "᪗", "᪘", "᪙"], "laoo": ["໐", "໑", "໒", "໓", "໔", "໕", "໖", "໗", "໘", "໙"], "lepc": ["᪐", "᪑", "᪒", "᪓", "᪔", "᪕", "᪖", "᪗", "᪘", "᪙"], "limb": ["᥆", "᥇", "᥈", "᥉", "᥊", "᥋", "᥌", "᥍", "᥎", "᥏"], "mathbold": ["𝟎", "𝟏", "𝟐", "𝟑", "𝟒", "𝟓", "𝟔", "𝟕", "𝟖", "𝟗"], "mathdbl": ["𝟘", "𝟙", "𝟚", "𝟛", "𝟜", "𝟝", "𝟞", "𝟟", "𝟠", "𝟡"], "mathmono": ["𝟶", "𝟷", "𝟸", "𝟹", "𝟺", "𝟻", "𝟼", "𝟽", "𝟾", "𝟿"], "mathsanb": ["𝟬", "𝟭", "𝟮", "𝟯", "𝟰", "𝟱", "𝟲", "𝟳", "𝟴", "𝟵"], "mathsans": ["𝟢", "𝟣", "𝟤", "𝟥", "𝟦", "𝟧", "𝟨", "𝟩", "𝟪", "𝟫"], "mlym": ["൦", "൧", "൨", "൩", "൪", "൫", "൬", "൭", "൮", "൯"], "modi": ["𑙐", "𑙑", "𑙒", "𑙓", "𑙔", "𑙕", "𑙖", "𑙗", "𑙘", "𑙙"], "mong": ["᠐", "᠑", "᠒", "᠓", "᠔", "᠕", "᠖", "᠗", "᠘", "᠙"], "mroo": ["𖩠", "𖩡", "𖩢", "𖩣", "𖩤", "𖩥", "𖩦", "𖩧", "𖩨", "𖩩"], "mtei": ["꯰", "꯱", "꯲", "꯳", "꯴", "꯵", "꯶", "꯷", "꯸", "꯹"], "mymr": ["၀", "၁", "၂", "၃", "၄", "၅", "၆", "၇", "၈", "၉"], "mymrshan": ["႐", "႑", "႒", "႓", "႔", "႕", "႖", "႗", "႘", "႙"], "mymrtlng": ["꧰", "꧱", "꧲", "꧳", "꧴", "꧵", "꧶", "꧷", "꧸", "꧹"], "newa": ["𑑐", "𑑑", "𑑒", "𑑓", "𑑔", "𑑕", "𑑖", "𑑗", "𑑘", "𑑙"], "nkoo": ["߀", "߁", "߂", "߃", "߄", "߅", "߆", "߇", "߈", "߉"], "olck": ["᱐", "᱑", "᱒", "᱓", "᱔", "᱕", "᱖", "᱗", "᱘", "᱙"], "orya": ["୦", "୧", "୨", "୩", "୪", "୫", "୬", "୭", "୮", "୯"], "osma": ["𐒠", "𐒡", "𐒢", "𐒣", "𐒤", "𐒥", "𐒦", "𐒧", "𐒨", "𐒩"], "rohg": ["𐴰", "𐴱", "𐴲", "𐴳", "𐴴", "𐴵", "𐴶", "𐴷", "𐴸", "𐴹"], "saur": ["꣐", "꣑", "꣒", "꣓", "꣔", "꣕", "꣖", "꣗", "꣘", "꣙"], "segment": ["🯰", "🯱", "🯲", "🯳", "🯴", "🯵", "🯶", "🯷", "🯸", "🯹"], "shrd": ["𑇐", "𑇑", "𑇒", "𑇓", "𑇔", "𑇕", "𑇖", "𑇗", "𑇘", "𑇙"], "sind": ["𑋰", "𑋱", "𑋲", "𑋳", "𑋴", "𑋵", "𑋶", "𑋷", "𑋸", "𑋹"], "sinh": ["෦", "෧", "෨", "෩", "෪", "෫", "෬", "෭", "෮", "෯"], "sora": ["𑃰", "𑃱", "𑃲", "𑃳", "𑃴", "𑃵", "𑃶", "𑃷", "𑃸", "𑃹"], "sund": ["᮰", "᮱", "᮲", "᮳", "᮴", "᮵", "᮶", "᮷", "᮸", "᮹"], "takr": ["𑛀", "𑛁", "𑛂", "𑛃", "𑛄", "𑛅", "𑛆", "𑛇", "𑛈", "𑛉"], "talu": ["᧐", "᧑", "᧒", "᧓", "᧔", "᧕", "᧖", "᧗", "᧘", "᧙"], "tamldec": ["௦", "௧", "௨", "௩", "௪", "௫", "௬", "௭", "௮", "௯"], "telu": ["౦", "౧", "౨", "౩", "౪", "౫", "౬", "౭", "౮", "౯"], "thai": ["๐", "๑", "๒", "๓", "๔", "๕", "๖", "๗", "๘", "๙"], "tibt": ["༠", "༡", "༢", "༣", "༤", "༥", "༦", "༧", "༨", "༩"], "tirh": ["𑓐", "𑓑", "𑓒", "𑓓", "𑓔", "𑓕", "𑓖", "𑓗", "𑓘", "𑓙"], "vaii": ["ᘠ", "ᘡ", "ᘢ", "ᘣ", "ᘤ", "ᘥ", "ᘦ", "ᘧ", "ᘨ", "ᘩ"], "wara": ["𑣠", "𑣡", "𑣢", "𑣣", "𑣤", "𑣥", "𑣦", "𑣧", "𑣨", "𑣩"], "wcho": ["𞋰", "𞋱", "𞋲", "𞋳", "𞋴", "𞋵", "𞋶", "𞋷", "𞋸", "𞋹"] };
@@ -1,22 +0,0 @@
1
- import { NumberFormatOptionsStyle, NumberFormatOptionsNotation, NumberFormatOptionsCompactDisplay, NumberFormatOptionsCurrencyDisplay, NumberFormatOptionsCurrencySign, NumberFormatOptionsUnitDisplay, NumberFormatLocaleInternalData, NumberFormatPart } from '../types/number';
2
- interface NumberResult {
3
- formattedString: string;
4
- roundedNumber: number;
5
- sign: -1 | 0 | 1;
6
- exponent: number;
7
- magnitude: number;
8
- }
9
- export default function formatToParts(numberResult: NumberResult, data: NumberFormatLocaleInternalData, pl: Intl.PluralRules, options: {
10
- numberingSystem: string;
11
- useGrouping: boolean;
12
- style: NumberFormatOptionsStyle;
13
- notation: NumberFormatOptionsNotation;
14
- compactDisplay?: NumberFormatOptionsCompactDisplay;
15
- currency?: string;
16
- currencyDisplay?: NumberFormatOptionsCurrencyDisplay;
17
- currencySign?: NumberFormatOptionsCurrencySign;
18
- unit?: string;
19
- unitDisplay?: NumberFormatOptionsUnitDisplay;
20
- }): NumberFormatPart[];
21
- export {};
22
- //# sourceMappingURL=format_to_parts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"format_to_parts.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/NumberFormat/format_to_parts.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,iCAAiC,EACjC,kCAAkC,EAClC,+BAA+B,EAC/B,8BAA8B,EAC9B,8BAA8B,EAM9B,gBAAgB,EACjB,MAAM,iBAAiB,CAAA;AAexB,UAAU,YAAY;IACpB,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAEhB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,8BAA8B,EACpC,EAAE,EAAE,IAAI,CAAC,WAAW,EACpB,OAAO,EAAE;IACP,eAAe,EAAE,MAAM,CAAA;IACvB,WAAW,EAAE,OAAO,CAAA;IACpB,KAAK,EAAE,wBAAwB,CAAA;IAE/B,QAAQ,EAAE,2BAA2B,CAAA;IAErC,cAAc,CAAC,EAAE,iCAAiC,CAAA;IAElD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,kCAAkC,CAAA;IACpD,YAAY,CAAC,EAAE,+BAA+B,CAAA;IAE9C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,8BAA8B,CAAA;CAC7C,GACA,gBAAgB,EAAE,CAySpB"}