@fable-org/fable-library-ts 2.0.0-beta.2 → 2.0.0-beta.4
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.ts +1379 -1378
- package/CHANGELOG.md +10 -0
- package/Choice.ts +302 -301
- package/FSharp.Collections.ts +35 -34
- package/FSharp.Core.CompilerServices.ts +38 -37
- package/FSharp.Core.ts +186 -184
- package/Global.ts +38 -37
- package/List.ts +1428 -1417
- package/Map.ts +1548 -1552
- package/MutableMap.ts +346 -345
- package/MutableSet.ts +250 -249
- package/Native.ts +19 -11
- package/Option.ts +9 -3
- package/Random.ts +183 -181
- package/Range.ts +57 -56
- package/Result.ts +197 -196
- package/Seq.ts +1515 -1525
- package/Seq2.ts +130 -129
- package/Set.ts +1954 -1955
- package/System.Collections.Generic.ts +381 -380
- package/System.Text.ts +204 -203
- package/Util.ts +13 -5
- package/package.json +22 -22
package/System.Text.ts
CHANGED
|
@@ -1,203 +1,204 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { toString } from "./Types.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
void (x.buf.push(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
let
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
let
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
1
|
+
|
|
2
|
+
import { replace, format, replicate, substring, isNullOrEmpty, join } from "./String.js";
|
|
3
|
+
import { float64, int32 } from "./Int32.js";
|
|
4
|
+
import { class_type, TypeInfo } from "./Reflection.js";
|
|
5
|
+
import { toString } from "./Types.js";
|
|
6
|
+
import { clear, int32ToString, Nullable } from "./Util.js";
|
|
7
|
+
|
|
8
|
+
export class StringBuilder {
|
|
9
|
+
readonly buf: string[];
|
|
10
|
+
constructor(value: string, capacity: int32) {
|
|
11
|
+
this.buf = [];
|
|
12
|
+
if (!isNullOrEmpty(value)) {
|
|
13
|
+
void (this.buf.push(value));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
toString(): string {
|
|
17
|
+
const _: StringBuilder = this;
|
|
18
|
+
return join("", _.buf);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function StringBuilder_$reflection(): TypeInfo {
|
|
23
|
+
return class_type("System.Text.StringBuilder", undefined, StringBuilder);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function StringBuilder_$ctor_Z18115A39(value: string, capacity: int32): StringBuilder {
|
|
27
|
+
return new StringBuilder(value, capacity);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function StringBuilder_$ctor_Z524259A4(capacity: int32): StringBuilder {
|
|
31
|
+
return StringBuilder_$ctor_Z18115A39("", capacity);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function StringBuilder_$ctor_Z721C83C5(value: string): StringBuilder {
|
|
35
|
+
return StringBuilder_$ctor_Z18115A39(value, 16);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function StringBuilder_$ctor(): StringBuilder {
|
|
39
|
+
return StringBuilder_$ctor_Z18115A39("", 16);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function StringBuilder__Append_Z721C83C5(x: StringBuilder, s: Nullable<string>): StringBuilder {
|
|
43
|
+
void (x.buf.push(toString(s)));
|
|
44
|
+
return x;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function StringBuilder__Append_487EF8FB(x: StringBuilder, s: Nullable<string>, startIndex: int32, count: int32): StringBuilder {
|
|
48
|
+
void (x.buf.push(substring(toString(s), startIndex, count)));
|
|
49
|
+
return x;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function StringBuilder__Append_244C7CD6(x: StringBuilder, c: string): StringBuilder {
|
|
53
|
+
void (x.buf.push(c));
|
|
54
|
+
return x;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function StringBuilder__Append_61B1CA(x: StringBuilder, c: string, repeatCount: int32): StringBuilder {
|
|
58
|
+
const s: string = replicate(repeatCount, c);
|
|
59
|
+
void (x.buf.push(s));
|
|
60
|
+
return x;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function StringBuilder__Append_Z524259A4(x: StringBuilder, o: int32): StringBuilder {
|
|
64
|
+
void (x.buf.push(int32ToString(o)));
|
|
65
|
+
return x;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function StringBuilder__Append_5E38073B(x: StringBuilder, o: float64): StringBuilder {
|
|
69
|
+
void (x.buf.push(o.toString()));
|
|
70
|
+
return x;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function StringBuilder__Append_Z1FBCCD16(x: StringBuilder, o: boolean): StringBuilder {
|
|
74
|
+
void (x.buf.push(toString(o)));
|
|
75
|
+
return x;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function StringBuilder__Append_4E60E31B(x: StringBuilder, o: any): StringBuilder {
|
|
79
|
+
void (x.buf.push(toString(o)));
|
|
80
|
+
return x;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function StringBuilder__Append_Z372E4D23(x: StringBuilder, cs: string[]): StringBuilder {
|
|
84
|
+
void (x.buf.push(cs.join('')));
|
|
85
|
+
return x;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function StringBuilder__Append_43A65C09(x: StringBuilder, s: StringBuilder): StringBuilder {
|
|
89
|
+
void (x.buf.push(s.toString()));
|
|
90
|
+
return x;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function StringBuilder__AppendFormat_433E080(x: StringBuilder, fmt: string, o: any): StringBuilder {
|
|
94
|
+
void (x.buf.push(format(fmt, o)));
|
|
95
|
+
return x;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function StringBuilder__AppendFormat_Z3B30EC65(x: StringBuilder, fmt: string, o1: any, o2: any): StringBuilder {
|
|
99
|
+
void (x.buf.push(format(fmt, o1, o2)));
|
|
100
|
+
return x;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function StringBuilder__AppendFormat_10D165E0(x: StringBuilder, fmt: string, o1: any, o2: any, o3: any): StringBuilder {
|
|
104
|
+
void (x.buf.push(format(fmt, o1, o2, o3)));
|
|
105
|
+
return x;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function StringBuilder__AppendFormat_Z17053F5(x: StringBuilder, fmt: string, arr: any[]): StringBuilder {
|
|
109
|
+
void (x.buf.push(format(fmt, ...arr)));
|
|
110
|
+
return x;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function StringBuilder__AppendFormat_Z696D8D1B(x: StringBuilder, provider: any, fmt: string, o: any): StringBuilder {
|
|
114
|
+
void (x.buf.push(format(provider, fmt, o)));
|
|
115
|
+
return x;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function StringBuilder__AppendFormat_26802C9E(x: StringBuilder, provider: any, fmt: string, o1: any, o2: any): StringBuilder {
|
|
119
|
+
void (x.buf.push(format(provider, fmt, o1, o2)));
|
|
120
|
+
return x;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function StringBuilder__AppendFormat_Z471ADCBB(x: StringBuilder, provider: any, fmt: string, o1: any, o2: any, o3: any): StringBuilder {
|
|
124
|
+
void (x.buf.push(format(provider, fmt, o1, o2, o3)));
|
|
125
|
+
return x;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function StringBuilder__AppendFormat_6C2E3E6E(x: StringBuilder, provider: any, fmt: string, arr: any[]): StringBuilder {
|
|
129
|
+
void (x.buf.push(format(provider, fmt, ...arr)));
|
|
130
|
+
return x;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function StringBuilder__AppendLine(x: StringBuilder): StringBuilder {
|
|
134
|
+
void (x.buf.push("\n"));
|
|
135
|
+
return x;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function StringBuilder__AppendLine_Z721C83C5(x: StringBuilder, s: string): StringBuilder {
|
|
139
|
+
void (x.buf.push(s));
|
|
140
|
+
void (x.buf.push("\n"));
|
|
141
|
+
return x;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export function StringBuilder__Clear(x: StringBuilder): StringBuilder {
|
|
145
|
+
clear(x.buf);
|
|
146
|
+
return x;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function StringBuilder__get_Chars_Z524259A4(x: StringBuilder, index: int32): string {
|
|
150
|
+
let len = 0;
|
|
151
|
+
let i = -1;
|
|
152
|
+
while (((i + 1) < x.buf.length) && (len < index)) {
|
|
153
|
+
i = ((i + 1) | 0);
|
|
154
|
+
len = ((len + x.buf[i].length) | 0);
|
|
155
|
+
}
|
|
156
|
+
if (((index < 0) ? true : (i < 0)) ? true : (i >= x.buf.length)) {
|
|
157
|
+
throw new Error("Index was outside the bounds of the array");
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
const pos: int32 = ((len - index) - 1) | 0;
|
|
161
|
+
return x.buf[i][pos];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function StringBuilder__set_Chars_413E0D0A(x: StringBuilder, index: int32, value: string): void {
|
|
166
|
+
let len = 0;
|
|
167
|
+
let i = -1;
|
|
168
|
+
while (((i + 1) < x.buf.length) && (len < index)) {
|
|
169
|
+
i = ((i + 1) | 0);
|
|
170
|
+
len = ((len + x.buf[i].length) | 0);
|
|
171
|
+
}
|
|
172
|
+
if (((index < 0) ? true : (i < 0)) ? true : (i >= x.buf.length)) {
|
|
173
|
+
throw new Error("Index was outside the bounds of the array");
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
const pos: int32 = ((len - index) - 1) | 0;
|
|
177
|
+
x.buf[i] = ((x.buf[i].slice(0, (pos - 1) + 1) + value) + x.buf[i].slice(pos + 1, x.buf[i].length));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export function StringBuilder__Replace_Z766F94C0(x: StringBuilder, oldValue: string, newValue: string): StringBuilder {
|
|
182
|
+
for (let i: int32 = x.buf.length - 1; i >= 0; i--) {
|
|
183
|
+
x.buf[i] = replace(x.buf[i], oldValue, newValue);
|
|
184
|
+
}
|
|
185
|
+
return x;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export function StringBuilder__Replace_Z384F8060(x: StringBuilder, oldValue: string, newValue: string): StringBuilder {
|
|
189
|
+
const str: string = replace(x.toString(), oldValue, newValue);
|
|
190
|
+
return StringBuilder__Append_Z721C83C5(StringBuilder__Clear(x), str);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export function StringBuilder__get_Length(x: StringBuilder): int32 {
|
|
194
|
+
let len = 0;
|
|
195
|
+
for (let i: int32 = x.buf.length - 1; i >= 0; i--) {
|
|
196
|
+
len = ((len + x.buf[i].length) | 0);
|
|
197
|
+
}
|
|
198
|
+
return len | 0;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export function StringBuilder__ToString_Z37302880(x: StringBuilder, firstIndex: int32, length: int32): string {
|
|
202
|
+
return substring(x.toString(), firstIndex, length);
|
|
203
|
+
}
|
|
204
|
+
|
package/Util.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export type Nullable<T> = T | null | undefined;
|
|
2
|
+
|
|
1
3
|
// Don't change, this corresponds to DateTime.Kind enum values in .NET
|
|
2
4
|
export const enum DateKind {
|
|
3
5
|
Unspecified = 0,
|
|
@@ -30,11 +32,11 @@ export interface IDisposable {
|
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
export interface IComparer<T> {
|
|
33
|
-
Compare(x: T
|
|
35
|
+
Compare(x: Nullable<T>, y: Nullable<T>): number;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
export interface IEqualityComparer<T> {
|
|
37
|
-
Equals(x: T
|
|
39
|
+
Equals(x: Nullable<T>, y: Nullable<T>): boolean;
|
|
38
40
|
GetHashCode(x: T): number;
|
|
39
41
|
}
|
|
40
42
|
|
|
@@ -426,7 +428,7 @@ export function safeHash<T>(x: T): number {
|
|
|
426
428
|
return identityHash(x);
|
|
427
429
|
}
|
|
428
430
|
|
|
429
|
-
export function equalArraysWith<T>(x: ArrayLike<T
|
|
431
|
+
export function equalArraysWith<T>(x: Nullable<ArrayLike<T>>, y: Nullable<ArrayLike<T>>, eq: (x: T, y: T) => boolean): boolean {
|
|
430
432
|
if (x == null) { return y == null; }
|
|
431
433
|
if (y == null) { return false; }
|
|
432
434
|
if (x.length !== y.length) { return false; }
|
|
@@ -436,7 +438,7 @@ export function equalArraysWith<T>(x: ArrayLike<T>, y: ArrayLike<T>, eq: (x: T,
|
|
|
436
438
|
return true;
|
|
437
439
|
}
|
|
438
440
|
|
|
439
|
-
export function equalArrays<T>(x: ArrayLike<T
|
|
441
|
+
export function equalArrays<T>(x: Nullable<ArrayLike<T>>, y: Nullable<ArrayLike<T>>): boolean {
|
|
440
442
|
return equalArraysWith(x, y, equals);
|
|
441
443
|
}
|
|
442
444
|
|
|
@@ -456,10 +458,16 @@ function equalObjects(x: { [k: string]: any }, y: { [k: string]: any }): boolean
|
|
|
456
458
|
return true;
|
|
457
459
|
}
|
|
458
460
|
|
|
459
|
-
export function
|
|
461
|
+
export function physicalEquals<T>(x: T, y: T): boolean {
|
|
460
462
|
return x === y;
|
|
461
463
|
}
|
|
462
464
|
|
|
465
|
+
export function nullableEquals<T>(x: Nullable<T>, y: Nullable<T>): boolean {
|
|
466
|
+
if (x == null) { return y == null; }
|
|
467
|
+
if (y == null) { return false; }
|
|
468
|
+
return equals(x, y);
|
|
469
|
+
}
|
|
470
|
+
|
|
463
471
|
export function equals<T>(x: T, y: T): boolean {
|
|
464
472
|
if (x === y) {
|
|
465
473
|
return true;
|
package/package.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
2
|
+
"sideEffects": false,
|
|
3
|
+
"private": false,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"name": "@fable-org/fable-library-ts",
|
|
6
|
+
"version": "2.0.0-beta.4",
|
|
7
|
+
"description": "Core library used by F# projects compiled with fable.io",
|
|
8
|
+
"author": "Fable Contributors",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/fable-compiler/Fable.git"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/fable-compiler/Fable/issues"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://fable.io",
|
|
18
|
+
"keywords": [
|
|
19
|
+
"fable",
|
|
20
|
+
"fable-compiler",
|
|
21
|
+
"fsharp",
|
|
22
|
+
"F#"
|
|
23
|
+
]
|
|
24
24
|
}
|