@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.
Files changed (55) hide show
  1. package/Array.ts +1385 -1378
  2. package/Async.ts +13 -12
  3. package/AsyncBuilder.ts +10 -11
  4. package/BigInt.ts +6 -6
  5. package/BitConverter.ts +3 -3
  6. package/Boolean.ts +3 -2
  7. package/CHANGELOG.md +12 -0
  8. package/Char.ts +38 -35
  9. package/Choice.ts +326 -301
  10. package/CollectionUtil.ts +4 -4
  11. package/Date.ts +67 -62
  12. package/DateOffset.ts +48 -57
  13. package/DateOnly.ts +8 -8
  14. package/Decimal.ts +9 -9
  15. package/Double.ts +3 -2
  16. package/Encoding.ts +1 -1
  17. package/Event.ts +3 -3
  18. package/FSharp.Collections.ts +53 -34
  19. package/FSharp.Core.CompilerServices.ts +38 -37
  20. package/FSharp.Core.ts +186 -185
  21. package/Global.ts +80 -37
  22. package/Guid.ts +7 -6
  23. package/Int32.ts +20 -17
  24. package/List.ts +1429 -1417
  25. package/Long.ts +6 -5
  26. package/MailboxProcessor.ts +8 -7
  27. package/Map.ts +1550 -1552
  28. package/MapUtil.ts +5 -5
  29. package/MutableMap.ts +358 -345
  30. package/MutableSet.ts +250 -249
  31. package/Native.ts +19 -11
  32. package/Numeric.ts +1 -1
  33. package/Observable.ts +3 -3
  34. package/Option.ts +10 -4
  35. package/Random.ts +196 -194
  36. package/Range.ts +57 -56
  37. package/Reflection.ts +73 -40
  38. package/RegExp.ts +5 -3
  39. package/Result.ts +201 -196
  40. package/Seq.ts +1517 -1525
  41. package/Seq2.ts +130 -129
  42. package/Set.ts +1955 -1955
  43. package/String.ts +41 -38
  44. package/System.Collections.Generic.ts +401 -380
  45. package/System.Text.ts +204 -203
  46. package/System.ts +366 -0
  47. package/TimeOnly.ts +10 -10
  48. package/TimeSpan.ts +11 -11
  49. package/Timer.ts +2 -2
  50. package/Types.ts +1 -19
  51. package/Uri.ts +13 -10
  52. package/Util.ts +77 -21
  53. package/package.json +22 -22
  54. package/tsconfig.json +18 -5
  55. package/SystemException.ts +0 -7
package/DateOnly.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { FSharpRef } from "./Types.js";
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.js";
3
- import { IDateTime, DateKind, padWithZeros } from "./Util.js";
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, DateKind.UTC);
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 = DateKind.Unspecified) {
61
- return DateTime(d.getTime() + time + (kind !== DateKind.UTC ? d.getTimezoneOffset() : 0) * 60000, 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 Error("Custom formats are not supported");
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 Error(`String '${str}' was not recognized as a valid DateOnly.`);
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.js";
3
- import { FSharpRef } from "./Types.js";
4
- import { combineHashCodes } from "./Util.js";
5
- import { int8, uint8, int16, uint16, int32, uint32, float16, float32, float64 } from "./Int32.js";
6
- import { fromDecimal, int64, uint64, int128, uint128, nativeint, unativeint } from "./BigInt.js";
7
- import * as bigInt from "./BigInt.js";
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 Error(`The input string ${str} was not in a correct format.`);
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 Error("Value was either too large or too small for a character.");
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 Error("The step of a range cannot be zero");
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.js";
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 Error(`The input string ${str} was not in a correct format.`);
21
+ throw new Exception(`The input string ${str} was not in a correct format.`);
21
22
  }
22
23
  }
23
24
 
package/Encoding.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { uint8 } from "./Int32.js";
1
+ import { uint8 } from "./Int32.ts";
2
2
 
3
3
  const littleEndian = true;
4
4
 
package/Event.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { IObservable, subscribe } from "./Observable.js";
2
- import { Option, some, value } from "./Option.js";
3
- import { FSharpChoice$2_$union, Choice_tryValueIfChoice1Of2, Choice_tryValueIfChoice2Of2 } from "./Choice.js";
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
 
@@ -1,34 +1,53 @@
1
- import { int32 } from "./Int32.js";
2
- import { compare, IComparer, physicalHash, equals, structuralHash, IEqualityComparer } from "./Util.js";
3
-
4
- export function HashIdentity_FromFunctions<T>(hash: ((arg0: T) => int32), eq: ((arg0: T, arg1: T) => boolean)): IEqualityComparer<T> {
5
- return {
6
- Equals(x: T, y: T): boolean {
7
- return eq(x, y);
8
- },
9
- GetHashCode(x_1: T): int32 {
10
- return hash(x_1) | 0;
11
- },
12
- };
13
- }
14
-
15
- export function HashIdentity_Structural<T>(): IEqualityComparer<T> {
16
- return HashIdentity_FromFunctions<T>((obj: T): int32 => (structuralHash(obj) | 0), equals);
17
- }
18
-
19
- export function HashIdentity_Reference<T>(): IEqualityComparer<T> {
20
- return HashIdentity_FromFunctions<T>((obj: T): int32 => (physicalHash(obj) | 0), (e: T, e_1: T): boolean => (e === e_1));
21
- }
22
-
23
- export function ComparisonIdentity_FromFunction<T>(comparer: ((arg0: T, arg1: T) => int32)): IComparer<T> {
24
- return {
25
- Compare(x: T, y: T): int32 {
26
- return comparer(x, y) | 0;
27
- },
28
- };
29
- }
30
-
31
- export function ComparisonIdentity_Structural<T>(): IComparer<T> {
32
- return ComparisonIdentity_FromFunction<T>((e: T, e_1: T): int32 => (compare(e, e_1) | 0));
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
- import { class_type, TypeInfo } from "./Reflection.js";
2
- import { addRangeInPlace } from "./Array.js";
3
- import { toList } from "./Seq.js";
4
- import { FSharpList } from "./List.js";
5
-
6
- export class ListCollector$1<T> {
7
- readonly collector: T[];
8
- constructor() {
9
- this.collector = [];
10
- }
11
- }
12
-
13
- export function ListCollector$1_$reflection(gen0: TypeInfo): TypeInfo {
14
- return class_type("Microsoft.FSharp.Core.CompilerServices.ListCollector`1", [gen0], ListCollector$1);
15
- }
16
-
17
- export function ListCollector$1_$ctor<T>(): ListCollector$1<T> {
18
- return new ListCollector$1();
19
- }
20
-
21
- export function ListCollector$1__Add_2B595<T>(this$: ListCollector$1<T>, value: T): void {
22
- void (this$.collector.push(value));
23
- }
24
-
25
- export function ListCollector$1__AddMany_BB573A<T>(this$: ListCollector$1<T>, values: Iterable<T>): void {
26
- addRangeInPlace(values, this$.collector);
27
- }
28
-
29
- export function ListCollector$1__AddManyAndClose_BB573A<T>(this$: ListCollector$1<T>, values: Iterable<T>): FSharpList<T> {
30
- addRangeInPlace(values, this$.collector);
31
- return toList<T>(this$.collector);
32
- }
33
-
34
- export function ListCollector$1__Close<T>(this$: ListCollector$1<T>): FSharpList<T> {
35
- return toList<T>(this$.collector);
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
+