@formatjs/ecma402-abstract 2.3.5 → 3.0.0

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 (177) hide show
  1. package/262.d.ts +1 -1
  2. package/262.js +42 -68
  3. package/CanonicalizeLocaleList.js +1 -4
  4. package/CanonicalizeTimeZoneName.js +1 -4
  5. package/CoerceOptionsToObject.js +3 -6
  6. package/DefaultNumberOption.js +1 -4
  7. package/GetNumberOption.js +3 -6
  8. package/GetOption.js +3 -6
  9. package/GetOptionsObject.js +1 -4
  10. package/GetStringOrBooleanOption.js +3 -6
  11. package/IsSanctionedSimpleUnitIdentifier.js +5 -10
  12. package/IsValidTimeZoneName.js +1 -4
  13. package/IsWellFormedCurrencyCode.js +1 -4
  14. package/IsWellFormedUnitIdentifier.js +5 -8
  15. package/NumberFormat/ApplyUnsignedRoundingMode.d.ts +2 -2
  16. package/NumberFormat/ApplyUnsignedRoundingMode.js +5 -8
  17. package/NumberFormat/CollapseNumberRange.d.ts +1 -1
  18. package/NumberFormat/CollapseNumberRange.js +1 -4
  19. package/NumberFormat/ComputeExponent.d.ts +2 -2
  20. package/NumberFormat/ComputeExponent.js +8 -12
  21. package/NumberFormat/ComputeExponentForMagnitude.d.ts +2 -2
  22. package/NumberFormat/ComputeExponentForMagnitude.js +6 -10
  23. package/NumberFormat/CurrencyDigits.js +3 -6
  24. package/NumberFormat/FormatApproximately.d.ts +1 -1
  25. package/NumberFormat/FormatApproximately.js +1 -4
  26. package/NumberFormat/FormatNumeric.d.ts +2 -2
  27. package/NumberFormat/FormatNumeric.js +3 -6
  28. package/NumberFormat/FormatNumericRange.d.ts +2 -2
  29. package/NumberFormat/FormatNumericRange.js +3 -6
  30. package/NumberFormat/FormatNumericRangeToParts.d.ts +2 -2
  31. package/NumberFormat/FormatNumericRangeToParts.js +3 -6
  32. package/NumberFormat/FormatNumericToParts.d.ts +2 -2
  33. package/NumberFormat/FormatNumericToParts.js +5 -8
  34. package/NumberFormat/FormatNumericToString.d.ts +2 -2
  35. package/NumberFormat/FormatNumericToString.js +16 -19
  36. package/NumberFormat/GetUnsignedRoundingMode.d.ts +1 -1
  37. package/NumberFormat/GetUnsignedRoundingMode.js +1 -4
  38. package/NumberFormat/InitializeNumberFormat.d.ts +1 -1
  39. package/NumberFormat/InitializeNumberFormat.js +23 -26
  40. package/NumberFormat/PartitionNumberPattern.d.ts +2 -2
  41. package/NumberFormat/PartitionNumberPattern.js +12 -16
  42. package/NumberFormat/PartitionNumberRangePattern.d.ts +2 -2
  43. package/NumberFormat/PartitionNumberRangePattern.js +12 -15
  44. package/NumberFormat/SetNumberFormatDigitOptions.d.ts +1 -1
  45. package/NumberFormat/SetNumberFormatDigitOptions.js +18 -21
  46. package/NumberFormat/SetNumberFormatUnitOptions.d.ts +1 -1
  47. package/NumberFormat/SetNumberFormatUnitOptions.js +15 -18
  48. package/NumberFormat/ToRawFixed.d.ts +2 -2
  49. package/NumberFormat/ToRawFixed.js +10 -14
  50. package/NumberFormat/ToRawPrecision.d.ts +2 -2
  51. package/NumberFormat/ToRawPrecision.js +19 -23
  52. package/NumberFormat/digit-mapping.generated.js +1 -4
  53. package/NumberFormat/format_to_parts.d.ts +2 -2
  54. package/NumberFormat/format_to_parts.js +18 -22
  55. package/PartitionPattern.d.ts +1 -0
  56. package/PartitionPattern.js +4 -6
  57. package/SupportedLocales.js +8 -11
  58. package/ToIntlMathematicalValue.d.ts +1 -1
  59. package/ToIntlMathematicalValue.js +12 -16
  60. package/constants.d.ts +1 -1
  61. package/constants.js +4 -8
  62. package/data.js +3 -6
  63. package/index.d.ts +47 -47
  64. package/index.js +45 -66
  65. package/package.json +7 -5
  66. package/regex.generated.js +1 -4
  67. package/types/core.js +1 -2
  68. package/types/date-time.js +2 -5
  69. package/types/displaynames.d.ts +1 -1
  70. package/types/displaynames.js +1 -2
  71. package/types/list.d.ts +1 -1
  72. package/types/list.js +1 -2
  73. package/types/number.d.ts +3 -3
  74. package/types/number.js +1 -2
  75. package/types/plural-rules.d.ts +2 -2
  76. package/types/plural-rules.js +1 -2
  77. package/types/relative-time.d.ts +2 -2
  78. package/types/relative-time.js +1 -2
  79. package/utils.js +28 -40
  80. package/lib/262.d.ts +0 -93
  81. package/lib/262.js +0 -400
  82. package/lib/CanonicalizeLocaleList.d.ts +0 -5
  83. package/lib/CanonicalizeLocaleList.js +0 -8
  84. package/lib/CanonicalizeTimeZoneName.d.ts +0 -8
  85. package/lib/CanonicalizeTimeZoneName.js +0 -17
  86. package/lib/CoerceOptionsToObject.d.ts +0 -6
  87. package/lib/CoerceOptionsToObject.js +0 -12
  88. package/lib/DefaultNumberOption.d.ts +0 -8
  89. package/lib/DefaultNumberOption.js +0 -18
  90. package/lib/GetNumberOption.d.ts +0 -9
  91. package/lib/GetNumberOption.js +0 -13
  92. package/lib/GetOption.d.ts +0 -9
  93. package/lib/GetOption.js +0 -31
  94. package/lib/GetOptionsObject.d.ts +0 -6
  95. package/lib/GetOptionsObject.js +0 -14
  96. package/lib/GetStringOrBooleanOption.d.ts +0 -10
  97. package/lib/GetStringOrBooleanOption.js +0 -31
  98. package/lib/IsSanctionedSimpleUnitIdentifier.d.ts +0 -13
  99. package/lib/IsSanctionedSimpleUnitIdentifier.js +0 -63
  100. package/lib/IsValidTimeZoneName.d.ts +0 -9
  101. package/lib/IsValidTimeZoneName.js +0 -17
  102. package/lib/IsWellFormedCurrencyCode.d.ts +0 -4
  103. package/lib/IsWellFormedCurrencyCode.js +0 -21
  104. package/lib/IsWellFormedUnitIdentifier.d.ts +0 -5
  105. package/lib/IsWellFormedUnitIdentifier.js +0 -28
  106. package/lib/NumberFormat/ApplyUnsignedRoundingMode.d.ts +0 -3
  107. package/lib/NumberFormat/ApplyUnsignedRoundingMode.js +0 -33
  108. package/lib/NumberFormat/CollapseNumberRange.d.ts +0 -8
  109. package/lib/NumberFormat/CollapseNumberRange.js +0 -50
  110. package/lib/NumberFormat/ComputeExponent.d.ts +0 -10
  111. package/lib/NumberFormat/ComputeExponent.js +0 -34
  112. package/lib/NumberFormat/ComputeExponentForMagnitude.d.ts +0 -8
  113. package/lib/NumberFormat/ComputeExponentForMagnitude.js +0 -65
  114. package/lib/NumberFormat/CurrencyDigits.d.ts +0 -6
  115. package/lib/NumberFormat/CurrencyDigits.js +0 -10
  116. package/lib/NumberFormat/FormatApproximately.d.ts +0 -5
  117. package/lib/NumberFormat/FormatApproximately.js +0 -9
  118. package/lib/NumberFormat/FormatNumeric.d.ts +0 -3
  119. package/lib/NumberFormat/FormatNumeric.js +0 -5
  120. package/lib/NumberFormat/FormatNumericRange.d.ts +0 -8
  121. package/lib/NumberFormat/FormatNumericRange.js +0 -11
  122. package/lib/NumberFormat/FormatNumericRangeToParts.d.ts +0 -8
  123. package/lib/NumberFormat/FormatNumericRangeToParts.js +0 -16
  124. package/lib/NumberFormat/FormatNumericToParts.d.ts +0 -5
  125. package/lib/NumberFormat/FormatNumericToParts.js +0 -14
  126. package/lib/NumberFormat/FormatNumericToString.d.ts +0 -9
  127. package/lib/NumberFormat/FormatNumericToString.js +0 -84
  128. package/lib/NumberFormat/GetUnsignedRoundingMode.d.ts +0 -2
  129. package/lib/NumberFormat/GetUnsignedRoundingMode.js +0 -28
  130. package/lib/NumberFormat/InitializeNumberFormat.d.ts +0 -12
  131. package/lib/NumberFormat/InitializeNumberFormat.js +0 -66
  132. package/lib/NumberFormat/PartitionNumberPattern.d.ts +0 -6
  133. package/lib/NumberFormat/PartitionNumberPattern.js +0 -126
  134. package/lib/NumberFormat/PartitionNumberRangePattern.d.ts +0 -8
  135. package/lib/NumberFormat/PartitionNumberRangePattern.js +0 -40
  136. package/lib/NumberFormat/SetNumberFormatDigitOptions.d.ts +0 -5
  137. package/lib/NumberFormat/SetNumberFormatDigitOptions.js +0 -179
  138. package/lib/NumberFormat/SetNumberFormatUnitOptions.d.ts +0 -5
  139. package/lib/NumberFormat/SetNumberFormatUnitOptions.js +0 -50
  140. package/lib/NumberFormat/ToRawFixed.d.ts +0 -9
  141. package/lib/NumberFormat/ToRawFixed.js +0 -119
  142. package/lib/NumberFormat/ToRawPrecision.d.ts +0 -9
  143. package/lib/NumberFormat/ToRawPrecision.js +0 -148
  144. package/lib/NumberFormat/digit-mapping.generated.d.ts +0 -1
  145. package/lib/NumberFormat/digit-mapping.generated.js +0 -782
  146. package/lib/NumberFormat/format_to_parts.d.ts +0 -24
  147. package/lib/NumberFormat/format_to_parts.js +0 -447
  148. package/lib/PartitionPattern.d.ts +0 -8
  149. package/lib/PartitionPattern.js +0 -35
  150. package/lib/SupportedLocales.d.ts +0 -9
  151. package/lib/SupportedLocales.js +0 -20
  152. package/lib/ToIntlMathematicalValue.d.ts +0 -2
  153. package/lib/ToIntlMathematicalValue.js +0 -27
  154. package/lib/constants.d.ts +0 -4
  155. package/lib/constants.js +0 -4
  156. package/lib/data.d.ts +0 -5
  157. package/lib/data.js +0 -13
  158. package/lib/index.d.ts +0 -47
  159. package/lib/index.js +0 -45
  160. package/lib/regex.generated.d.ts +0 -1
  161. package/lib/regex.generated.js +0 -2
  162. package/lib/types/core.d.ts +0 -10
  163. package/lib/types/core.js +0 -1
  164. package/lib/types/date-time.d.ts +0 -135
  165. package/lib/types/date-time.js +0 -6
  166. package/lib/types/displaynames.d.ts +0 -65
  167. package/lib/types/displaynames.js +0 -1
  168. package/lib/types/list.d.ts +0 -18
  169. package/lib/types/list.js +0 -1
  170. package/lib/types/number.d.ts +0 -173
  171. package/lib/types/number.js +0 -1
  172. package/lib/types/plural-rules.d.ts +0 -16
  173. package/lib/types/plural-rules.js +0 -1
  174. package/lib/types/relative-time.d.ts +0 -40
  175. package/lib/types/relative-time.js +0 -1
  176. package/lib/utils.d.ts +0 -30
  177. package/lib/utils.js +0 -135
@@ -1,5 +1,5 @@
1
- import Decimal from 'decimal.js';
2
- import { NumberFormatInternal } from '../types/number';
1
+ import { Decimal } from 'decimal.js';
2
+ import { NumberFormatInternal } from '../types/number.js';
3
3
  /**
4
4
  * The abstract operation ComputeExponentForMagnitude computes an exponent by which to scale a
5
5
  * number of the given magnitude (power of ten of the most significant digit) according to the
@@ -1,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ComputeExponentForMagnitude = ComputeExponentForMagnitude;
4
- var tslib_1 = require("tslib");
5
- var decimal_js_1 = tslib_1.__importDefault(require("decimal.js"));
6
- var utils_1 = require("../utils");
7
- decimal_js_1.default.set({
1
+ import { Decimal } from 'decimal.js';
2
+ import { invariant } from '../utils.js';
3
+ Decimal.set({
8
4
  toExpPos: 100,
9
5
  });
10
6
  /**
@@ -12,7 +8,7 @@ decimal_js_1.default.set({
12
8
  * number of the given magnitude (power of ten of the most significant digit) according to the
13
9
  * locale and the desired notation (scientific, engineering, or compact).
14
10
  */
15
- function ComputeExponentForMagnitude(internalSlots, magnitude) {
11
+ export function ComputeExponentForMagnitude(internalSlots, magnitude) {
16
12
  var notation = internalSlots.notation, dataLocaleData = internalSlots.dataLocaleData, numberingSystem = internalSlots.numberingSystem;
17
13
  switch (notation) {
18
14
  case 'standard':
@@ -23,7 +19,7 @@ function ComputeExponentForMagnitude(internalSlots, magnitude) {
23
19
  var thousands = magnitude.div(3).floor();
24
20
  return thousands.times(3).toNumber();
25
21
  default: {
26
- (0, utils_1.invariant)(notation === 'compact', 'Invalid notation');
22
+ invariant(notation === 'compact', 'Invalid notation');
27
23
  // Let exponent be an implementation- and locale-dependent (ILD) integer by which to scale a
28
24
  // number of the given magnitude in compact notation for the current locale.
29
25
  var compactDisplay = internalSlots.compactDisplay, style = internalSlots.style, currencyDisplay = internalSlots.currencyDisplay;
@@ -41,7 +37,7 @@ function ComputeExponentForMagnitude(internalSlots, magnitude) {
41
37
  if (!thresholdMap) {
42
38
  return 0;
43
39
  }
44
- var num = decimal_js_1.default.pow(10, magnitude).toString();
40
+ var num = Decimal.pow(10, magnitude).toString();
45
41
  var thresholds = Object.keys(thresholdMap); // TODO: this can be pre-processed
46
42
  if (num < thresholds[0]) {
47
43
  return 0;
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CurrencyDigits = CurrencyDigits;
4
- var _262_1 = require("../262");
1
+ import { HasOwnProperty } from '../262.js';
5
2
  /**
6
3
  * https://tc39.es/ecma402/#sec-currencydigits
7
4
  */
8
- function CurrencyDigits(c, _a) {
5
+ export function CurrencyDigits(c, _a) {
9
6
  var currencyDigitsData = _a.currencyDigitsData;
10
- return (0, _262_1.HasOwnProperty)(currencyDigitsData, c)
7
+ return HasOwnProperty(currencyDigitsData, c)
11
8
  ? currencyDigitsData[c]
12
9
  : 2;
13
10
  }
@@ -1,4 +1,4 @@
1
- import { NumberFormatInternal, NumberFormatPart } from '../types/number';
1
+ import { NumberFormatInternal, NumberFormatPart } from '../types/number.js';
2
2
  /**
3
3
  * https://tc39.es/ecma402/#sec-formatapproximately
4
4
  */
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormatApproximately = FormatApproximately;
4
1
  /**
5
2
  * https://tc39.es/ecma402/#sec-formatapproximately
6
3
  */
7
- function FormatApproximately(internalSlots, result) {
4
+ export function FormatApproximately(internalSlots, result) {
8
5
  var symbols = internalSlots.dataLocaleData.numbers.symbols[internalSlots.numberingSystem];
9
6
  var approximatelySign = symbols.approximatelySign;
10
7
  result.push({ type: 'approximatelySign', value: approximatelySign });
@@ -1,3 +1,3 @@
1
- import Decimal from 'decimal.js';
2
- import { NumberFormatInternal } from '../types/number';
1
+ import { Decimal } from 'decimal.js';
2
+ import { NumberFormatInternal } from '../types/number.js';
3
3
  export declare function FormatNumeric(internalSlots: NumberFormatInternal, x: Decimal): string;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormatNumeric = FormatNumeric;
4
- var PartitionNumberPattern_1 = require("./PartitionNumberPattern");
5
- function FormatNumeric(internalSlots, x) {
6
- var parts = (0, PartitionNumberPattern_1.PartitionNumberPattern)(internalSlots, x);
1
+ import { PartitionNumberPattern } from './PartitionNumberPattern.js';
2
+ export function FormatNumeric(internalSlots, x) {
3
+ var parts = PartitionNumberPattern(internalSlots, x);
7
4
  return parts.map(function (p) { return p.value; }).join('');
8
5
  }
@@ -1,5 +1,5 @@
1
- import Decimal from 'decimal.js';
2
- import { NumberFormatInternal } from '../types/number';
1
+ import { Decimal } from 'decimal.js';
2
+ import { NumberFormatInternal } from '../types/number.js';
3
3
  /**
4
4
  * https://tc39.es/ecma402/#sec-formatnumericrange
5
5
  */
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormatNumericRange = FormatNumericRange;
4
- var PartitionNumberRangePattern_1 = require("./PartitionNumberRangePattern");
1
+ import { PartitionNumberRangePattern } from './PartitionNumberRangePattern.js';
5
2
  /**
6
3
  * https://tc39.es/ecma402/#sec-formatnumericrange
7
4
  */
8
- function FormatNumericRange(numberFormat, x, y, _a) {
5
+ export function FormatNumericRange(numberFormat, x, y, _a) {
9
6
  var getInternalSlots = _a.getInternalSlots;
10
- var parts = (0, PartitionNumberRangePattern_1.PartitionNumberRangePattern)(numberFormat, x, y, {
7
+ var parts = PartitionNumberRangePattern(numberFormat, x, y, {
11
8
  getInternalSlots: getInternalSlots,
12
9
  });
13
10
  return parts.map(function (part) { return part.value; }).join('');
@@ -1,5 +1,5 @@
1
- import Decimal from 'decimal.js';
2
- import { NumberFormatInternal, NumberRangeToParts } from '../types/number';
1
+ import { Decimal } from 'decimal.js';
2
+ import { NumberFormatInternal, NumberRangeToParts } from '../types/number.js';
3
3
  /**
4
4
  * https://tc39.es/ecma402/#sec-formatnumericrangetoparts
5
5
  */
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormatNumericRangeToParts = FormatNumericRangeToParts;
4
- var PartitionNumberRangePattern_1 = require("./PartitionNumberRangePattern");
1
+ import { PartitionNumberRangePattern } from './PartitionNumberRangePattern.js';
5
2
  /**
6
3
  * https://tc39.es/ecma402/#sec-formatnumericrangetoparts
7
4
  */
8
- function FormatNumericRangeToParts(numberFormat, x, y, _a) {
5
+ export function FormatNumericRangeToParts(numberFormat, x, y, _a) {
9
6
  var getInternalSlots = _a.getInternalSlots;
10
- var parts = (0, PartitionNumberRangePattern_1.PartitionNumberRangePattern)(numberFormat, x, y, {
7
+ var parts = PartitionNumberRangePattern(numberFormat, x, y, {
11
8
  getInternalSlots: getInternalSlots,
12
9
  });
13
10
  return parts.map(function (part, index) { return ({
@@ -1,5 +1,5 @@
1
- import Decimal from 'decimal.js';
2
- import { NumberFormatInternal, NumberFormatPart } from '../types/number';
1
+ import { Decimal } from 'decimal.js';
2
+ import { NumberFormatInternal, NumberFormatPart } from '../types/number.js';
3
3
  export declare function FormatNumericToParts(nf: Intl.NumberFormat, x: Decimal, implDetails: {
4
4
  getInternalSlots(nf: Intl.NumberFormat): NumberFormatInternal;
5
5
  }): NumberFormatPart[];
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormatNumericToParts = FormatNumericToParts;
4
- var _262_1 = require("../262");
5
- var PartitionNumberPattern_1 = require("./PartitionNumberPattern");
6
- function FormatNumericToParts(nf, x, implDetails) {
7
- var parts = (0, PartitionNumberPattern_1.PartitionNumberPattern)(implDetails.getInternalSlots(nf), x);
8
- var result = (0, _262_1.ArrayCreate)(0);
1
+ import { ArrayCreate } from '../262.js';
2
+ import { PartitionNumberPattern } from './PartitionNumberPattern.js';
3
+ export function FormatNumericToParts(nf, x, implDetails) {
4
+ var parts = PartitionNumberPattern(implDetails.getInternalSlots(nf), x);
5
+ var result = ArrayCreate(0);
9
6
  for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
10
7
  var part = parts_1[_i];
11
8
  result.push({
@@ -1,5 +1,5 @@
1
- import Decimal from 'decimal.js';
2
- import { NumberFormatDigitInternalSlots } from '../types/number';
1
+ import { Decimal } from 'decimal.js';
2
+ import { NumberFormatDigitInternalSlots } from '../types/number.js';
3
3
  /**
4
4
  * https://tc39.es/ecma402/#sec-formatnumberstring
5
5
  */
@@ -1,24 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormatNumericToString = FormatNumericToString;
4
- var constants_1 = require("../constants");
5
- var utils_1 = require("../utils");
6
- var GetUnsignedRoundingMode_1 = require("./GetUnsignedRoundingMode");
7
- var ToRawFixed_1 = require("./ToRawFixed");
8
- var ToRawPrecision_1 = require("./ToRawPrecision");
1
+ import { NEGATIVE_ZERO, ZERO } from '../constants.js';
2
+ import { invariant, repeat } from '../utils.js';
3
+ import { GetUnsignedRoundingMode } from './GetUnsignedRoundingMode.js';
4
+ import { ToRawFixed } from './ToRawFixed.js';
5
+ import { ToRawPrecision } from './ToRawPrecision.js';
9
6
  /**
10
7
  * https://tc39.es/ecma402/#sec-formatnumberstring
11
8
  */
12
- function FormatNumericToString(intlObject, _x) {
9
+ export function FormatNumericToString(intlObject, _x) {
13
10
  var x = _x;
14
11
  var sign;
15
12
  // -0
16
13
  if (x.isZero() && x.isNegative()) {
17
14
  sign = 'negative';
18
- x = constants_1.ZERO;
15
+ x = ZERO;
19
16
  }
20
17
  else {
21
- (0, utils_1.invariant)(x.isFinite(), 'NumberFormatDigitInternalSlots value is not finite');
18
+ invariant(x.isFinite(), 'NumberFormatDigitInternalSlots value is not finite');
22
19
  if (x.lessThan(0)) {
23
20
  sign = 'negative';
24
21
  }
@@ -31,17 +28,17 @@ function FormatNumericToString(intlObject, _x) {
31
28
  }
32
29
  var result;
33
30
  var roundingType = intlObject.roundingType;
34
- var unsignedRoundingMode = (0, GetUnsignedRoundingMode_1.GetUnsignedRoundingMode)(intlObject.roundingMode, sign === 'negative');
31
+ var unsignedRoundingMode = GetUnsignedRoundingMode(intlObject.roundingMode, sign === 'negative');
35
32
  switch (roundingType) {
36
33
  case 'significantDigits':
37
- result = (0, ToRawPrecision_1.ToRawPrecision)(x, intlObject.minimumSignificantDigits, intlObject.maximumSignificantDigits, unsignedRoundingMode);
34
+ result = ToRawPrecision(x, intlObject.minimumSignificantDigits, intlObject.maximumSignificantDigits, unsignedRoundingMode);
38
35
  break;
39
36
  case 'fractionDigits':
40
- result = (0, ToRawFixed_1.ToRawFixed)(x, intlObject.minimumFractionDigits, intlObject.maximumFractionDigits, intlObject.roundingIncrement, unsignedRoundingMode);
37
+ result = ToRawFixed(x, intlObject.minimumFractionDigits, intlObject.maximumFractionDigits, intlObject.roundingIncrement, unsignedRoundingMode);
41
38
  break;
42
39
  default:
43
- var sResult = (0, ToRawPrecision_1.ToRawPrecision)(x, intlObject.minimumSignificantDigits, intlObject.maximumSignificantDigits, unsignedRoundingMode);
44
- var fResult = (0, ToRawFixed_1.ToRawFixed)(x, intlObject.minimumFractionDigits, intlObject.maximumFractionDigits, intlObject.roundingIncrement, unsignedRoundingMode);
40
+ var sResult = ToRawPrecision(x, intlObject.minimumSignificantDigits, intlObject.maximumSignificantDigits, unsignedRoundingMode);
41
+ var fResult = ToRawFixed(x, intlObject.minimumFractionDigits, intlObject.maximumFractionDigits, intlObject.roundingIncrement, unsignedRoundingMode);
45
42
  if (intlObject.roundingType === 'morePrecision') {
46
43
  if (sResult.roundingMagnitude <= fResult.roundingMagnitude) {
47
44
  result = sResult;
@@ -51,7 +48,7 @@ function FormatNumericToString(intlObject, _x) {
51
48
  }
52
49
  }
53
50
  else {
54
- (0, utils_1.invariant)(intlObject.roundingType === 'lessPrecision', 'Invalid roundingType');
51
+ invariant(intlObject.roundingType === 'lessPrecision', 'Invalid roundingType');
55
52
  if (sResult.roundingMagnitude <= fResult.roundingMagnitude) {
56
53
  result = fResult;
57
54
  }
@@ -72,12 +69,12 @@ function FormatNumericToString(intlObject, _x) {
72
69
  var int = result.integerDigitsCount;
73
70
  var minInteger = intlObject.minimumIntegerDigits;
74
71
  if (int < minInteger) {
75
- var forwardZeros = (0, utils_1.repeat)('0', minInteger - int);
72
+ var forwardZeros = repeat('0', minInteger - int);
76
73
  string = forwardZeros + string;
77
74
  }
78
75
  if (sign === 'negative') {
79
76
  if (x.isZero()) {
80
- x = constants_1.NEGATIVE_ZERO;
77
+ x = NEGATIVE_ZERO;
81
78
  }
82
79
  else {
83
80
  x = x.negated();
@@ -1,2 +1,2 @@
1
- import { RoundingModeType, UnsignedRoundingModeType } from '../types/number';
1
+ import { RoundingModeType, UnsignedRoundingModeType } from '../types/number.js';
2
2
  export declare function GetUnsignedRoundingMode(roundingMode: RoundingModeType, isNegative: boolean): UnsignedRoundingModeType;
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetUnsignedRoundingMode = GetUnsignedRoundingMode;
4
1
  var negativeMapping = {
5
2
  ceil: 'zero',
6
3
  floor: 'infinity',
@@ -23,7 +20,7 @@ var positiveMapping = {
23
20
  halfTrunc: 'half-zero',
24
21
  halfEven: 'half-even',
25
22
  };
26
- function GetUnsignedRoundingMode(roundingMode, isNegative) {
23
+ export function GetUnsignedRoundingMode(roundingMode, isNegative) {
27
24
  if (isNegative) {
28
25
  return negativeMapping[roundingMode];
29
26
  }
@@ -1,4 +1,4 @@
1
- import { NumberFormatInternal, NumberFormatLocaleInternalData, NumberFormatOptions } from '../types/number';
1
+ import { NumberFormatInternal, NumberFormatLocaleInternalData, NumberFormatOptions } from '../types/number.js';
2
2
  /**
3
3
  * https://tc39.es/ecma402/#sec-initializenumberformat
4
4
  */
@@ -1,26 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InitializeNumberFormat = InitializeNumberFormat;
4
- var intl_localematcher_1 = require("@formatjs/intl-localematcher");
5
- var CanonicalizeLocaleList_1 = require("../CanonicalizeLocaleList");
6
- var CoerceOptionsToObject_1 = require("../CoerceOptionsToObject");
7
- var GetOption_1 = require("../GetOption");
8
- var GetStringOrBooleanOption_1 = require("../GetStringOrBooleanOption");
9
- var utils_1 = require("../utils");
10
- var CurrencyDigits_1 = require("./CurrencyDigits");
11
- var SetNumberFormatDigitOptions_1 = require("./SetNumberFormatDigitOptions");
12
- var SetNumberFormatUnitOptions_1 = require("./SetNumberFormatUnitOptions");
1
+ import { ResolveLocale } from '@formatjs/intl-localematcher';
2
+ import { CanonicalizeLocaleList } from '../CanonicalizeLocaleList.js';
3
+ import { CoerceOptionsToObject } from '../CoerceOptionsToObject.js';
4
+ import { GetOption } from '../GetOption.js';
5
+ import { GetStringOrBooleanOption } from '../GetStringOrBooleanOption.js';
6
+ import { invariant } from '../utils.js';
7
+ import { CurrencyDigits } from './CurrencyDigits.js';
8
+ import { SetNumberFormatDigitOptions } from './SetNumberFormatDigitOptions.js';
9
+ import { SetNumberFormatUnitOptions } from './SetNumberFormatUnitOptions.js';
13
10
  /**
14
11
  * https://tc39.es/ecma402/#sec-initializenumberformat
15
12
  */
16
- function InitializeNumberFormat(nf, locales, opts, _a) {
13
+ export function InitializeNumberFormat(nf, locales, opts, _a) {
17
14
  var getInternalSlots = _a.getInternalSlots, localeData = _a.localeData, availableLocales = _a.availableLocales, numberingSystemNames = _a.numberingSystemNames, getDefaultLocale = _a.getDefaultLocale, currencyDigitsData = _a.currencyDigitsData;
18
- var requestedLocales = (0, CanonicalizeLocaleList_1.CanonicalizeLocaleList)(locales);
19
- var options = (0, CoerceOptionsToObject_1.CoerceOptionsToObject)(opts);
15
+ var requestedLocales = CanonicalizeLocaleList(locales);
16
+ var options = CoerceOptionsToObject(opts);
20
17
  var opt = Object.create(null);
21
- var matcher = (0, GetOption_1.GetOption)(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
18
+ var matcher = GetOption(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
22
19
  opt.localeMatcher = matcher;
23
- var numberingSystem = (0, GetOption_1.GetOption)(options, 'numberingSystem', 'string', undefined, undefined);
20
+ var numberingSystem = GetOption(options, 'numberingSystem', 'string', undefined, undefined);
24
21
  if (numberingSystem !== undefined &&
25
22
  numberingSystemNames.indexOf(numberingSystem) < 0) {
26
23
  // 8.a. If numberingSystem does not match the Unicode Locale Identifier type nonterminal,
@@ -28,25 +25,25 @@ function InitializeNumberFormat(nf, locales, opts, _a) {
28
25
  throw RangeError("Invalid numberingSystems: ".concat(numberingSystem));
29
26
  }
30
27
  opt.nu = numberingSystem;
31
- var r = (0, intl_localematcher_1.ResolveLocale)(Array.from(availableLocales), requestedLocales, opt,
28
+ var r = ResolveLocale(Array.from(availableLocales), requestedLocales, opt,
32
29
  // [[RelevantExtensionKeys]] slot, which is a constant
33
30
  ['nu'], localeData, getDefaultLocale);
34
31
  var dataLocaleData = localeData[r.dataLocale];
35
- (0, utils_1.invariant)(!!dataLocaleData, "Missing locale data for ".concat(r.dataLocale));
32
+ invariant(!!dataLocaleData, "Missing locale data for ".concat(r.dataLocale));
36
33
  var internalSlots = getInternalSlots(nf);
37
34
  internalSlots.locale = r.locale;
38
35
  internalSlots.dataLocale = r.dataLocale;
39
36
  internalSlots.numberingSystem = r.nu;
40
37
  internalSlots.dataLocaleData = dataLocaleData;
41
- (0, SetNumberFormatUnitOptions_1.SetNumberFormatUnitOptions)(internalSlots, options);
38
+ SetNumberFormatUnitOptions(internalSlots, options);
42
39
  var style = internalSlots.style;
43
- var notation = (0, GetOption_1.GetOption)(options, 'notation', 'string', ['standard', 'scientific', 'engineering', 'compact'], 'standard');
40
+ var notation = GetOption(options, 'notation', 'string', ['standard', 'scientific', 'engineering', 'compact'], 'standard');
44
41
  internalSlots.notation = notation;
45
42
  var mnfdDefault;
46
43
  var mxfdDefault;
47
44
  if (style === 'currency' && notation === 'standard') {
48
45
  var currency = internalSlots.currency;
49
- var cDigits = (0, CurrencyDigits_1.CurrencyDigits)(currency, { currencyDigitsData: currencyDigitsData });
46
+ var cDigits = CurrencyDigits(currency, { currencyDigitsData: currencyDigitsData });
50
47
  mnfdDefault = cDigits;
51
48
  mxfdDefault = cDigits;
52
49
  }
@@ -54,16 +51,16 @@ function InitializeNumberFormat(nf, locales, opts, _a) {
54
51
  mnfdDefault = 0;
55
52
  mxfdDefault = style === 'percent' ? 0 : 3;
56
53
  }
57
- (0, SetNumberFormatDigitOptions_1.SetNumberFormatDigitOptions)(internalSlots, options, mnfdDefault, mxfdDefault, notation);
58
- var compactDisplay = (0, GetOption_1.GetOption)(options, 'compactDisplay', 'string', ['short', 'long'], 'short');
54
+ SetNumberFormatDigitOptions(internalSlots, options, mnfdDefault, mxfdDefault, notation);
55
+ var compactDisplay = GetOption(options, 'compactDisplay', 'string', ['short', 'long'], 'short');
59
56
  var defaultUseGrouping = 'auto';
60
57
  if (notation === 'compact') {
61
58
  internalSlots.compactDisplay = compactDisplay;
62
59
  defaultUseGrouping = 'min2';
63
60
  }
64
- var useGrouping = (0, GetStringOrBooleanOption_1.GetStringOrBooleanOption)(options, 'useGrouping', ['min2', 'auto', 'always'], 'always', false, defaultUseGrouping);
61
+ var useGrouping = GetStringOrBooleanOption(options, 'useGrouping', ['min2', 'auto', 'always'], 'always', false, defaultUseGrouping);
65
62
  internalSlots.useGrouping = useGrouping;
66
- var signDisplay = (0, GetOption_1.GetOption)(options, 'signDisplay', 'string', ['auto', 'never', 'always', 'exceptZero', 'negative'], 'auto');
63
+ var signDisplay = GetOption(options, 'signDisplay', 'string', ['auto', 'never', 'always', 'exceptZero', 'negative'], 'auto');
67
64
  internalSlots.signDisplay = signDisplay;
68
65
  return nf;
69
66
  }
@@ -1,5 +1,5 @@
1
- import Decimal from 'decimal.js';
2
- import { NumberFormatInternal, NumberFormatPart } from '../types/number';
1
+ import { Decimal } from 'decimal.js';
2
+ import { NumberFormatInternal, NumberFormatPart } from '../types/number.js';
3
3
  /**
4
4
  * https://tc39.es/ecma402/#sec-partitionnumberpattern
5
5
  */
@@ -1,16 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PartitionNumberPattern = PartitionNumberPattern;
4
- var tslib_1 = require("tslib");
5
- var decimal_js_1 = tslib_1.__importDefault(require("decimal.js"));
6
- var utils_1 = require("../utils");
7
- var ComputeExponent_1 = require("./ComputeExponent");
8
- var format_to_parts_1 = tslib_1.__importDefault(require("./format_to_parts"));
9
- var FormatNumericToString_1 = require("./FormatNumericToString");
1
+ import { Decimal } from 'decimal.js';
2
+ import { invariant } from '../utils.js';
3
+ import { ComputeExponent } from './ComputeExponent.js';
4
+ import formatToParts from './format_to_parts.js';
5
+ import { FormatNumericToString } from './FormatNumericToString.js';
10
6
  /**
11
7
  * https://tc39.es/ecma402/#sec-partitionnumberpattern
12
8
  */
13
- function PartitionNumberPattern(internalSlots, _x) {
9
+ export function PartitionNumberPattern(internalSlots, _x) {
14
10
  var _a;
15
11
  var x = _x;
16
12
  // IMPL: We need to record the magnitude of the number
@@ -38,21 +34,21 @@ function PartitionNumberPattern(internalSlots, _x) {
38
34
  // 8. Else,
39
35
  if (!x.isZero()) {
40
36
  // 8.a. If x < 0, let x be -x.
41
- (0, utils_1.invariant)(x.isFinite(), 'Input must be a mathematical value');
37
+ invariant(x.isFinite(), 'Input must be a mathematical value');
42
38
  // 8.b. If internalSlots.[[style]] is "percent", let x be 100 × x.
43
39
  if (internalSlots.style == 'percent') {
44
40
  x = x.times(100);
45
41
  }
46
42
  // 8.c. Let exponent be ComputeExponent(numberFormat, x).
47
43
  ;
48
- _a = (0, ComputeExponent_1.ComputeExponent)(internalSlots, x), exponent = _a[0],
44
+ _a = ComputeExponent(internalSlots, x), exponent = _a[0],
49
45
  // IMPL: We need to record the magnitude of the number
50
46
  magnitude = _a[1];
51
47
  // 8.d. Let x be x × 10^(-exponent).
52
- x = x.times(decimal_js_1.default.pow(10, -exponent));
48
+ x = x.times(Decimal.pow(10, -exponent));
53
49
  }
54
50
  // 8.e. Let formatNumberResult be FormatNumericToString(internalSlots, x).
55
- var formatNumberResult = (0, FormatNumericToString_1.FormatNumericToString)(internalSlots, x);
51
+ var formatNumberResult = FormatNumericToString(internalSlots, x);
56
52
  // 8.f. Let n be formatNumberResult.[[formattedString]].
57
53
  n = formatNumberResult.formattedString;
58
54
  // 8.g. Let x be formatNumberResult.[[roundedNumber]].
@@ -107,7 +103,7 @@ function PartitionNumberPattern(internalSlots, _x) {
107
103
  break;
108
104
  default:
109
105
  // 10.e. Else,
110
- (0, utils_1.invariant)(signDisplay === 'negative', 'signDisplay must be "negative"');
106
+ invariant(signDisplay === 'negative', 'signDisplay must be "negative"');
111
107
  if (x.isNegative() && !x.isZero()) {
112
108
  // 10.e.i. If x is negative and x is not 0, let sign be -1.
113
109
  sign = -1;
@@ -119,7 +115,7 @@ function PartitionNumberPattern(internalSlots, _x) {
119
115
  break;
120
116
  }
121
117
  // 11. Return ? FormatNumberToParts(numberFormat, x, n, exponent, sign).
122
- return (0, format_to_parts_1.default)({
118
+ return formatToParts({
123
119
  roundedNumber: x,
124
120
  formattedString: n,
125
121
  exponent: exponent,
@@ -1,5 +1,5 @@
1
- import Decimal from 'decimal.js';
2
- import { NumberFormatInternal, NumberFormatPart } from '../types/number';
1
+ import { Decimal } from 'decimal.js';
2
+ import { NumberFormatInternal, NumberFormatPart } from '../types/number.js';
3
3
  /**
4
4
  * https://tc39.es/ecma402/#sec-partitionnumberrangepattern
5
5
  */
@@ -1,25 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PartitionNumberRangePattern = PartitionNumberRangePattern;
4
- var utils_1 = require("../utils");
5
- var CollapseNumberRange_1 = require("./CollapseNumberRange");
6
- var FormatApproximately_1 = require("./FormatApproximately");
7
- var FormatNumeric_1 = require("./FormatNumeric");
8
- var PartitionNumberPattern_1 = require("./PartitionNumberPattern");
1
+ import { invariant } from '../utils.js';
2
+ import { CollapseNumberRange } from './CollapseNumberRange.js';
3
+ import { FormatApproximately } from './FormatApproximately.js';
4
+ import { FormatNumeric } from './FormatNumeric.js';
5
+ import { PartitionNumberPattern } from './PartitionNumberPattern.js';
9
6
  /**
10
7
  * https://tc39.es/ecma402/#sec-partitionnumberrangepattern
11
8
  */
12
- function PartitionNumberRangePattern(numberFormat, x, y, _a) {
9
+ export function PartitionNumberRangePattern(numberFormat, x, y, _a) {
13
10
  var getInternalSlots = _a.getInternalSlots;
14
11
  // 1. Assert: x and y are both mathematical values.
15
- (0, utils_1.invariant)(!x.isNaN() && !y.isNaN(), 'Input must be a number', RangeError);
12
+ invariant(!x.isNaN() && !y.isNaN(), 'Input must be a number', RangeError);
16
13
  var internalSlots = getInternalSlots(numberFormat);
17
14
  // 3. Let xResult be ? PartitionNumberPattern(numberFormat, x).
18
- var xResult = (0, PartitionNumberPattern_1.PartitionNumberPattern)(internalSlots, x);
15
+ var xResult = PartitionNumberPattern(internalSlots, x);
19
16
  // 4. Let yResult be ? PartitionNumberPattern(numberFormat, y).
20
- var yResult = (0, PartitionNumberPattern_1.PartitionNumberPattern)(internalSlots, y);
21
- if ((0, FormatNumeric_1.FormatNumeric)(internalSlots, x) === (0, FormatNumeric_1.FormatNumeric)(internalSlots, y)) {
22
- var appxResult = (0, FormatApproximately_1.FormatApproximately)(internalSlots, xResult);
17
+ var yResult = PartitionNumberPattern(internalSlots, y);
18
+ if (FormatNumeric(internalSlots, x) === FormatNumeric(internalSlots, y)) {
19
+ var appxResult = FormatApproximately(internalSlots, xResult);
23
20
  appxResult.forEach(function (el) {
24
21
  el.source = 'shared';
25
22
  });
@@ -39,5 +36,5 @@ function PartitionNumberRangePattern(numberFormat, x, y, _a) {
39
36
  result.push(el);
40
37
  });
41
38
  // 13. Return ? CollapseNumberRange(numberFormat, result).
42
- return (0, CollapseNumberRange_1.CollapseNumberRange)(numberFormat, result, { getInternalSlots: getInternalSlots });
39
+ return CollapseNumberRange(numberFormat, result, { getInternalSlots: getInternalSlots });
43
40
  }
@@ -1,4 +1,4 @@
1
- import { NumberFormatDigitInternalSlots, NumberFormatDigitOptions, NumberFormatNotation } from '../types/number';
1
+ import { NumberFormatDigitInternalSlots, NumberFormatDigitOptions, NumberFormatNotation } from '../types/number.js';
2
2
  /**
3
3
  * https://tc39.es/ecma402/#sec-setnfdigitoptions
4
4
  */