@fable-org/fable-library-ts 2.0.0-rc.3 → 2.0.0-rc.5
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 +13 -0
- package/Map.ts +3 -0
- package/MutableMap.ts +3 -3
- package/MutableSet.ts +2 -2
- package/Reflection.ts +1 -2
- package/RegExp.ts +11 -2
- package/Seq.ts +3 -3
- package/String.ts +15 -3
- package/System.Text.ts +9 -8
- package/Types.ts +9 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## Unreleased
|
|
9
9
|
|
|
10
|
+
## 2.0.0-rc.5 - 2026-03-31
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
* [JS/TS] Improve `Regex.Escape` and `Regex.Unescape` handling (by @MangelMaxime)
|
|
15
|
+
* [JS/TS] Fixed quotation for union string cases (by @MangelMaxime)
|
|
16
|
+
|
|
17
|
+
## 2.0.0-rc.4 - 2026-03-19
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
* [JS/TS] Fix `Unchecked.defaultof<char>` being emitted as `null` instead of `'\0'` (by @MangelMaxime)
|
|
22
|
+
|
|
10
23
|
## 2.0.0-rc.3 - 2026-03-10
|
|
11
24
|
|
|
12
25
|
### Fixed
|
package/Map.ts
CHANGED
|
@@ -881,6 +881,9 @@ export function MapTreeModule_ofSeq<Key, Value>(comparer: IComparer<Key>, c: Ite
|
|
|
881
881
|
}
|
|
882
882
|
}
|
|
883
883
|
|
|
884
|
+
/**
|
|
885
|
+
* Imperative left-to-right iterators.
|
|
886
|
+
*/
|
|
884
887
|
export class MapTreeModule_MapIterator$2<Key, Value> extends Record {
|
|
885
888
|
stack: FSharpList<Option<MapTreeLeaf$2<Key, Value>>>;
|
|
886
889
|
started: boolean;
|
package/MutableMap.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { IEqualityComparer, IDisposable, disposeSafe, defaultOf, IMap, MutableAr
|
|
|
3
3
|
import { iterate, map, delay, toArray, iterateIndexed, concat } from "./Seq.ts";
|
|
4
4
|
import { value as value_1, Option } from "./Option.ts";
|
|
5
5
|
import { int32 } from "./Int32.ts";
|
|
6
|
-
import { setItem } from "./Array.ts";
|
|
6
|
+
import { item as item_1, setItem } from "./Array.ts";
|
|
7
7
|
import { FSharpRef } from "./Types.ts";
|
|
8
8
|
import { class_type, TypeInfo } from "./Reflection.ts";
|
|
9
9
|
import { getItemFromDict, tryGetValue } from "./MapUtil.ts";
|
|
@@ -241,7 +241,7 @@ export function Dictionary__TryFind_2B595<Key, Value>(this$: Dictionary<Key, Val
|
|
|
241
241
|
}
|
|
242
242
|
switch (matchResult) {
|
|
243
243
|
case 0:
|
|
244
|
-
return getItemFromDict(this$.hashMap, matchValue[1])
|
|
244
|
+
return item_1(matchValue[2], getItemFromDict(this$.hashMap, matchValue[1]));
|
|
245
245
|
default:
|
|
246
246
|
return undefined;
|
|
247
247
|
}
|
|
@@ -284,7 +284,7 @@ export function Dictionary__set_Item_5BDDA1<Key, Value>(this$: Dictionary<Key, V
|
|
|
284
284
|
const matchValue: [boolean, int32, int32] = Dictionary__TryFindIndex_2B595<Key, Value>(this$, k);
|
|
285
285
|
if (matchValue[0]) {
|
|
286
286
|
if (matchValue[2] > -1) {
|
|
287
|
-
getItemFromDict(this$.hashMap, matchValue[1])
|
|
287
|
+
setItem(getItemFromDict(this$.hashMap, matchValue[1]), matchValue[2], [k, v] as [Key, Value]);
|
|
288
288
|
}
|
|
289
289
|
else {
|
|
290
290
|
const value: any = void (getItemFromDict(this$.hashMap, matchValue[1]).push([k, v] as [Key, Value]));
|
package/MutableSet.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { IMap, IEqualityComparer, IDisposable, disposeSafe, defaultOf, ISet, MutableArray, toIterator, IEnumerator, getEnumerator } from "./Util.ts";
|
|
3
3
|
import { iterate, map, iterateIndexed, concat } from "./Seq.ts";
|
|
4
|
-
import { setItem } from "./Array.ts";
|
|
4
|
+
import { item as item_1, setItem } from "./Array.ts";
|
|
5
5
|
import { int32 } from "./Int32.ts";
|
|
6
6
|
import { some, Option } from "./Option.ts";
|
|
7
7
|
import { FSharpRef } from "./Types.ts";
|
|
@@ -156,7 +156,7 @@ function HashSet__TryFind_2B595<T>(this$: HashSet<T>, k: T): Option<T> {
|
|
|
156
156
|
}
|
|
157
157
|
switch (matchResult) {
|
|
158
158
|
case 0:
|
|
159
|
-
return some(getItemFromDict(this$.hashMap, matchValue[1])
|
|
159
|
+
return some(item_1(matchValue[2], getItemFromDict(this$.hashMap, matchValue[1])));
|
|
160
160
|
default:
|
|
161
161
|
return undefined;
|
|
162
162
|
}
|
package/Reflection.ts
CHANGED
|
@@ -536,8 +536,7 @@ export function createInstance(t: TypeInfo, consArgs?: any[]): any {
|
|
|
536
536
|
case decimal_type.fullname:
|
|
537
537
|
return new Decimal(0);
|
|
538
538
|
case char_type.fullname:
|
|
539
|
-
|
|
540
|
-
return null;
|
|
539
|
+
return "\0";
|
|
541
540
|
default:
|
|
542
541
|
throw new Exception(`Cannot access constructor of ${t.fullname}`);
|
|
543
542
|
}
|
package/RegExp.ts
CHANGED
|
@@ -22,11 +22,20 @@ export function create(pattern: string, options = 0) {
|
|
|
22
22
|
// From http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
|
|
23
23
|
|
|
24
24
|
export function escape(str: string) {
|
|
25
|
-
|
|
25
|
+
// Matches the characters escaped by .NET's Regex.Escape.
|
|
26
|
+
// Note:
|
|
27
|
+
//
|
|
28
|
+
// .NET also escapes space and # (relevant for IgnorePatternWhitespace mode),
|
|
29
|
+
// but JS unicode-mode regex rejects \ and \# as invalid escapes, and we don't
|
|
30
|
+
// support IgnorePatternWhitespace, so we omit them.
|
|
31
|
+
//
|
|
32
|
+
// .NET does not escape ] and } but JS unicode-mode regex rejects bare ] and }
|
|
33
|
+
// as invalid, so we escape them too for compatibility.
|
|
34
|
+
return str.replace(/[$()*+.?[\\\^{|}\]]/g, "\\$&");
|
|
26
35
|
}
|
|
27
36
|
|
|
28
37
|
export function unescape(str: string) {
|
|
29
|
-
return str.replace(/\\([
|
|
38
|
+
return str.replace(/\\([$()*+.?[\\\^{|}\]])/g, "$1");
|
|
30
39
|
}
|
|
31
40
|
|
|
32
41
|
export function isMatch(reg: RegExp, input: string, startAt = 0) {
|
package/Seq.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { class_type, TypeInfo } from "./Reflection.ts";
|
|
|
6
6
|
import { some, value as value_1, Option } from "./Option.ts";
|
|
7
7
|
import { KeyNotFoundException_$ctor_Z721C83C5 } from "./System.Collections.Generic.ts";
|
|
8
8
|
import { Operators_Lock, Operators_NullArgCheck } from "./FSharp.Core.ts";
|
|
9
|
-
import { chunkBySize as chunkBySize_1, permute as permute_1, transpose as transpose_1, map as map_1, windowed as windowed_1, splitInto as splitInto_1, pairwise as pairwise_1, scanBack as scanBack_1, reverse as reverse_1, mapFoldBack as mapFoldBack_1, mapFold as mapFold_1, tryItem as tryItem_1, tryHead as tryHead_1, foldBack2 as foldBack2_1, foldBack as foldBack_1, tryFindIndexBack as tryFindIndexBack_1, tryFindBack as tryFindBack_1, singleton as singleton_1 } from "./Array.ts";
|
|
9
|
+
import { chunkBySize as chunkBySize_1, permute as permute_1, transpose as transpose_1, map as map_1, windowed as windowed_1, splitInto as splitInto_1, pairwise as pairwise_1, scanBack as scanBack_1, reverse as reverse_1, mapFoldBack as mapFoldBack_1, mapFold as mapFold_1, item as item_1, tryItem as tryItem_1, tryHead as tryHead_1, foldBack2 as foldBack2_1, foldBack as foldBack_1, tryFindIndexBack as tryFindIndexBack_1, tryFindBack as tryFindBack_1, singleton as singleton_1 } from "./Array.ts";
|
|
10
10
|
import { length as length_1, tryItem as tryItem_2, isEmpty as isEmpty_1, tryHead as tryHead_2, ofSeq as ofSeq_1, ofArray as ofArray_1, toArray as toArray_1, FSharpList } from "./List.ts";
|
|
11
11
|
import { int32 } from "./Int32.ts";
|
|
12
12
|
import { SR_indexOutOfBounds } from "./Global.ts";
|
|
@@ -1054,7 +1054,7 @@ export function cache<T>(source: Iterable<T>): Iterable<T> {
|
|
|
1054
1054
|
});
|
|
1055
1055
|
}, unfold<int32, T>((i_1: int32): Option<[T, int32]> => Operators_Lock<T[], Option<[T, int32]>>(prefix, (): Option<[T, int32]> => {
|
|
1056
1056
|
if (i_1 < prefix.length) {
|
|
1057
|
-
return [
|
|
1057
|
+
return [item_1(i_1, prefix), i_1 + 1] as [T, int32];
|
|
1058
1058
|
}
|
|
1059
1059
|
else {
|
|
1060
1060
|
if (i_1 >= prefix.length) {
|
|
@@ -1081,7 +1081,7 @@ export function cache<T>(source: Iterable<T>): Iterable<T> {
|
|
|
1081
1081
|
}
|
|
1082
1082
|
}
|
|
1083
1083
|
if (i_1 < prefix.length) {
|
|
1084
|
-
return [
|
|
1084
|
+
return [item_1(i_1, prefix), i_1 + 1] as [T, int32];
|
|
1085
1085
|
}
|
|
1086
1086
|
else {
|
|
1087
1087
|
return undefined;
|
package/String.ts
CHANGED
|
@@ -344,7 +344,11 @@ export function format(str: string | object, ...args: any[]) {
|
|
|
344
344
|
precision = precision == null ? 2 : precision;
|
|
345
345
|
rep = toFixed(rep, precision);
|
|
346
346
|
parts = splitIntAndDecimalPart(rep);
|
|
347
|
-
|
|
347
|
+
if (precision > 0) {
|
|
348
|
+
rep = "¤" + thousandSeparate(parts.integral) + "." + padRight(parts.decimal, precision, "0");
|
|
349
|
+
} else {
|
|
350
|
+
rep = "¤" + thousandSeparate(parts.integral);
|
|
351
|
+
}
|
|
348
352
|
if (isNegative) {
|
|
349
353
|
rep = "(" + rep + ")";
|
|
350
354
|
}
|
|
@@ -382,13 +386,21 @@ export function format(str: string | object, ...args: any[]) {
|
|
|
382
386
|
precision = precision != null ? precision : 2;
|
|
383
387
|
rep = toFixed(rep, precision);
|
|
384
388
|
parts = splitIntAndDecimalPart(rep);
|
|
385
|
-
|
|
389
|
+
if (precision > 0) {
|
|
390
|
+
rep = thousandSeparate(parts.integral) + "." + padRight(parts.decimal, precision, "0");
|
|
391
|
+
} else {
|
|
392
|
+
rep = thousandSeparate(parts.integral);
|
|
393
|
+
}
|
|
386
394
|
break;
|
|
387
395
|
case "p": case "P":
|
|
388
396
|
precision = precision != null ? precision : 2;
|
|
389
397
|
rep = toFixed(multiply(rep, 100), precision)
|
|
390
398
|
parts = splitIntAndDecimalPart(rep);
|
|
391
|
-
|
|
399
|
+
if (precision > 0) {
|
|
400
|
+
rep = thousandSeparate(parts.integral) + "." + padRight(parts.decimal, precision, "0") + " %";
|
|
401
|
+
} else {
|
|
402
|
+
rep = thousandSeparate(parts.integral) + " %";
|
|
403
|
+
}
|
|
392
404
|
break;
|
|
393
405
|
case "r": case "R":
|
|
394
406
|
throw new Exception("The round-trip format is not supported by Fable");
|
package/System.Text.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { float64, int32 } from "./Int32.ts";
|
|
|
4
4
|
import { class_type, TypeInfo } from "./Reflection.ts";
|
|
5
5
|
import { toString } from "./Types.ts";
|
|
6
6
|
import { Exception, clear, MutableArray, int32ToString } from "./Util.ts";
|
|
7
|
+
import { setItem, item } from "./Array.ts";
|
|
7
8
|
|
|
8
9
|
export class StringBuilder {
|
|
9
10
|
readonly buf: string[];
|
|
@@ -149,8 +150,8 @@ export function StringBuilder__Clear(x: StringBuilder): StringBuilder {
|
|
|
149
150
|
export function StringBuilder__get_Chars_Z524259A4(x: StringBuilder, index: int32): string {
|
|
150
151
|
let len = 0;
|
|
151
152
|
let i = 0;
|
|
152
|
-
while ((i < x.buf.length) && ((len + x.buf
|
|
153
|
-
len = ((len + x.buf
|
|
153
|
+
while ((i < x.buf.length) && ((len + item(i, x.buf).length) <= index)) {
|
|
154
|
+
len = ((len + item(i, x.buf).length) | 0);
|
|
154
155
|
i = ((i + 1) | 0);
|
|
155
156
|
}
|
|
156
157
|
if ((index < 0) ? true : (i >= x.buf.length)) {
|
|
@@ -158,15 +159,15 @@ export function StringBuilder__get_Chars_Z524259A4(x: StringBuilder, index: int3
|
|
|
158
159
|
}
|
|
159
160
|
else {
|
|
160
161
|
const pos: int32 = (index - len) | 0;
|
|
161
|
-
return x.buf[
|
|
162
|
+
return item(i, x.buf)[pos];
|
|
162
163
|
}
|
|
163
164
|
}
|
|
164
165
|
|
|
165
166
|
export function StringBuilder__set_Chars_413E0D0A(x: StringBuilder, index: int32, value: string): void {
|
|
166
167
|
let len = 0;
|
|
167
168
|
let i = 0;
|
|
168
|
-
while ((i < x.buf.length) && ((len + x.buf
|
|
169
|
-
len = ((len + x.buf
|
|
169
|
+
while ((i < x.buf.length) && ((len + item(i, x.buf).length) <= index)) {
|
|
170
|
+
len = ((len + item(i, x.buf).length) | 0);
|
|
170
171
|
i = ((i + 1) | 0);
|
|
171
172
|
}
|
|
172
173
|
if ((index < 0) ? true : (i >= x.buf.length)) {
|
|
@@ -174,13 +175,13 @@ export function StringBuilder__set_Chars_413E0D0A(x: StringBuilder, index: int32
|
|
|
174
175
|
}
|
|
175
176
|
else {
|
|
176
177
|
const pos: int32 = (index - len) | 0;
|
|
177
|
-
x.buf
|
|
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));
|
|
178
179
|
}
|
|
179
180
|
}
|
|
180
181
|
|
|
181
182
|
export function StringBuilder__Replace_Z766F94C0(x: StringBuilder, oldValue: string, newValue: string): StringBuilder {
|
|
182
183
|
for (let i: int32 = x.buf.length - 1; i >= 0; i--) {
|
|
183
|
-
x.buf
|
|
184
|
+
setItem(x.buf, i, replace(item(i, x.buf), oldValue, newValue));
|
|
184
185
|
}
|
|
185
186
|
return x;
|
|
186
187
|
}
|
|
@@ -193,7 +194,7 @@ export function StringBuilder__Replace_Z384F8060(x: StringBuilder, oldValue: str
|
|
|
193
194
|
export function StringBuilder__get_Length(x: StringBuilder): int32 {
|
|
194
195
|
let len = 0;
|
|
195
196
|
for (let i: int32 = x.buf.length - 1; i >= 0; i--) {
|
|
196
|
-
len = ((len + x.buf
|
|
197
|
+
len = ((len + item(i, x.buf).length) | 0);
|
|
197
198
|
}
|
|
198
199
|
return len | 0;
|
|
199
200
|
}
|
package/Types.ts
CHANGED
|
@@ -39,16 +39,23 @@ export function toString(x: any, callStack = 0): string {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export function unionToString(name: string, fields: any[]) {
|
|
42
|
+
function unionFieldToString(x: any): string {
|
|
43
|
+
if (typeof x === "string") {
|
|
44
|
+
return '"' + x + '"';
|
|
45
|
+
}
|
|
46
|
+
return toString(x);
|
|
47
|
+
}
|
|
48
|
+
|
|
42
49
|
if (fields.length === 0) {
|
|
43
50
|
return name;
|
|
44
51
|
} else {
|
|
45
52
|
let fieldStr;
|
|
46
53
|
let withParens = true;
|
|
47
54
|
if (fields.length === 1) {
|
|
48
|
-
fieldStr =
|
|
55
|
+
fieldStr = unionFieldToString(fields[0]);
|
|
49
56
|
withParens = fieldStr.indexOf(" ") >= 0;
|
|
50
57
|
} else {
|
|
51
|
-
fieldStr = fields.map((x: any) =>
|
|
58
|
+
fieldStr = fields.map((x: any) => unionFieldToString(x)).join(", ");
|
|
52
59
|
}
|
|
53
60
|
return name + (withParens ? " (" : " ") + fieldStr + (withParens ? ")" : "");
|
|
54
61
|
}
|
package/package.json
CHANGED