@fable-org/fable-library-js 2.7.0 → 2.8.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.
- package/CHANGELOG.md +24 -1
- package/CollectionUtil.js +10 -16
- package/MutableMap.js +5 -1
- package/MutableSet.js +5 -1
- package/Util.js +15 -3
- 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: 2369fbd24fafe851544c1ed6eb54f0bfc2b75f36
|
|
3
3
|
updaters:
|
|
4
4
|
- package.json:
|
|
5
5
|
file: package.json
|
|
@@ -15,6 +15,29 @@ 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.8.0 - 2026-09-25
|
|
19
|
+
|
|
20
|
+
### 🐞 Bug Fixes
|
|
21
|
+
|
|
22
|
+
* *(js/ts)* Fix Dictionary.Remove and HashSet.Remove to remove empty buckets (#4985) ([aea61b56](https://github.com/fable-compiler/Fable/commit/aea61b562c461a9b383e805f06f68a3b21ed45c2))
|
|
23
|
+
* *(js/ts)* Clear custom System.Collections.IList implementations ([2369fbd2](https://github.com/fable-compiler/Fable/commit/2369fbd24fafe851544c1ed6eb54f0bfc2b75f36))
|
|
24
|
+
|
|
25
|
+
### ⚡ Performance Improvements
|
|
26
|
+
|
|
27
|
+
* *(js/ts)* Faster `resizeArray.Clear()` in JS/TS ([32d85add](https://github.com/fable-compiler/Fable/commit/32d85add01422547dba03b15e0a0787d8afb031b))
|
|
28
|
+
|
|
29
|
+
<strong><small>[View changes on Github](https://github.com/fable-compiler/Fable/compare/4a441b1926387a42db6a3a4294acd97b02760ca3..2369fbd24fafe851544c1ed6eb54f0bfc2b75f36)</small></strong>
|
|
30
|
+
|
|
31
|
+
## 2.7.1 - 2026-09-11
|
|
32
|
+
|
|
33
|
+
### 🐞 Bug Fixes
|
|
34
|
+
|
|
35
|
+
* *(js/ts)* Keep the sign of negative decimals below 0.1 ([91d80f18](https://github.com/fable-compiler/Fable/commit/91d80f185fb38e4d23fd9e906037a14daab3e3b9))
|
|
36
|
+
* *(js/ts)* Respect the precision when formatting decimals below 0.1 ([1c02557e](https://github.com/fable-compiler/Fable/commit/1c02557efd113d8d30a922c74c3fc9d1e7168cfd))
|
|
37
|
+
* *(js/ts)* Omit the decimal sign when the rounded result is zero ([ef63087d](https://github.com/fable-compiler/Fable/commit/ef63087d97b61927763023c4b2e5bb16bcd64af2))
|
|
38
|
+
|
|
39
|
+
<strong><small>[View changes on Github](https://github.com/fable-compiler/Fable/compare/c49d1ec5d1a491bfff65fe4bd6c71014cac9b321..4a441b1926387a42db6a3a4294acd97b02760ca3)</small></strong>
|
|
40
|
+
|
|
18
41
|
## 2.7.0 - 2026-09-08
|
|
19
42
|
|
|
20
43
|
### 🚀 Features
|
package/CollectionUtil.js
CHANGED
|
@@ -161,22 +161,16 @@ export function clear(col) {
|
|
|
161
161
|
if (typeof col["System.Collections.Generic.ICollection`1.Clear"] === "function") {
|
|
162
162
|
return col["System.Collections.Generic.ICollection`1.Clear"](); // collection
|
|
163
163
|
}
|
|
164
|
+
else if (Array.isArray(col)) {
|
|
165
|
+
col.length = 0;
|
|
166
|
+
}
|
|
167
|
+
else if (ArrayBuffer.isView(col)) {
|
|
168
|
+
// TODO: throw for typed arrays?
|
|
169
|
+
}
|
|
170
|
+
else if (typeof col.clear === "function") {
|
|
171
|
+
col.clear(); // map, set
|
|
172
|
+
}
|
|
164
173
|
else {
|
|
165
|
-
|
|
166
|
-
if (ArrayBuffer.isView(col)) {
|
|
167
|
-
// TODO: throw for typed arrays?
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
col.splice(0); // array, resize array
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
if (typeof col.clear === "function") {
|
|
175
|
-
col.clear(); // map, set
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
// TODO: throw for other collections?
|
|
179
|
-
}
|
|
180
|
-
}
|
|
174
|
+
// TODO: throw for other collections?
|
|
181
175
|
}
|
|
182
176
|
}
|
package/MutableMap.js
CHANGED
|
@@ -330,7 +330,11 @@ export function Dictionary__Remove_2B595(this$, k) {
|
|
|
330
330
|
}
|
|
331
331
|
switch (matchResult) {
|
|
332
332
|
case 0: {
|
|
333
|
-
|
|
333
|
+
const h_1 = matchValue[1] | 0;
|
|
334
|
+
getItemFromDict(this$.hashMap, h_1).splice(matchValue[2], 1);
|
|
335
|
+
if (getItemFromDict(this$.hashMap, h_1).length === 0) {
|
|
336
|
+
this$.hashMap.delete(h_1);
|
|
337
|
+
}
|
|
334
338
|
return true;
|
|
335
339
|
}
|
|
336
340
|
default:
|
package/MutableSet.js
CHANGED
|
@@ -224,7 +224,11 @@ export function HashSet__Remove_2B595(this$, k) {
|
|
|
224
224
|
}
|
|
225
225
|
switch (matchResult) {
|
|
226
226
|
case 0: {
|
|
227
|
-
|
|
227
|
+
const h_1 = matchValue[1] | 0;
|
|
228
|
+
getItemFromDict(this$.hashMap, h_1).splice(matchValue[2], 1);
|
|
229
|
+
if (getItemFromDict(this$.hashMap, h_1).length === 0) {
|
|
230
|
+
this$.hashMap.delete(h_1);
|
|
231
|
+
}
|
|
228
232
|
return true;
|
|
229
233
|
}
|
|
230
234
|
default:
|
package/Util.js
CHANGED
|
@@ -559,11 +559,23 @@ export function count(col) {
|
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
561
|
export function clear(col) {
|
|
562
|
-
if (
|
|
563
|
-
col.
|
|
562
|
+
if (Array.isArray(col)) {
|
|
563
|
+
col.length = 0;
|
|
564
|
+
}
|
|
565
|
+
else if (ArrayBuffer.isView(col)) {
|
|
566
|
+
// TODO: throw for typed arrays?
|
|
567
|
+
}
|
|
568
|
+
else if (typeof col.clear === "function") {
|
|
569
|
+
col.clear(); // map, set
|
|
570
|
+
}
|
|
571
|
+
else if (typeof col["System.Collections.Generic.ICollection`1.Clear"] === "function") {
|
|
572
|
+
col["System.Collections.Generic.ICollection`1.Clear"](); // collection
|
|
573
|
+
}
|
|
574
|
+
else if (typeof col["System.Collections.IList.Clear"] === "function") {
|
|
575
|
+
col["System.Collections.IList.Clear"](); // collection
|
|
564
576
|
}
|
|
565
577
|
else {
|
|
566
|
-
|
|
578
|
+
// TODO: throw for other collections?
|
|
567
579
|
}
|
|
568
580
|
}
|
|
569
581
|
const curried = new WeakMap();
|
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