@formatjs/intl-pluralrules 7.0.0 → 7.0.1
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.
- package/index.js +20 -15
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/polyfill-force.js +20 -15
- package/polyfill-force.js.map +1 -1
- package/polyfill.iife.js +49 -30
- package/polyfill.js +20 -15
- package/polyfill.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/intl-pluralrules",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"description": "Polyfill for Intl.PluralRules",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"PluralRules",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"./should-polyfill.js": "./should-polyfill.js"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@formatjs/bigdecimal": "0.2.
|
|
33
|
-
"@formatjs/intl-localematcher": "0.10.
|
|
32
|
+
"@formatjs/bigdecimal": "0.2.9",
|
|
33
|
+
"@formatjs/intl-localematcher": "0.10.1"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/polyfill-force.js
CHANGED
|
@@ -765,19 +765,15 @@ function ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode) {
|
|
|
765
765
|
return r2;
|
|
766
766
|
}
|
|
767
767
|
// packages/ecma402-abstract/NumberFormat/decimal-cache.js
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
*/
|
|
778
|
-
const getPowerOf10 = memoize((exponent) => {
|
|
779
|
-
return Decimal.pow(10, exponent);
|
|
780
|
-
});
|
|
768
|
+
const powersOfTen = /* @__PURE__ */ new Map();
|
|
769
|
+
function getPowerOf10(exponent) {
|
|
770
|
+
const n = typeof exponent === "number" ? exponent : exponent.toNumber();
|
|
771
|
+
const cached = powersOfTen.get(n);
|
|
772
|
+
if (cached !== void 0) return cached;
|
|
773
|
+
const power = Decimal.pow(10, n);
|
|
774
|
+
if (Number.isInteger(n) && n >= -324 && n <= 324) powersOfTen.set(n, power);
|
|
775
|
+
return power;
|
|
776
|
+
}
|
|
781
777
|
// packages/ecma402-abstract/NumberFormat/ToRawFixed.js
|
|
782
778
|
function ToRawFixedFn(n, f) {
|
|
783
779
|
return n.times(getPowerOf10(-f));
|
|
@@ -799,10 +795,19 @@ function findN2R2(x, f, roundingIncrement) {
|
|
|
799
795
|
/**
|
|
800
796
|
* https://tc39.es/ecma402/#sec-torawfixed
|
|
801
797
|
* @param x a finite non-negative Number or BigInt
|
|
802
|
-
* @param minFraction an integer between 0 and
|
|
803
|
-
* @param maxFraction an integer between 0 and
|
|
798
|
+
* @param minFraction an integer between 0 and 100
|
|
799
|
+
* @param maxFraction an integer between 0 and 100
|
|
804
800
|
*/
|
|
805
801
|
function ToRawFixed(x, minFraction, maxFraction, roundingIncrement, unsignedRoundingMode) {
|
|
802
|
+
if (roundingIncrement === 1 && x.isInteger()) {
|
|
803
|
+
const integer = x.toString();
|
|
804
|
+
return {
|
|
805
|
+
formattedString: integer + (minFraction === 0 ? "" : "." + repeat("0", minFraction)),
|
|
806
|
+
roundedNumber: x,
|
|
807
|
+
integerDigitsCount: integer.length,
|
|
808
|
+
roundingMagnitude: -maxFraction
|
|
809
|
+
};
|
|
810
|
+
}
|
|
806
811
|
const f = maxFraction;
|
|
807
812
|
const { n1, r1 } = findN1R1(x, f, roundingIncrement);
|
|
808
813
|
const { n2, r2 } = findN2R2(x, f, roundingIncrement);
|