@formatjs/ecma402-abstract 1.11.10 → 1.13.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 (69) hide show
  1. package/GetStringOrBooleanOption.d.ts +11 -0
  2. package/GetStringOrBooleanOption.d.ts.map +1 -0
  3. package/GetStringOrBooleanOption.js +35 -0
  4. package/NumberFormat/ApplyUnsignedRoundingMode.d.ts +3 -0
  5. package/NumberFormat/ApplyUnsignedRoundingMode.d.ts.map +1 -0
  6. package/NumberFormat/ApplyUnsignedRoundingMode.js +42 -0
  7. package/NumberFormat/CollapseNumberRange.d.ts +5 -0
  8. package/NumberFormat/CollapseNumberRange.d.ts.map +1 -0
  9. package/NumberFormat/CollapseNumberRange.js +10 -0
  10. package/NumberFormat/FormatApproximately.d.ts +8 -0
  11. package/NumberFormat/FormatApproximately.d.ts.map +1 -0
  12. package/NumberFormat/FormatApproximately.js +15 -0
  13. package/NumberFormat/GetUnsignedRoundingMode.d.ts +3 -0
  14. package/NumberFormat/GetUnsignedRoundingMode.d.ts.map +1 -0
  15. package/NumberFormat/GetUnsignedRoundingMode.js +32 -0
  16. package/NumberFormat/InitializeNumberFormat.d.ts.map +1 -1
  17. package/NumberFormat/InitializeNumberFormat.js +35 -4
  18. package/NumberFormat/PartitionNumberPattern.d.ts.map +1 -1
  19. package/NumberFormat/PartitionNumberPattern.js +14 -9
  20. package/NumberFormat/PartitionNumberRangePattern.d.ts +8 -0
  21. package/NumberFormat/PartitionNumberRangePattern.d.ts.map +1 -0
  22. package/NumberFormat/PartitionNumberRangePattern.js +62 -0
  23. package/NumberFormat/SetNumberFormatDigitOptions.d.ts.map +1 -1
  24. package/NumberFormat/SetNumberFormatDigitOptions.js +63 -18
  25. package/NumberFormat/format_to_parts.d.ts +2 -2
  26. package/NumberFormat/format_to_parts.d.ts.map +1 -1
  27. package/NumberFormat/format_to_parts.js +1 -1
  28. package/index.d.ts +6 -0
  29. package/index.d.ts.map +1 -1
  30. package/index.js +6 -0
  31. package/lib/GetStringOrBooleanOption.d.ts +11 -0
  32. package/lib/GetStringOrBooleanOption.d.ts.map +1 -0
  33. package/lib/GetStringOrBooleanOption.js +31 -0
  34. package/lib/NumberFormat/ApplyUnsignedRoundingMode.d.ts +3 -0
  35. package/lib/NumberFormat/ApplyUnsignedRoundingMode.d.ts.map +1 -0
  36. package/lib/NumberFormat/ApplyUnsignedRoundingMode.js +38 -0
  37. package/lib/NumberFormat/CollapseNumberRange.d.ts +5 -0
  38. package/lib/NumberFormat/CollapseNumberRange.d.ts.map +1 -0
  39. package/lib/NumberFormat/CollapseNumberRange.js +6 -0
  40. package/lib/NumberFormat/FormatApproximately.d.ts +8 -0
  41. package/lib/NumberFormat/FormatApproximately.d.ts.map +1 -0
  42. package/lib/NumberFormat/FormatApproximately.js +11 -0
  43. package/lib/NumberFormat/GetUnsignedRoundingMode.d.ts +3 -0
  44. package/lib/NumberFormat/GetUnsignedRoundingMode.d.ts.map +1 -0
  45. package/lib/NumberFormat/GetUnsignedRoundingMode.js +28 -0
  46. package/lib/NumberFormat/InitializeNumberFormat.d.ts.map +1 -1
  47. package/lib/NumberFormat/InitializeNumberFormat.js +35 -4
  48. package/lib/NumberFormat/PartitionNumberPattern.d.ts.map +1 -1
  49. package/lib/NumberFormat/PartitionNumberPattern.js +14 -9
  50. package/lib/NumberFormat/PartitionNumberRangePattern.d.ts +8 -0
  51. package/lib/NumberFormat/PartitionNumberRangePattern.d.ts.map +1 -0
  52. package/lib/NumberFormat/PartitionNumberRangePattern.js +58 -0
  53. package/lib/NumberFormat/SetNumberFormatDigitOptions.d.ts.map +1 -1
  54. package/lib/NumberFormat/SetNumberFormatDigitOptions.js +63 -18
  55. package/lib/NumberFormat/format_to_parts.d.ts +2 -2
  56. package/lib/NumberFormat/format_to_parts.d.ts.map +1 -1
  57. package/lib/NumberFormat/format_to_parts.js +1 -1
  58. package/lib/index.d.ts +6 -0
  59. package/lib/index.d.ts.map +1 -1
  60. package/lib/index.js +6 -0
  61. package/lib/types/date-time.d.ts +5 -4
  62. package/lib/types/date-time.d.ts.map +1 -1
  63. package/lib/types/number.d.ts +21 -7
  64. package/lib/types/number.d.ts.map +1 -1
  65. package/package.json +2 -2
  66. package/types/date-time.d.ts +5 -4
  67. package/types/date-time.d.ts.map +1 -1
  68. package/types/number.d.ts +21 -7
  69. package/types/number.d.ts.map +1 -1
@@ -0,0 +1,11 @@
1
+ /**
2
+ * https://tc39.es/ecma402/#sec-getstringorbooleanoption
3
+ * @param opts
4
+ * @param prop
5
+ * @param values
6
+ * @param trueValue
7
+ * @param falsyValue
8
+ * @param fallback
9
+ */
10
+ export declare function GetStringOrBooleanOption<T extends object, K extends keyof T>(opts: T, prop: K, values: T[K][] | undefined, trueValue: T[K] | boolean, falsyValue: T[K] | boolean, fallback: T[K] | boolean): T[K] | boolean;
11
+ //# sourceMappingURL=GetStringOrBooleanOption.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GetStringOrBooleanOption.d.ts","sourceRoot":"","sources":["GetStringOrBooleanOption.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAC1E,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,EAC1B,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,EACzB,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,EAC1B,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,GACvB,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAyBhB"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /**
3
+ * https://tc39.es/ecma402/#sec-getstringorbooleanoption
4
+ * @param opts
5
+ * @param prop
6
+ * @param values
7
+ * @param trueValue
8
+ * @param falsyValue
9
+ * @param fallback
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.GetStringOrBooleanOption = void 0;
13
+ var _262_1 = require("./262");
14
+ function GetStringOrBooleanOption(opts, prop, values, trueValue, falsyValue, fallback) {
15
+ var value = opts[prop];
16
+ if (value === undefined) {
17
+ return fallback;
18
+ }
19
+ if (value === true) {
20
+ return trueValue;
21
+ }
22
+ var valueBoolean = Boolean(value);
23
+ if (valueBoolean === false) {
24
+ return falsyValue;
25
+ }
26
+ value = (0, _262_1.ToString)(value);
27
+ if (value === 'true' || value === 'false') {
28
+ return fallback;
29
+ }
30
+ if ((values || []).indexOf(value) === -1) {
31
+ throw new RangeError("Invalid value ".concat(value));
32
+ }
33
+ return value;
34
+ }
35
+ exports.GetStringOrBooleanOption = GetStringOrBooleanOption;
@@ -0,0 +1,3 @@
1
+ import { UnsignedRoundingModeType } from '../types/number';
2
+ export declare function ApplyUnsignedRoundingMode(x: number, r1: number, r2: number, unsignedRoundingMode: UnsignedRoundingModeType): number;
3
+ //# sourceMappingURL=ApplyUnsignedRoundingMode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApplyUnsignedRoundingMode.d.ts","sourceRoot":"","sources":["ApplyUnsignedRoundingMode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,wBAAwB,EAAC,MAAM,iBAAiB,CAAA;AAExD,wBAAgB,yBAAyB,CACvC,CAAC,EAAE,MAAM,EACT,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,oBAAoB,EAAE,wBAAwB,GAC7C,MAAM,CA8CR"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApplyUnsignedRoundingMode = void 0;
4
+ function ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode) {
5
+ if (x === r1)
6
+ return r1;
7
+ if (unsignedRoundingMode === undefined) {
8
+ throw new Error('unsignedRoundingMode is mandatory');
9
+ }
10
+ if (unsignedRoundingMode === 'zero') {
11
+ return r1;
12
+ }
13
+ if (unsignedRoundingMode === 'infinity') {
14
+ return r2;
15
+ }
16
+ var d1 = x - r1;
17
+ var d2 = r2 - x;
18
+ if (d1 < d2) {
19
+ return r1;
20
+ }
21
+ if (d2 < d1) {
22
+ return r2;
23
+ }
24
+ if (d1 !== d2) {
25
+ throw new Error('Unexpected error');
26
+ }
27
+ if (unsignedRoundingMode === 'half-zero') {
28
+ return r1;
29
+ }
30
+ if (unsignedRoundingMode === 'half-infinity') {
31
+ return r2;
32
+ }
33
+ if (unsignedRoundingMode !== 'half-even') {
34
+ throw new Error("Unexpected value for unsignedRoundingMode: ".concat(unsignedRoundingMode));
35
+ }
36
+ var cardinality = (r1 / (r2 - r1)) % 2;
37
+ if (cardinality === 0) {
38
+ return r1;
39
+ }
40
+ return r2;
41
+ }
42
+ exports.ApplyUnsignedRoundingMode = ApplyUnsignedRoundingMode;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * https://tc39.es/ecma402/#sec-collapsenumberrange
3
+ */
4
+ export declare function CollapseNumberRange<T>(result: T): T;
5
+ //# sourceMappingURL=CollapseNumberRange.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CollapseNumberRange.d.ts","sourceRoot":"","sources":["CollapseNumberRange.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,KAE/C"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CollapseNumberRange = void 0;
4
+ /**
5
+ * https://tc39.es/ecma402/#sec-collapsenumberrange
6
+ */
7
+ function CollapseNumberRange(result) {
8
+ return result;
9
+ }
10
+ exports.CollapseNumberRange = CollapseNumberRange;
@@ -0,0 +1,8 @@
1
+ import { NumberFormatInternal, NumberFormatPart } from '../types/number';
2
+ /**
3
+ * https://tc39.es/ecma402/#sec-formatapproximately
4
+ */
5
+ export declare function FormatApproximately(numberFormat: Intl.NumberFormat, result: NumberFormatPart[], { getInternalSlots, }: {
6
+ getInternalSlots(nf: Intl.NumberFormat): NumberFormatInternal;
7
+ }): NumberFormatPart[];
8
+ //# sourceMappingURL=FormatApproximately.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormatApproximately.d.ts","sourceRoot":"","sources":["FormatApproximately.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAE,gBAAgB,EAAC,MAAM,iBAAiB,CAAA;AAEtE;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,MAAM,EAAE,gBAAgB,EAAE,EAC1B,EACE,gBAAgB,GACjB,EAAE;IACD,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAA;CAC9D,sBAWF"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FormatApproximately = void 0;
4
+ /**
5
+ * https://tc39.es/ecma402/#sec-formatapproximately
6
+ */
7
+ function FormatApproximately(numberFormat, result, _a) {
8
+ var getInternalSlots = _a.getInternalSlots;
9
+ var internalSlots = getInternalSlots(numberFormat);
10
+ var symbols = internalSlots.dataLocaleData.numbers.symbols[internalSlots.numberingSystem];
11
+ var approximatelySign = symbols.approximatelySign;
12
+ result.push({ type: 'approximatelySign', value: approximatelySign });
13
+ return result;
14
+ }
15
+ exports.FormatApproximately = FormatApproximately;
@@ -0,0 +1,3 @@
1
+ import { RoundingModeType, UnsignedRoundingModeType } from '../types/number';
2
+ export declare function GetUnsignedRoundingMode(roundingMode: RoundingModeType, isNegative: boolean): UnsignedRoundingModeType;
3
+ //# sourceMappingURL=GetUnsignedRoundingMode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GetUnsignedRoundingMode.d.ts","sourceRoot":"","sources":["GetUnsignedRoundingMode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,wBAAwB,EAAC,MAAM,iBAAiB,CAAA;AA0B1E,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,gBAAgB,EAC9B,UAAU,EAAE,OAAO,GAClB,wBAAwB,CAK1B"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetUnsignedRoundingMode = void 0;
4
+ var negativeMapping = {
5
+ ceil: 'zero',
6
+ floor: 'infinity',
7
+ expand: 'infinity',
8
+ trunc: 'zero',
9
+ halfCeil: 'half-zero',
10
+ halfFloor: 'half-infinity',
11
+ halfExpand: 'half-infinity',
12
+ halfTrunc: 'half-zero',
13
+ halfEven: 'half-even',
14
+ };
15
+ var positiveMapping = {
16
+ ceil: 'infinity',
17
+ floor: 'zero',
18
+ expand: 'infinity',
19
+ trunc: 'zero',
20
+ halfCeil: 'half-infinity',
21
+ halfFloor: 'half-zero',
22
+ halfExpand: 'half-infinity',
23
+ halfTrunc: 'half-zero',
24
+ halfEven: 'half-even',
25
+ };
26
+ function GetUnsignedRoundingMode(roundingMode, isNegative) {
27
+ if (isNegative) {
28
+ return negativeMapping[roundingMode];
29
+ }
30
+ return positiveMapping[roundingMode];
31
+ }
32
+ exports.GetUnsignedRoundingMode = GetUnsignedRoundingMode;
@@ -1 +1 @@
1
- {"version":3,"file":"InitializeNumberFormat.d.ts","sourceRoot":"","sources":["InitializeNumberFormat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,8BAA8B,EAC/B,MAAM,iBAAiB,CAAA;AAUxB;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,IAAI,CAAC,YAAY,EACrB,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,EACnD,IAAI,EAAE,mBAAmB,GAAG,SAAS,EACrC,EACE,gBAAgB,EAChB,UAAU,EACV,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
@@ -9,6 +9,11 @@ var CurrencyDigits_1 = require("./CurrencyDigits");
9
9
  var SetNumberFormatDigitOptions_1 = require("./SetNumberFormatDigitOptions");
10
10
  var utils_1 = require("../utils");
11
11
  var CoerceOptionsToObject_1 = require("../CoerceOptionsToObject");
12
+ var GetNumberOption_1 = require("../GetNumberOption");
13
+ var GetStringOrBooleanOption_1 = require("../GetStringOrBooleanOption");
14
+ var VALID_ROUND_INCREMENT_VALUES = [
15
+ 1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000,
16
+ ];
12
17
  /**
13
18
  * https://tc39.es/ecma402/#sec-initializenumberformat
14
19
  */
@@ -55,14 +60,40 @@ function InitializeNumberFormat(nf, locales, opts, _a) {
55
60
  var notation = (0, GetOption_1.GetOption)(options, 'notation', 'string', ['standard', 'scientific', 'engineering', 'compact'], 'standard');
56
61
  internalSlots.notation = notation;
57
62
  (0, SetNumberFormatDigitOptions_1.SetNumberFormatDigitOptions)(internalSlots, options, mnfdDefault, mxfdDefault, notation);
63
+ var roundingIncrement = (0, GetNumberOption_1.GetNumberOption)(options, 'roundingIncrement', 1, 5000, 1);
64
+ if (VALID_ROUND_INCREMENT_VALUES.indexOf(roundingIncrement) === -1) {
65
+ throw new RangeError("Invalid rounding increment value: ".concat(roundingIncrement, ".\nValid values are ").concat(VALID_ROUND_INCREMENT_VALUES, "."));
66
+ }
67
+ if (roundingIncrement !== 1 &&
68
+ internalSlots.roundingType !== 'fractionDigits') {
69
+ throw new TypeError("For roundingIncrement > 1 only fractionDigits is a valid roundingType");
70
+ }
71
+ if (roundingIncrement !== 1 &&
72
+ internalSlots.maximumFractionDigits !== internalSlots.minimumFractionDigits) {
73
+ throw new RangeError('With roundingIncrement > 1, maximumFractionDigits and minimumFractionDigits must be equal.');
74
+ }
75
+ internalSlots.roundingIncrement = roundingIncrement;
76
+ var trailingZeroDisplay = (0, GetOption_1.GetOption)(options, 'trailingZeroDisplay', 'string', ['auto', 'stripIfInteger'], 'auto');
77
+ internalSlots.trailingZeroDisplay = trailingZeroDisplay;
58
78
  var compactDisplay = (0, GetOption_1.GetOption)(options, 'compactDisplay', 'string', ['short', 'long'], 'short');
79
+ var defaultUseGrouping = 'auto';
59
80
  if (notation === 'compact') {
60
81
  internalSlots.compactDisplay = compactDisplay;
82
+ defaultUseGrouping = 'min2';
61
83
  }
62
- var useGrouping = (0, GetOption_1.GetOption)(options, 'useGrouping', 'boolean', undefined, true);
63
- internalSlots.useGrouping = useGrouping;
64
- var signDisplay = (0, GetOption_1.GetOption)(options, 'signDisplay', 'string', ['auto', 'never', 'always', 'exceptZero'], 'auto');
65
- internalSlots.signDisplay = signDisplay;
84
+ internalSlots.useGrouping = (0, GetStringOrBooleanOption_1.GetStringOrBooleanOption)(options, 'useGrouping', ['min2', 'auto', 'always'], 'always', false, defaultUseGrouping);
85
+ internalSlots.signDisplay = (0, GetOption_1.GetOption)(options, 'signDisplay', 'string', ['auto', 'never', 'always', 'exceptZero', 'negative'], 'auto');
86
+ internalSlots.roundingMode = (0, GetOption_1.GetOption)(options, 'roundingMode', 'string', [
87
+ 'ceil',
88
+ 'floor',
89
+ 'expand',
90
+ 'trunc',
91
+ 'halfCeil',
92
+ 'halfFloor',
93
+ 'halfExpand',
94
+ 'halfTrunc',
95
+ 'halfEven',
96
+ ], 'halfExpand');
66
97
  return nf;
67
98
  }
68
99
  exports.InitializeNumberFormat = InitializeNumberFormat;
@@ -1 +1 @@
1
- {"version":3,"file":"PartitionNumberPattern.d.ts","sourceRoot":"","sources":["PartitionNumberPattern.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,iBAAiB,CAAA;AAMpD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,CAAC,EAAE,MAAM,EACT,EACE,gBAAgB,GACjB,EAAE;IACD,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAA;CAC9D,gDAqEF"}
1
+ {"version":3,"file":"PartitionNumberPattern.d.ts","sourceRoot":"","sources":["PartitionNumberPattern.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,iBAAiB,CAAA;AAMpD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,CAAC,EAAE,MAAM,EACT,EACE,gBAAgB,GACjB,EAAE;IACD,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAA;CAC9D,gDA0EF"}
@@ -22,19 +22,24 @@ function PartitionNumberPattern(numberFormat, x, _a) {
22
22
  if (isNaN(x)) {
23
23
  n = symbols.nan;
24
24
  }
25
- else if (!isFinite(x)) {
25
+ else if (x == Number.POSITIVE_INFINITY || x == Number.NEGATIVE_INFINITY) {
26
26
  n = symbols.infinity;
27
27
  }
28
28
  else {
29
- if (internalSlots.style === 'percent') {
30
- x *= 100;
29
+ if (!(0, _262_1.SameValue)(x, -0)) {
30
+ if (!isFinite(x)) {
31
+ throw new Error('Input must be a mathematical value');
32
+ }
33
+ if (internalSlots.style == 'percent') {
34
+ x *= 100;
35
+ }
36
+ ;
37
+ _b = (0, ComputeExponent_1.ComputeExponent)(numberFormat, x, {
38
+ getInternalSlots: getInternalSlots,
39
+ }), exponent = _b[0], magnitude = _b[1];
40
+ // Preserve more precision by doing multiplication when exponent is negative.
41
+ x = exponent < 0 ? x * Math.pow(10, -exponent) : x / Math.pow(10, exponent);
31
42
  }
32
- ;
33
- _b = (0, ComputeExponent_1.ComputeExponent)(numberFormat, x, {
34
- getInternalSlots: getInternalSlots,
35
- }), exponent = _b[0], magnitude = _b[1];
36
- // Preserve more precision by doing multiplication when exponent is negative.
37
- x = exponent < 0 ? x * Math.pow(10, -exponent) : x / Math.pow(10, exponent);
38
43
  var formatNumberResult = (0, FormatNumericToString_1.FormatNumericToString)(internalSlots, x);
39
44
  n = formatNumberResult.formattedString;
40
45
  x = formatNumberResult.roundedNumber;
@@ -0,0 +1,8 @@
1
+ import { NumberFormatInternal, NumberFormatPart } from '../types/number';
2
+ /**
3
+ * https://tc39.es/ecma402/#sec-partitionnumberrangepattern
4
+ */
5
+ export declare function PartitionNumberRangePattern(numberFormat: Intl.NumberFormat, x: number, y: number, { getInternalSlots, }: {
6
+ getInternalSlots(nf: Intl.NumberFormat): NumberFormatInternal;
7
+ }): NumberFormatPart[];
8
+ //# sourceMappingURL=PartitionNumberRangePattern.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PartitionNumberRangePattern.d.ts","sourceRoot":"","sources":["PartitionNumberRangePattern.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAE,gBAAgB,EAAC,MAAM,iBAAiB,CAAA;AAMtE;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,EACE,gBAAgB,GACjB,EAAE;IACD,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAA;CAC9D,sBAqDF"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PartitionNumberRangePattern = void 0;
4
+ var _262_1 = require("../262");
5
+ var PartitionNumberPattern_1 = require("./PartitionNumberPattern");
6
+ var CollapseNumberRange_1 = require("./CollapseNumberRange");
7
+ var FormatApproximately_1 = require("./FormatApproximately");
8
+ /**
9
+ * https://tc39.es/ecma402/#sec-partitionnumberrangepattern
10
+ */
11
+ function PartitionNumberRangePattern(numberFormat, x, y, _a) {
12
+ var getInternalSlots = _a.getInternalSlots;
13
+ var internalSlots = getInternalSlots(numberFormat);
14
+ if (isNaN(x) || isNaN(y)) {
15
+ throw new RangeError('Input must be a number');
16
+ }
17
+ if (isFinite(x)) {
18
+ if (isFinite(y) && y < x) {
19
+ throw new RangeError('Y input must be bigger than X');
20
+ }
21
+ else if (y == Number.NEGATIVE_INFINITY) {
22
+ throw new RangeError('Y input must not be NegativeInfinity');
23
+ }
24
+ else if ((0, _262_1.SameValue)(y, -0) && x >= 0) {
25
+ throw new RangeError('Y input must be bigger than X');
26
+ }
27
+ }
28
+ else if (x == Number.POSITIVE_INFINITY) {
29
+ if (isFinite(y) || y == Number.NEGATIVE_INFINITY || (0, _262_1.SameValue)(y, -0)) {
30
+ throw new RangeError('Y input must be bigger than X');
31
+ }
32
+ }
33
+ else if ((0, _262_1.SameValue)(x, -0)) {
34
+ if (isFinite(y) && y < 0) {
35
+ throw new RangeError('Y input must be bigger than X');
36
+ }
37
+ else if (y == Number.NEGATIVE_INFINITY) {
38
+ throw new RangeError('Y input must be bigger than X');
39
+ }
40
+ }
41
+ var result = [];
42
+ var xResult = (0, PartitionNumberPattern_1.PartitionNumberPattern)(numberFormat, x, { getInternalSlots: getInternalSlots });
43
+ var yResult = (0, PartitionNumberPattern_1.PartitionNumberPattern)(numberFormat, y, { getInternalSlots: getInternalSlots });
44
+ if (xResult === yResult) {
45
+ return (0, FormatApproximately_1.FormatApproximately)(numberFormat, xResult, { getInternalSlots: getInternalSlots });
46
+ }
47
+ for (var _i = 0, xResult_1 = xResult; _i < xResult_1.length; _i++) {
48
+ var r = xResult_1[_i];
49
+ r.source = 'startRange';
50
+ }
51
+ result = result.concat(xResult);
52
+ var symbols = internalSlots.dataLocaleData.numbers.symbols[internalSlots.numberingSystem];
53
+ var rangeSeparator = symbols.timeSeparator;
54
+ result.push({ type: 'literal', value: rangeSeparator, source: 'shared' });
55
+ for (var _b = 0, yResult_1 = yResult; _b < yResult_1.length; _b++) {
56
+ var r = yResult_1[_b];
57
+ r.source = 'endRange';
58
+ }
59
+ result = result.concat(yResult);
60
+ return (0, CollapseNumberRange_1.CollapseNumberRange)(result);
61
+ }
62
+ exports.PartitionNumberRangePattern = PartitionNumberRangePattern;
@@ -1 +1 @@
1
- {"version":3,"file":"SetNumberFormatDigitOptions.d.ts","sourceRoot":"","sources":["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
+ {"version":3,"file":"SetNumberFormatDigitOptions.d.ts","sourceRoot":"","sources":["SetNumberFormatDigitOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,8BAA8B,EAC/B,MAAM,iBAAiB,CAAA;AAKxB;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,8BAA8B,EAC7C,IAAI,EAAE,wBAAwB,EAC9B,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,oBAAoB,QA2E/B"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SetNumberFormatDigitOptions = void 0;
4
4
  var GetNumberOption_1 = require("../GetNumberOption");
5
5
  var DefaultNumberOption_1 = require("../DefaultNumberOption");
6
+ var GetOption_1 = require("../GetOption");
6
7
  /**
7
8
  * https://tc39.es/ecma402/#sec-setnfdigitoptions
8
9
  */
@@ -13,28 +14,72 @@ function SetNumberFormatDigitOptions(internalSlots, opts, mnfdDefault, mxfdDefau
13
14
  var mnsd = opts.minimumSignificantDigits;
14
15
  var mxsd = opts.maximumSignificantDigits;
15
16
  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;
17
+ var roundingPriority = (0, GetOption_1.GetOption)(opts, 'roundingPriority', 'string', ['auto', 'morePrecision', 'lessPrecision'], 'auto');
18
+ var hasSd = mnsd !== undefined || mxsd !== undefined;
19
+ var hasFd = mnfd !== undefined || mxfd !== undefined;
20
+ var needSd = true;
21
+ var needFd = true;
22
+ if (roundingPriority === 'auto') {
23
+ needSd = hasSd;
24
+ if (hasSd || (!hasFd && notation === 'compact')) {
25
+ needFd = false;
26
+ }
22
27
  }
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;
28
+ if (needSd) {
29
+ if (hasSd) {
30
+ mnsd = (0, DefaultNumberOption_1.DefaultNumberOption)(mnsd, 1, 21, 1);
31
+ mxsd = (0, DefaultNumberOption_1.DefaultNumberOption)(mxsd, mnsd, 21, 21);
32
+ internalSlots.minimumSignificantDigits = mnsd;
33
+ internalSlots.maximumSignificantDigits = mxsd;
34
+ }
35
+ else {
36
+ internalSlots.minimumSignificantDigits = 1;
37
+ internalSlots.maximumSignificantDigits = 21;
38
+ }
30
39
  }
31
- else if (notation === 'compact') {
32
- internalSlots.roundingType = 'compactRounding';
40
+ if (needFd) {
41
+ if (hasFd) {
42
+ // @ts-expect-error
43
+ mnfd = (0, DefaultNumberOption_1.DefaultNumberOption)(mnfd, 0, 20, undefined);
44
+ // @ts-expect-error
45
+ mxfd = (0, DefaultNumberOption_1.DefaultNumberOption)(mxfd, 0, 20, undefined);
46
+ if (mnfd === undefined) {
47
+ mnfd = Math.min(mnfdDefault, mxfd);
48
+ }
49
+ else if (mxfd === undefined) {
50
+ mxfd = Math.max(mxfdDefault, mnfd);
51
+ }
52
+ else if (mnfd > mxfd) {
53
+ throw new RangeError("Invalid range, ".concat(mnfd, " > ").concat(mxfd));
54
+ }
55
+ internalSlots.minimumFractionDigits = mnfd;
56
+ internalSlots.maximumFractionDigits = mxfd;
57
+ }
58
+ else {
59
+ internalSlots.minimumFractionDigits = mnfdDefault;
60
+ internalSlots.maximumFractionDigits = mxfdDefault;
61
+ }
62
+ }
63
+ if (needSd || needFd) {
64
+ if (roundingPriority === 'morePrecision') {
65
+ internalSlots.roundingType = 'morePrecision';
66
+ }
67
+ else if (roundingPriority === 'lessPrecision') {
68
+ internalSlots.roundingType = 'lessPrecision';
69
+ }
70
+ else if (hasSd) {
71
+ internalSlots.roundingType = 'significantDigits';
72
+ }
73
+ else {
74
+ internalSlots.roundingType = 'fractionDigits';
75
+ }
33
76
  }
34
77
  else {
35
- internalSlots.roundingType = 'fractionDigits';
36
- internalSlots.minimumFractionDigits = mnfdDefault;
37
- internalSlots.maximumFractionDigits = mxfdDefault;
78
+ internalSlots.roundingType = 'morePrecision';
79
+ internalSlots.minimumFractionDigits = 0;
80
+ internalSlots.maximumFractionDigits = 0;
81
+ internalSlots.minimumSignificantDigits = 1;
82
+ internalSlots.maximumSignificantDigits = 2;
38
83
  }
39
84
  }
40
85
  exports.SetNumberFormatDigitOptions = SetNumberFormatDigitOptions;
@@ -1,4 +1,4 @@
1
- import { NumberFormatOptionsStyle, NumberFormatOptionsNotation, NumberFormatOptionsCompactDisplay, NumberFormatOptionsCurrencyDisplay, NumberFormatOptionsCurrencySign, NumberFormatOptionsUnitDisplay, NumberFormatLocaleInternalData, NumberFormatPart } from '../types/number';
1
+ import { NumberFormatOptionsStyle, NumberFormatOptionsNotation, NumberFormatOptionsCompactDisplay, NumberFormatOptionsCurrencyDisplay, NumberFormatOptionsCurrencySign, NumberFormatOptionsUnitDisplay, NumberFormatLocaleInternalData, NumberFormatPart, UseGroupingType } from '../types/number';
2
2
  interface NumberResult {
3
3
  formattedString: string;
4
4
  roundedNumber: number;
@@ -8,7 +8,7 @@ interface NumberResult {
8
8
  }
9
9
  export default function formatToParts(numberResult: NumberResult, data: NumberFormatLocaleInternalData, pl: Intl.PluralRules, options: {
10
10
  numberingSystem: string;
11
- useGrouping: boolean;
11
+ useGrouping?: UseGroupingType;
12
12
  style: NumberFormatOptionsStyle;
13
13
  notation: NumberFormatOptionsNotation;
14
14
  compactDisplay?: NumberFormatOptionsCompactDisplay;
@@ -1 +1 @@
1
- {"version":3,"file":"format_to_parts.d.ts","sourceRoot":"","sources":["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"}
1
+ {"version":3,"file":"format_to_parts.d.ts","sourceRoot":"","sources":["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,EAChB,eAAe,EAChB,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,CAAC,EAAE,eAAe,CAAA;IAC7B,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"}
@@ -119,7 +119,7 @@ function formatToParts(numberResult, data, pl, options) {
119
119
  // We only need to handle scientific and engineering notation here.
120
120
  numberParts.push.apply(numberParts, paritionNumberIntoParts(symbols, numberResult, notation, exponent, numberingSystem,
121
121
  // If compact number pattern exists, do not insert group separators.
122
- !compactNumberPattern && options.useGrouping, decimalNumberPattern));
122
+ !compactNumberPattern && Boolean(options.useGrouping), decimalNumberPattern));
123
123
  break;
124
124
  }
125
125
  case '-':
package/index.d.ts CHANGED
@@ -4,17 +4,23 @@ export * from './CoerceOptionsToObject';
4
4
  export * from './GetNumberOption';
5
5
  export * from './GetOption';
6
6
  export * from './GetOptionsObject';
7
+ export * from './GetStringOrBooleanOption';
7
8
  export * from './IsSanctionedSimpleUnitIdentifier';
8
9
  export * from './IsValidTimeZoneName';
9
10
  export * from './IsWellFormedCurrencyCode';
10
11
  export * from './IsWellFormedUnitIdentifier';
12
+ export * from './NumberFormat/ApplyUnsignedRoundingMode';
13
+ export * from './NumberFormat/CollapseNumberRange';
11
14
  export * from './NumberFormat/ComputeExponent';
12
15
  export * from './NumberFormat/ComputeExponentForMagnitude';
13
16
  export * from './NumberFormat/CurrencyDigits';
17
+ export * from './NumberFormat/FormatApproximately';
14
18
  export * from './NumberFormat/FormatNumericToParts';
15
19
  export * from './NumberFormat/FormatNumericToString';
20
+ export * from './NumberFormat/GetUnsignedRoundingMode';
16
21
  export * from './NumberFormat/InitializeNumberFormat';
17
22
  export * from './NumberFormat/PartitionNumberPattern';
23
+ export * from './NumberFormat/PartitionNumberRangePattern';
18
24
  export * from './NumberFormat/SetNumberFormatDigitOptions';
19
25
  export * from './NumberFormat/SetNumberFormatUnitOptions';
20
26
  export * from './NumberFormat/ToRawFixed';
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oCAAoC,CAAA;AACl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), exports);
8
8
  tslib_1.__exportStar(require("./GetNumberOption"), exports);
9
9
  tslib_1.__exportStar(require("./GetOption"), exports);
10
10
  tslib_1.__exportStar(require("./GetOptionsObject"), exports);
11
+ tslib_1.__exportStar(require("./GetStringOrBooleanOption"), exports);
11
12
  tslib_1.__exportStar(require("./IsSanctionedSimpleUnitIdentifier"), exports);
12
13
  tslib_1.__exportStar(require("./IsValidTimeZoneName"), exports);
13
14
  tslib_1.__exportStar(require("./IsWellFormedCurrencyCode"), exports);
14
15
  tslib_1.__exportStar(require("./IsWellFormedUnitIdentifier"), exports);
16
+ tslib_1.__exportStar(require("./NumberFormat/ApplyUnsignedRoundingMode"), exports);
17
+ tslib_1.__exportStar(require("./NumberFormat/CollapseNumberRange"), exports);
15
18
  tslib_1.__exportStar(require("./NumberFormat/ComputeExponent"), exports);
16
19
  tslib_1.__exportStar(require("./NumberFormat/ComputeExponentForMagnitude"), exports);
17
20
  tslib_1.__exportStar(require("./NumberFormat/CurrencyDigits"), exports);
21
+ tslib_1.__exportStar(require("./NumberFormat/FormatApproximately"), exports);
18
22
  tslib_1.__exportStar(require("./NumberFormat/FormatNumericToParts"), exports);
19
23
  tslib_1.__exportStar(require("./NumberFormat/FormatNumericToString"), exports);
24
+ tslib_1.__exportStar(require("./NumberFormat/GetUnsignedRoundingMode"), exports);
20
25
  tslib_1.__exportStar(require("./NumberFormat/InitializeNumberFormat"), exports);
21
26
  tslib_1.__exportStar(require("./NumberFormat/PartitionNumberPattern"), exports);
27
+ tslib_1.__exportStar(require("./NumberFormat/PartitionNumberRangePattern"), exports);
22
28
  tslib_1.__exportStar(require("./NumberFormat/SetNumberFormatDigitOptions"), exports);
23
29
  tslib_1.__exportStar(require("./NumberFormat/SetNumberFormatUnitOptions"), exports);
24
30
  tslib_1.__exportStar(require("./NumberFormat/ToRawFixed"), exports);
@@ -0,0 +1,11 @@
1
+ /**
2
+ * https://tc39.es/ecma402/#sec-getstringorbooleanoption
3
+ * @param opts
4
+ * @param prop
5
+ * @param values
6
+ * @param trueValue
7
+ * @param falsyValue
8
+ * @param fallback
9
+ */
10
+ export declare function GetStringOrBooleanOption<T extends object, K extends keyof T>(opts: T, prop: K, values: T[K][] | undefined, trueValue: T[K] | boolean, falsyValue: T[K] | boolean, fallback: T[K] | boolean): T[K] | boolean;
11
+ //# sourceMappingURL=GetStringOrBooleanOption.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GetStringOrBooleanOption.d.ts","sourceRoot":"","sources":["../GetStringOrBooleanOption.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAC1E,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,EAC1B,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,EACzB,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,EAC1B,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,GACvB,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAyBhB"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * https://tc39.es/ecma402/#sec-getstringorbooleanoption
3
+ * @param opts
4
+ * @param prop
5
+ * @param values
6
+ * @param trueValue
7
+ * @param falsyValue
8
+ * @param fallback
9
+ */
10
+ import { ToString } from './262';
11
+ export function GetStringOrBooleanOption(opts, prop, values, trueValue, falsyValue, fallback) {
12
+ var value = opts[prop];
13
+ if (value === undefined) {
14
+ return fallback;
15
+ }
16
+ if (value === true) {
17
+ return trueValue;
18
+ }
19
+ var valueBoolean = Boolean(value);
20
+ if (valueBoolean === false) {
21
+ return falsyValue;
22
+ }
23
+ value = ToString(value);
24
+ if (value === 'true' || value === 'false') {
25
+ return fallback;
26
+ }
27
+ if ((values || []).indexOf(value) === -1) {
28
+ throw new RangeError("Invalid value ".concat(value));
29
+ }
30
+ return value;
31
+ }
@@ -0,0 +1,3 @@
1
+ import { UnsignedRoundingModeType } from '../types/number';
2
+ export declare function ApplyUnsignedRoundingMode(x: number, r1: number, r2: number, unsignedRoundingMode: UnsignedRoundingModeType): number;
3
+ //# sourceMappingURL=ApplyUnsignedRoundingMode.d.ts.map