@fable-org/fable-library-ts 2.0.0-beta.3 → 2.0.0-beta.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/Array.ts +1385 -1378
- package/Async.ts +13 -12
- package/AsyncBuilder.ts +10 -11
- package/BigInt.ts +6 -6
- package/BitConverter.ts +3 -3
- package/Boolean.ts +3 -2
- package/CHANGELOG.md +12 -0
- package/Char.ts +38 -35
- package/Choice.ts +326 -301
- package/CollectionUtil.ts +4 -4
- package/Date.ts +67 -62
- package/DateOffset.ts +48 -57
- package/DateOnly.ts +8 -8
- package/Decimal.ts +9 -9
- package/Double.ts +3 -2
- package/Encoding.ts +1 -1
- package/Event.ts +3 -3
- package/FSharp.Collections.ts +53 -34
- package/FSharp.Core.CompilerServices.ts +38 -37
- package/FSharp.Core.ts +186 -185
- package/Global.ts +80 -37
- package/Guid.ts +7 -6
- package/Int32.ts +20 -17
- package/List.ts +1429 -1417
- package/Long.ts +6 -5
- package/MailboxProcessor.ts +8 -7
- package/Map.ts +1550 -1552
- package/MapUtil.ts +5 -5
- package/MutableMap.ts +358 -345
- package/MutableSet.ts +250 -249
- package/Native.ts +19 -11
- package/Numeric.ts +1 -1
- package/Observable.ts +3 -3
- package/Option.ts +10 -4
- package/Random.ts +196 -194
- package/Range.ts +57 -56
- package/Reflection.ts +73 -40
- package/RegExp.ts +5 -3
- package/Result.ts +201 -196
- package/Seq.ts +1517 -1525
- package/Seq2.ts +130 -129
- package/Set.ts +1955 -1955
- package/String.ts +41 -38
- package/System.Collections.Generic.ts +401 -380
- package/System.Text.ts +204 -203
- package/System.ts +366 -0
- package/TimeOnly.ts +10 -10
- package/TimeSpan.ts +11 -11
- package/Timer.ts +2 -2
- package/Types.ts +1 -19
- package/Uri.ts +13 -10
- package/Util.ts +77 -21
- package/package.json +22 -22
- package/tsconfig.json +18 -5
- package/SystemException.ts +0 -7
package/DateOnly.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { FSharpRef } from "./Types.
|
|
2
|
-
import { DateTime, getTicks, dayOfYear as Date_dayOfYear, year as Date_year, month as Date_month, day as Date_day, daysInMonth as Date_daysInMonth, ticksToUnixEpochMilliseconds } from "./Date.
|
|
3
|
-
import { IDateTime,
|
|
1
|
+
import { FSharpRef } from "./Types.ts";
|
|
2
|
+
import { DateTime, getTicks, dayOfYear as Date_dayOfYear, year as Date_year, month as Date_month, day as Date_day, daysInMonth as Date_daysInMonth, ticksToUnixEpochMilliseconds } from "./Date.ts";
|
|
3
|
+
import { Exception, IDateTime, DateTimeKind, padWithZeros } from "./Util.ts";
|
|
4
4
|
|
|
5
5
|
export function fromUnixMilliseconds(value: number) {
|
|
6
|
-
return DateTime(value,
|
|
6
|
+
return DateTime(value, DateTimeKind.Utc);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export function create(year: number, month: number, day: number) {
|
|
@@ -57,13 +57,13 @@ export function dayOfYear(d: IDateTime) {
|
|
|
57
57
|
return Date_dayOfYear(d);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
export function toDateTime(d: IDateTime, time: number, kind =
|
|
61
|
-
return DateTime(d.getTime() + time + (kind !==
|
|
60
|
+
export function toDateTime(d: IDateTime, time: number, kind: DateTimeKind = DateTimeKind.Unspecified) {
|
|
61
|
+
return DateTime(d.getTime() + time + (kind !== DateTimeKind.Utc ? d.getTimezoneOffset() : 0) * 60_000, kind);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
export function toString(d: IDateTime, format = "d", _provider?: any) {
|
|
65
65
|
if (["d", "o", "O"].indexOf(format) === -1) {
|
|
66
|
-
throw new
|
|
66
|
+
throw new Exception("Custom formats are not supported");
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
const y = padWithZeros(year(d), 4);
|
|
@@ -75,7 +75,7 @@ export function toString(d: IDateTime, format = "d", _provider?: any) {
|
|
|
75
75
|
|
|
76
76
|
export function parse(str: string) {
|
|
77
77
|
function fail(): IDateTime {
|
|
78
|
-
throw new
|
|
78
|
+
throw new Exception(`String '${str}' was not recognized as a valid DateOnly.`);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
// Allowed separators: . , / -
|
package/Decimal.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import Decimal, { BigSource } from "./lib/big.js";
|
|
2
|
-
import { Numeric, symbol } from "./Numeric.
|
|
3
|
-
import { FSharpRef } from "./Types.
|
|
4
|
-
import { combineHashCodes } from "./Util.
|
|
5
|
-
import { int8, uint8, int16, uint16, int32, uint32, float16, float32, float64 } from "./Int32.
|
|
6
|
-
import { fromDecimal, int64, uint64, int128, uint128, nativeint, unativeint } from "./BigInt.
|
|
7
|
-
import * as bigInt from "./BigInt.
|
|
2
|
+
import { Numeric, symbol } from "./Numeric.ts";
|
|
3
|
+
import { FSharpRef } from "./Types.ts";
|
|
4
|
+
import { Exception, combineHashCodes } from "./Util.ts";
|
|
5
|
+
import { int8, uint8, int16, uint16, int32, uint32, float16, float32, float64 } from "./Int32.ts";
|
|
6
|
+
import { fromDecimal, int64, uint64, int128, uint128, nativeint, unativeint } from "./BigInt.ts";
|
|
7
|
+
import * as bigInt from "./BigInt.ts";
|
|
8
8
|
|
|
9
9
|
Decimal.prototype.GetHashCode = function () {
|
|
10
10
|
return combineHashCodes([this.s, this.e].concat(this.c))
|
|
@@ -138,7 +138,7 @@ export function parse(str: string): Decimal {
|
|
|
138
138
|
if (tryParse(str, defValue)) {
|
|
139
139
|
return defValue.contents;
|
|
140
140
|
} else {
|
|
141
|
-
throw new
|
|
141
|
+
throw new Exception(`The input string ${str} was not in a correct format.`);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
|
|
@@ -149,7 +149,7 @@ export function toNumber(x: Decimal): number {
|
|
|
149
149
|
export function toChar(x: Decimal): string {
|
|
150
150
|
const n = toNumber(x);
|
|
151
151
|
if (n < 0 || n > 65535 || isNaN(n)) {
|
|
152
|
-
throw new
|
|
152
|
+
throw new Exception("Value was either too large or too small for a character.");
|
|
153
153
|
}
|
|
154
154
|
return String.fromCharCode(n);
|
|
155
155
|
}
|
|
@@ -263,7 +263,7 @@ export function getBits(d: Decimal) {
|
|
|
263
263
|
// export function makeRangeStepFunction(step: Decimal, last: Decimal) {
|
|
264
264
|
// const stepComparedWithZero = step.cmp(get_Zero);
|
|
265
265
|
// if (stepComparedWithZero === 0) {
|
|
266
|
-
// throw new
|
|
266
|
+
// throw new Exception("The step of a range cannot be zero");
|
|
267
267
|
// }
|
|
268
268
|
// const stepGreaterThanZero = stepComparedWithZero > 0;
|
|
269
269
|
// return (x: Decimal) => {
|
package/Double.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FSharpRef } from "./Types.
|
|
1
|
+
import { FSharpRef } from "./Types.ts";
|
|
2
|
+
import { Exception } from "./Util.ts";
|
|
2
3
|
|
|
3
4
|
export function tryParse(str: string, defValue: FSharpRef<number>): boolean {
|
|
4
5
|
// TODO: test if value is valid and in range
|
|
@@ -17,7 +18,7 @@ export function parse(str: string): number {
|
|
|
17
18
|
if (tryParse(str, defValue)) {
|
|
18
19
|
return defValue.contents;
|
|
19
20
|
} else {
|
|
20
|
-
throw new
|
|
21
|
+
throw new Exception(`The input string ${str} was not in a correct format.`);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
|
package/Encoding.ts
CHANGED
package/Event.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IObservable, subscribe } from "./Observable.
|
|
2
|
-
import { Option, some, value } from "./Option.
|
|
3
|
-
import { FSharpChoice$2_$union, Choice_tryValueIfChoice1Of2, Choice_tryValueIfChoice2Of2 } from "./Choice.
|
|
1
|
+
import { IObservable, subscribe } from "./Observable.ts";
|
|
2
|
+
import { Option, some, value } from "./Option.ts";
|
|
3
|
+
import { FSharpChoice$2_$union, Choice_tryValueIfChoice1Of2, Choice_tryValueIfChoice2Of2 } from "./Choice.ts";
|
|
4
4
|
|
|
5
5
|
export type Handler<T> = (sender: any, x: T) => void;
|
|
6
6
|
|
package/FSharp.Collections.ts
CHANGED
|
@@ -1,34 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
1
|
+
|
|
2
|
+
import { int32 } from "./Int32.ts";
|
|
3
|
+
import { compare, IComparer, physicalHash, equals as equals_1, structuralHash, IEqualityComparer } from "./Util.ts";
|
|
4
|
+
|
|
5
|
+
export function HashIdentity_FromFunctions<T>(hasher: ((arg0: T) => int32), equals: ((arg0: T, arg1: T) => boolean)): IEqualityComparer<T> {
|
|
6
|
+
return {
|
|
7
|
+
GetHashCode(x: T): int32 {
|
|
8
|
+
return hasher(x) | 0;
|
|
9
|
+
},
|
|
10
|
+
Equals(x_1: T, y: T): boolean {
|
|
11
|
+
return (x_1 == null) ? (y == null) : ((y == null) ? false : equals(x_1, y));
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function HashIdentity_Structural<T>(): IEqualityComparer<T> {
|
|
17
|
+
return {
|
|
18
|
+
GetHashCode(x: T): int32 {
|
|
19
|
+
return structuralHash(x) | 0;
|
|
20
|
+
},
|
|
21
|
+
Equals(x_1: T, y: T): boolean {
|
|
22
|
+
return equals_1(x_1, y);
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function HashIdentity_Reference<T>(): IEqualityComparer<T> {
|
|
28
|
+
return {
|
|
29
|
+
GetHashCode(x: T): int32 {
|
|
30
|
+
return physicalHash(x) | 0;
|
|
31
|
+
},
|
|
32
|
+
Equals(x_1: T, y: T): boolean {
|
|
33
|
+
return equals_1(x_1, y);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function ComparisonIdentity_FromFunction<T>(comparer: ((arg0: T, arg1: T) => int32)): IComparer<T> {
|
|
39
|
+
return {
|
|
40
|
+
Compare(x: T, y: T): int32 {
|
|
41
|
+
return ((x == null) ? ((y == null) ? 0 : -1) : ((y == null) ? 1 : comparer(x, y))) | 0;
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function ComparisonIdentity_Structural<T>(): IComparer<T> {
|
|
47
|
+
return {
|
|
48
|
+
Compare(x: T, y: T): int32 {
|
|
49
|
+
return compare(x, y) | 0;
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
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
|
-
|
|
1
|
+
|
|
2
|
+
import { class_type, TypeInfo } from "./Reflection.ts";
|
|
3
|
+
import { addRangeInPlace } from "./Array.ts";
|
|
4
|
+
import { toList } from "./Seq.ts";
|
|
5
|
+
import { FSharpList } from "./List.ts";
|
|
6
|
+
|
|
7
|
+
export class ListCollector$1<T> {
|
|
8
|
+
readonly collector: T[];
|
|
9
|
+
constructor() {
|
|
10
|
+
this.collector = [];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function ListCollector$1_$reflection(gen0: TypeInfo): TypeInfo {
|
|
15
|
+
return class_type("Microsoft.FSharp.Core.CompilerServices.ListCollector`1", [gen0], ListCollector$1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function ListCollector$1_$ctor<T>(): ListCollector$1<T> {
|
|
19
|
+
return new ListCollector$1();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function ListCollector$1__Add_2B595<T>(this$: ListCollector$1<T>, value: T): void {
|
|
23
|
+
void (this$.collector.push(value));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function ListCollector$1__AddMany_BB573A<T>(this$: ListCollector$1<T>, values: Iterable<T>): void {
|
|
27
|
+
addRangeInPlace(values, this$.collector);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function ListCollector$1__AddManyAndClose_BB573A<T>(this$: ListCollector$1<T>, values: Iterable<T>): FSharpList<T> {
|
|
31
|
+
addRangeInPlace(values, this$.collector);
|
|
32
|
+
return toList<T>(this$.collector);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function ListCollector$1__Close<T>(this$: ListCollector$1<T>): FSharpList<T> {
|
|
36
|
+
return toList<T>(this$.collector);
|
|
37
|
+
}
|
|
38
|
+
|