@fable-org/fable-library-js 2.5.0 → 2.6.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/Array.js +3 -2
- package/CHANGELOG.md +21 -1
- package/List.js +2 -1
- package/Map.js +8 -4
- package/MutableMap.js +2 -2
- package/MutableSet.js +1 -1
- package/Option.js +1 -18
- package/Seq.js +2 -2
- package/System.Text.js +9 -9
- package/package.json +1 -1
- package/quotation.js +47 -0
package/Array.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { disposeSafe, getEnumerator, copyToArray, defaultOf, Exception } from "./Util.js";
|
|
2
2
|
import { Helpers_allocateArrayFromCons } from "./Native.js";
|
|
3
3
|
import { setItem as setItem_1, item as item_2 } from "./Array.js";
|
|
4
|
-
import { value as value_2,
|
|
4
|
+
import { value as value_2, defaultArg, some } from "./Option.js";
|
|
5
5
|
import { min as min_1, max as max_1 } from "./Double.js";
|
|
6
6
|
import { SR_notEnoughElements, SR_inputMustBeNonNegative, SR_inputSequenceEmpty, SR_Arg_ArgumentOutOfRangeException, SR_indexOutOfBounds } from "./Global.js";
|
|
7
7
|
import { Operators_IsNull } from "./FSharp.Core.js";
|
|
@@ -183,8 +183,9 @@ export function where(predicate, array) {
|
|
|
183
183
|
return array.filter(predicate);
|
|
184
184
|
}
|
|
185
185
|
export function indexOf(array, item_1, start, count, eq) {
|
|
186
|
+
let option_1 = undefined;
|
|
186
187
|
const start_1 = defaultArg(start, 0) | 0;
|
|
187
|
-
const end$0027 = defaultArg(
|
|
188
|
+
const end$0027 = defaultArg((option_1 = count, (option_1 != null) ? (start_1 + value_2(option_1)) : undefined), array.length) | 0;
|
|
188
189
|
const loop = (i_mut) => {
|
|
189
190
|
loop: while (true) {
|
|
190
191
|
const i = i_mut;
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
last_commit_released:
|
|
2
|
+
last_commit_released: bf694309ae5dbc6bb546d9acc4d091f5e35fe330
|
|
3
3
|
updaters:
|
|
4
4
|
- package.json:
|
|
5
5
|
file: package.json
|
|
@@ -15,6 +15,26 @@ 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.6.0 - 2026-09-03
|
|
19
|
+
|
|
20
|
+
### 🚀 Features
|
|
21
|
+
|
|
22
|
+
* *(all)* Quotations: DerivedPatterns, and captured locals as Value nodes (#4919) ([fae5093f](https://github.com/fable-compiler/Fable/commit/fae5093f2801195e865adf1acfaec63f38bbf973))
|
|
23
|
+
|
|
24
|
+
### 🐞 Bug Fixes
|
|
25
|
+
|
|
26
|
+
* *(all)* Emit instance calls for virtual methods inherited from Object (#4926) ([2fb535a7](https://github.com/fable-compiler/Fable/commit/2fb535a7cd35cef501c56684f205e2dffa3c36e6))
|
|
27
|
+
|
|
28
|
+
<strong><small>[View changes on Github](https://github.com/fable-compiler/Fable/compare/619d7afddbaf25108e819abaaa9d8a6503c457d6..bf694309ae5dbc6bb546d9acc4d091f5e35fe330)</small></strong>
|
|
29
|
+
|
|
30
|
+
## 2.5.1 - 2026-07-24
|
|
31
|
+
|
|
32
|
+
### 🐞 Bug Fixes
|
|
33
|
+
|
|
34
|
+
* *(js/ts,python)* Inline Option/ValueOption combinators to avoid closures and allocations (#4836) ([61cac646](https://github.com/fable-compiler/Fable/commit/61cac646e6385d82247082dbb90a98b1646560de))
|
|
35
|
+
|
|
36
|
+
<strong><small>[View changes on Github](https://github.com/fable-compiler/Fable/compare/6568f35ece227fc30ce84111c8d2e975b09bac00..619d7afddbaf25108e819abaaa9d8a6503c457d6)</small></strong>
|
|
37
|
+
|
|
18
38
|
## 2.5.0 - 2026-07-15
|
|
19
39
|
|
|
20
40
|
### 🚀 Features
|
package/List.js
CHANGED
|
@@ -253,12 +253,13 @@ export function FSharpList__get_Item_Z524259A4(xs, index) {
|
|
|
253
253
|
const i = i_mut, xs_1 = xs_1_mut;
|
|
254
254
|
const matchValue = xs_1.tail;
|
|
255
255
|
if (matchValue != null) {
|
|
256
|
+
const t = value_1(matchValue);
|
|
256
257
|
if (i === index) {
|
|
257
258
|
return xs_1.head;
|
|
258
259
|
}
|
|
259
260
|
else {
|
|
260
261
|
i_mut = (i + 1);
|
|
261
|
-
xs_1_mut =
|
|
262
|
+
xs_1_mut = t;
|
|
262
263
|
continue loop;
|
|
263
264
|
}
|
|
264
265
|
}
|
package/Map.js
CHANGED
|
@@ -702,11 +702,15 @@ export function MapTreeModule_foldSectionOpt(comparer, lo, hi, f, m, x) {
|
|
|
702
702
|
return x_3;
|
|
703
703
|
}
|
|
704
704
|
}
|
|
705
|
-
else if ((comparer.Compare(lo, MapTreeLeaf$2__get_Key(m2)) <= 0) && (comparer.Compare(MapTreeLeaf$2__get_Key(m2), hi) <= 0)) {
|
|
706
|
-
return f_1(MapTreeLeaf$2__get_Key(m2), MapTreeLeaf$2__get_Value(m2), x_1);
|
|
707
|
-
}
|
|
708
705
|
else {
|
|
709
|
-
|
|
706
|
+
const cLoKey_1 = comparer.Compare(lo, MapTreeLeaf$2__get_Key(m2)) | 0;
|
|
707
|
+
const cKeyHi_1 = comparer.Compare(MapTreeLeaf$2__get_Key(m2), hi) | 0;
|
|
708
|
+
if ((cLoKey_1 <= 0) && (cKeyHi_1 <= 0)) {
|
|
709
|
+
return f_1(MapTreeLeaf$2__get_Key(m2), MapTreeLeaf$2__get_Value(m2), x_1);
|
|
710
|
+
}
|
|
711
|
+
else {
|
|
712
|
+
return x_1;
|
|
713
|
+
}
|
|
710
714
|
}
|
|
711
715
|
}
|
|
712
716
|
else {
|
package/MutableMap.js
CHANGED
|
@@ -272,7 +272,7 @@ export function Dictionary__set_Item_5BDDA1(this$, k, v) {
|
|
|
272
272
|
setItem(getItemFromDict(this$.hashMap, matchValue[1]), matchValue[2], [k, v]);
|
|
273
273
|
}
|
|
274
274
|
else {
|
|
275
|
-
|
|
275
|
+
void (getItemFromDict(this$.hashMap, matchValue[1]).push([k, v]));
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
278
|
else {
|
|
@@ -286,7 +286,7 @@ export function Dictionary__Add_5BDDA1(this$, k, v) {
|
|
|
286
286
|
throw ArgumentException_$ctor_Z721C83C5(format("An item with the same key has already been added. Key: {0}", k));
|
|
287
287
|
}
|
|
288
288
|
else {
|
|
289
|
-
|
|
289
|
+
void (getItemFromDict(this$.hashMap, matchValue[1]).push([k, v]));
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
else {
|
package/MutableSet.js
CHANGED
|
@@ -178,7 +178,7 @@ export function HashSet__Add_2B595(this$, k) {
|
|
|
178
178
|
return false;
|
|
179
179
|
}
|
|
180
180
|
else {
|
|
181
|
-
|
|
181
|
+
void (getItemFromDict(this$.hashMap, matchValue[1]).push(k));
|
|
182
182
|
return true;
|
|
183
183
|
}
|
|
184
184
|
}
|
package/Option.js
CHANGED
|
@@ -70,30 +70,13 @@ export function toArray(opt) {
|
|
|
70
70
|
export function defaultArg(opt, defaultValue) {
|
|
71
71
|
return (opt != null) ? value(opt) : defaultValue;
|
|
72
72
|
}
|
|
73
|
-
export function defaultArgWith(opt, defThunk) {
|
|
74
|
-
return (opt != null) ? value(opt) : defThunk();
|
|
75
|
-
}
|
|
76
73
|
export function orElse(opt, ifNone) {
|
|
77
74
|
return opt == null ? ifNone : opt;
|
|
78
75
|
}
|
|
79
|
-
|
|
80
|
-
return opt == null ? ifNoneThunk() : opt;
|
|
81
|
-
}
|
|
82
|
-
export function filter(predicate, opt) {
|
|
83
|
-
return (opt != null) ? (predicate(value(opt)) ? opt : undefined) : opt;
|
|
84
|
-
}
|
|
76
|
+
// Only used by Replacements.Util.fs's curry/uncurry helpers, not by `Option.map` itself.
|
|
85
77
|
export function map(mapping, opt) {
|
|
86
78
|
return (opt != null) ? some(mapping(value(opt))) : undefined;
|
|
87
79
|
}
|
|
88
|
-
export function map2(mapping, opt1, opt2) {
|
|
89
|
-
return (opt1 != null && opt2 != null) ? mapping(value(opt1), value(opt2)) : undefined;
|
|
90
|
-
}
|
|
91
|
-
export function map3(mapping, opt1, opt2, opt3) {
|
|
92
|
-
return (opt1 != null && opt2 != null && opt3 != null) ? mapping(value(opt1), value(opt2), value(opt3)) : undefined;
|
|
93
|
-
}
|
|
94
|
-
export function bind(binder, opt) {
|
|
95
|
-
return opt != null ? binder(value(opt)) : undefined;
|
|
96
|
-
}
|
|
97
80
|
export function tryOp(op, arg) {
|
|
98
81
|
try {
|
|
99
82
|
return some(op(arg));
|
package/Seq.js
CHANGED
|
@@ -277,7 +277,7 @@ export function Enumerator_unfold(f, state) {
|
|
|
277
277
|
return Enumerator_FromFunctions$1_$ctor_58C54629(() => {
|
|
278
278
|
if (curr != null) {
|
|
279
279
|
const x = value_1(curr)[0];
|
|
280
|
-
|
|
280
|
+
value_1(curr)[1];
|
|
281
281
|
return x;
|
|
282
282
|
}
|
|
283
283
|
else {
|
|
@@ -286,7 +286,7 @@ export function Enumerator_unfold(f, state) {
|
|
|
286
286
|
}, () => {
|
|
287
287
|
curr = f(acc);
|
|
288
288
|
if (curr != null) {
|
|
289
|
-
|
|
289
|
+
value_1(curr)[0];
|
|
290
290
|
const st_1 = value_1(curr)[1];
|
|
291
291
|
acc = st_1;
|
|
292
292
|
return true;
|
package/System.Text.js
CHANGED
|
@@ -178,6 +178,13 @@ export function StringBuilder__set_Chars_413E0D0A(x, index, value) {
|
|
|
178
178
|
setItem(x.buf, i, (item(i, x.buf).slice(0, (pos - 1) + 1) + value) + item(i, x.buf).slice(pos + 1, item(i, x.buf).length));
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
+
export function StringBuilder__get_Length(x) {
|
|
182
|
+
let len = 0;
|
|
183
|
+
for (let i = x.buf.length - 1; i >= 0; i--) {
|
|
184
|
+
len = ((len + item(i, x.buf).length) | 0);
|
|
185
|
+
}
|
|
186
|
+
return len | 0;
|
|
187
|
+
}
|
|
181
188
|
export function StringBuilder__Replace_Z766F94C0(x, oldValue, newValue) {
|
|
182
189
|
for (let i = x.buf.length - 1; i >= 0; i--) {
|
|
183
190
|
setItem(x.buf, i, replace(item(i, x.buf), oldValue, newValue));
|
|
@@ -188,13 +195,6 @@ export function StringBuilder__Replace_Z384F8060(x, oldValue, newValue) {
|
|
|
188
195
|
const str = replace(x.toString(), oldValue, newValue);
|
|
189
196
|
return StringBuilder__Append_Z721C83C5(StringBuilder__Clear(x), str);
|
|
190
197
|
}
|
|
191
|
-
export function
|
|
192
|
-
|
|
193
|
-
for (let i = x.buf.length - 1; i >= 0; i--) {
|
|
194
|
-
len = ((len + item(i, x.buf).length) | 0);
|
|
195
|
-
}
|
|
196
|
-
return len | 0;
|
|
197
|
-
}
|
|
198
|
-
export function StringBuilder__ToString_Z37302880(x, firstIndex, length) {
|
|
199
|
-
return substring(x.toString(), firstIndex, length);
|
|
198
|
+
export function StringBuilder__ToString_Z37302880(x, startIndex, length) {
|
|
199
|
+
return substring(x.toString(), startIndex, length);
|
|
200
200
|
}
|
package/package.json
CHANGED
package/quotation.js
CHANGED
|
@@ -633,3 +633,50 @@ export function exprFromJSON(json) {
|
|
|
633
633
|
default: return new ExprValue(json, "unknown");
|
|
634
634
|
}
|
|
635
635
|
}
|
|
636
|
+
// ===================================================================
|
|
637
|
+
// DerivedPatterns
|
|
638
|
+
// F# defines these on top of Patterns. AndAlso and OrElse recover the
|
|
639
|
+
// shape `&&` and `||` desugar into; SpecificCall matches a call by the
|
|
640
|
+
// identity of a template quotation rather than by compiled name.
|
|
641
|
+
// ===================================================================
|
|
642
|
+
export function isAndAlso(expr) {
|
|
643
|
+
// a && b ==> if a then b else false
|
|
644
|
+
if (expr instanceof ExprIfThenElse
|
|
645
|
+
&& expr.elseExpr instanceof ExprValue
|
|
646
|
+
&& expr.elseExpr.value === false) {
|
|
647
|
+
return [expr.guard, expr.thenExpr];
|
|
648
|
+
}
|
|
649
|
+
return undefined;
|
|
650
|
+
}
|
|
651
|
+
export function isOrElse(expr) {
|
|
652
|
+
// a || b ==> if a then true else b
|
|
653
|
+
if (expr instanceof ExprIfThenElse
|
|
654
|
+
&& expr.thenExpr instanceof ExprValue
|
|
655
|
+
&& expr.thenExpr.value === true) {
|
|
656
|
+
return [expr.guard, expr.elseExpr];
|
|
657
|
+
}
|
|
658
|
+
return undefined;
|
|
659
|
+
}
|
|
660
|
+
/// A template such as <@ (=) @> quotes as nested lambdas around the call, so
|
|
661
|
+
/// the identifying Call node has to be dug out before comparing.
|
|
662
|
+
function templateCall(expr) {
|
|
663
|
+
let current = expr;
|
|
664
|
+
while (current instanceof ExprLambda) {
|
|
665
|
+
current = current.body;
|
|
666
|
+
}
|
|
667
|
+
return current instanceof ExprCall ? current : undefined;
|
|
668
|
+
}
|
|
669
|
+
// Takes both arguments; the partial application FSharp.Core expresses by
|
|
670
|
+
// currying is built by the replacement instead.
|
|
671
|
+
export function isSpecificCall(template, expr) {
|
|
672
|
+
const wanted = templateCall(template);
|
|
673
|
+
if (wanted === undefined || !(expr instanceof ExprCall))
|
|
674
|
+
return undefined;
|
|
675
|
+
if (expr.method !== wanted.method || expr.declaringType !== wanted.declaringType)
|
|
676
|
+
return undefined;
|
|
677
|
+
const instance = (expr.instance instanceof ExprValue && expr.instance.type === "novalue") ? null : expr.instance;
|
|
678
|
+
// The middle slot is F#'s generic-argument list. The runtime models types as
|
|
679
|
+
// names rather than System.Type, so it is always empty here; callers written
|
|
680
|
+
// against Fable match it with a wildcard.
|
|
681
|
+
return [instance, ofArray([]), ofArray(expr.args)];
|
|
682
|
+
}
|