@fable-org/fable-library-js 2.7.0 → 2.7.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/CHANGELOG.md +11 -1
- package/lib/big.js +14 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
last_commit_released:
|
|
2
|
+
last_commit_released: 4a441b1926387a42db6a3a4294acd97b02760ca3
|
|
3
3
|
updaters:
|
|
4
4
|
- package.json:
|
|
5
5
|
file: package.json
|
|
@@ -15,6 +15,16 @@ All notable changes to this project will be documented in this file.
|
|
|
15
15
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
16
16
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
17
17
|
|
|
18
|
+
## 2.7.1 - 2026-09-11
|
|
19
|
+
|
|
20
|
+
### 🐞 Bug Fixes
|
|
21
|
+
|
|
22
|
+
* *(js/ts)* Keep the sign of negative decimals below 0.1 ([91d80f18](https://github.com/fable-compiler/Fable/commit/91d80f185fb38e4d23fd9e906037a14daab3e3b9))
|
|
23
|
+
* *(js/ts)* Respect the precision when formatting decimals below 0.1 ([1c02557e](https://github.com/fable-compiler/Fable/commit/1c02557efd113d8d30a922c74c3fc9d1e7168cfd))
|
|
24
|
+
* *(js/ts)* Omit the decimal sign when the rounded result is zero ([ef63087d](https://github.com/fable-compiler/Fable/commit/ef63087d97b61927763023c4b2e5bb16bcd64af2))
|
|
25
|
+
|
|
26
|
+
<strong><small>[View changes on Github](https://github.com/fable-compiler/Fable/compare/c49d1ec5d1a491bfff65fe4bd6c71014cac9b321..4a441b1926387a42db6a3a4294acd97b02760ca3)</small></strong>
|
|
27
|
+
|
|
18
28
|
## 2.7.0 - 2026-09-08
|
|
19
29
|
|
|
20
30
|
### 🚀 Features
|
package/lib/big.js
CHANGED
|
@@ -210,6 +210,9 @@ function round(x, sd, rm, more) {
|
|
|
210
210
|
}
|
|
211
211
|
return x;
|
|
212
212
|
}
|
|
213
|
+
function hasNonzeroDigit(x) {
|
|
214
|
+
return x.c.some(d => d !== 0);
|
|
215
|
+
}
|
|
213
216
|
/*
|
|
214
217
|
* Return a string representing the value of Big x in normal or exponential notation.
|
|
215
218
|
* Handles P.toExponential, P.toFixed, P.toJSON, P.toPrecision, P.toString and P.valueOf.
|
|
@@ -728,7 +731,7 @@ P.times = P.mul = function (y) {
|
|
|
728
731
|
* rm? {number} Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up).
|
|
729
732
|
*/
|
|
730
733
|
P.toExponential = function (dp, rm) {
|
|
731
|
-
var x = this, n = x
|
|
734
|
+
var x = this, n = hasNonzeroDigit(x);
|
|
732
735
|
if (dp !== UNDEFINED) {
|
|
733
736
|
if (dp !== ~~dp || dp < 0 || dp > MAX_DP) {
|
|
734
737
|
throw Error(INVALID_DP);
|
|
@@ -737,7 +740,7 @@ P.toExponential = function (dp, rm) {
|
|
|
737
740
|
for (; x.c.length < dp;)
|
|
738
741
|
x.c.push(0);
|
|
739
742
|
}
|
|
740
|
-
return stringify(x, true,
|
|
743
|
+
return stringify(x, true, n);
|
|
741
744
|
};
|
|
742
745
|
/*
|
|
743
746
|
* Return a string representing the value of this Big in normal notation rounded to dp fixed
|
|
@@ -746,21 +749,22 @@ P.toExponential = function (dp, rm) {
|
|
|
746
749
|
* dp? {number} Decimal places: integer, 0 to MAX_DP inclusive.
|
|
747
750
|
* rm? {number} Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up).
|
|
748
751
|
*
|
|
749
|
-
*
|
|
750
|
-
* (-0).toFixed(
|
|
752
|
+
* Unlike JavaScript, the sign is omitted when the rounded result is zero:
|
|
753
|
+
* (-0.1).toFixed(0) is '0' and (-0.01).toFixed(1) is '0.0', matching .NET.
|
|
751
754
|
*/
|
|
752
755
|
P.toFixed = function (dp, rm) {
|
|
753
|
-
var x = this
|
|
756
|
+
var x = this;
|
|
754
757
|
if (dp !== UNDEFINED) {
|
|
755
758
|
if (dp !== ~~dp || dp < 0 || dp > MAX_DP) {
|
|
756
759
|
throw Error(INVALID_DP);
|
|
757
760
|
}
|
|
758
|
-
x =
|
|
761
|
+
x = new x.constructor(x);
|
|
762
|
+
x = round(x, dp + x.e + 1, rm);
|
|
759
763
|
// x.e may have changed if the value is rounded up.
|
|
760
764
|
for (dp = dp + x.e + 1; x.c.length < dp;)
|
|
761
765
|
x.c.push(0);
|
|
762
766
|
}
|
|
763
|
-
return stringify(x, false,
|
|
767
|
+
return stringify(x, false, hasNonzeroDigit(x));
|
|
764
768
|
};
|
|
765
769
|
/*
|
|
766
770
|
* Return a string representing the value of this Big.
|
|
@@ -770,7 +774,7 @@ P.toFixed = function (dp, rm) {
|
|
|
770
774
|
*/
|
|
771
775
|
P.toJSON = P.toString = function () {
|
|
772
776
|
var x = this, Big = x.constructor;
|
|
773
|
-
return stringify(x, x.e <= Big.NE || x.e >= Big.PE,
|
|
777
|
+
return stringify(x, x.e <= Big.NE || x.e >= Big.PE, hasNonzeroDigit(x));
|
|
774
778
|
};
|
|
775
779
|
/*
|
|
776
780
|
* Return the value of this Big as a primitve number.
|
|
@@ -792,7 +796,7 @@ P.toNumber = function () {
|
|
|
792
796
|
* rm? {number} Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up).
|
|
793
797
|
*/
|
|
794
798
|
P.toPrecision = function (sd, rm) {
|
|
795
|
-
var x = this, Big = x.constructor, n = x
|
|
799
|
+
var x = this, Big = x.constructor, n = hasNonzeroDigit(x);
|
|
796
800
|
if (sd !== UNDEFINED) {
|
|
797
801
|
if (sd !== ~~sd || sd < 1 || sd > MAX_DP) {
|
|
798
802
|
throw Error(INVALID + 'precision');
|
|
@@ -801,7 +805,7 @@ P.toPrecision = function (sd, rm) {
|
|
|
801
805
|
for (; x.c.length < sd;)
|
|
802
806
|
x.c.push(0);
|
|
803
807
|
}
|
|
804
|
-
return stringify(x, sd <= x.e || x.e <= Big.NE || x.e >= Big.PE,
|
|
808
|
+
return stringify(x, sd <= x.e || x.e <= Big.NE || x.e >= Big.PE, n);
|
|
805
809
|
};
|
|
806
810
|
/*
|
|
807
811
|
* Return a string representing the value of this Big.
|
package/package.json
CHANGED