@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/Seq2.ts CHANGED
@@ -1,129 +1,130 @@
1
- import { toList, toArray, map, filter, delay } from "./Seq.js";
2
- import { HashSet } from "./MutableSet.js";
3
- import { defaultOf, IDisposable, disposeSafe, IEnumerator, getEnumerator, IMap, IEqualityComparer, ISet } from "./Util.js";
4
- import { addToDict, getItemFromDict, tryGetValue, addToSet } from "./MapUtil.js";
5
- import { Dictionary } from "./MutableMap.js";
6
- import { int32 } from "./Int32.js";
7
- import { FSharpRef } from "./Types.js";
8
- import { FSharpList } from "./List.js";
9
-
10
- export function distinct<T>(xs: Iterable<T>, comparer: IEqualityComparer<T>): Iterable<T> {
11
- return delay<T>((): Iterable<T> => {
12
- const hashSet: ISet<T> = new HashSet<T>([], comparer);
13
- return filter<T>((x: T): boolean => addToSet(x, hashSet), xs);
14
- });
15
- }
16
-
17
- export function distinctBy<T, Key>(projection: ((arg0: T) => Key), xs: Iterable<T>, comparer: IEqualityComparer<Key>): Iterable<T> {
18
- return delay<T>((): Iterable<T> => {
19
- const hashSet: ISet<Key> = new HashSet<Key>([], comparer);
20
- return filter<T>((x: T): boolean => addToSet(projection(x), hashSet), xs);
21
- });
22
- }
23
-
24
- export function except<T>(itemsToExclude: Iterable<T>, xs: Iterable<T>, comparer: IEqualityComparer<T>): Iterable<T> {
25
- return delay<T>((): Iterable<T> => {
26
- const hashSet: ISet<T> = new HashSet<T>(itemsToExclude, comparer);
27
- return filter<T>((x: T): boolean => addToSet(x, hashSet), xs);
28
- });
29
- }
30
-
31
- export function countBy<T, Key>(projection: ((arg0: T) => Key), xs: Iterable<T>, comparer: IEqualityComparer<Key>): Iterable<[Key, int32]> {
32
- return delay<[Key, int32]>((): Iterable<[Key, int32]> => {
33
- const dict: IMap<Key, int32> = new Dictionary<Key, int32>([], comparer);
34
- const keys: Key[] = [];
35
- const enumerator: IEnumerator<T> = getEnumerator(xs);
36
- try {
37
- while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
38
- const key: Key = projection(enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]());
39
- let matchValue: [boolean, int32];
40
- let outArg = 0;
41
- matchValue = ([tryGetValue(dict, key, new FSharpRef<int32>((): int32 => (outArg | 0), (v: int32): void => {
42
- outArg = (v | 0);
43
- })), outArg] as [boolean, int32]);
44
- if (matchValue[0]) {
45
- dict.set(key, matchValue[1] + 1);
46
- }
47
- else {
48
- dict.set(key, 1);
49
- void (keys.push(key));
50
- }
51
- }
52
- }
53
- finally {
54
- disposeSafe(enumerator as IDisposable);
55
- }
56
- return map<Key, [Key, int32]>((key_1: Key): [Key, int32] => ([key_1, getItemFromDict(dict, key_1)] as [Key, int32]), keys);
57
- });
58
- }
59
-
60
- export function groupBy<T, Key>(projection: ((arg0: T) => Key), xs: Iterable<T>, comparer: IEqualityComparer<Key>): Iterable<[Key, Iterable<T>]> {
61
- return delay<[Key, Iterable<T>]>((): Iterable<[Key, Iterable<T>]> => {
62
- const dict: IMap<Key, T[]> = new Dictionary<Key, T[]>([], comparer);
63
- const keys: Key[] = [];
64
- const enumerator: IEnumerator<T> = getEnumerator(xs);
65
- try {
66
- while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
67
- const x: T = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
68
- const key: Key = projection(x);
69
- let matchValue: [boolean, T[]];
70
- let outArg: T[] = defaultOf();
71
- matchValue = ([tryGetValue(dict, key, new FSharpRef<T[]>((): T[] => outArg, (v: T[]): void => {
72
- outArg = v;
73
- })), outArg] as [boolean, T[]]);
74
- if (matchValue[0]) {
75
- void (matchValue[1].push(x));
76
- }
77
- else {
78
- addToDict(dict, key, [x]);
79
- void (keys.push(key));
80
- }
81
- }
82
- }
83
- finally {
84
- disposeSafe(enumerator as IDisposable);
85
- }
86
- return map<Key, [Key, Iterable<T>]>((key_1: Key): [Key, Iterable<T>] => ([key_1, getItemFromDict(dict, key_1)] as [Key, Iterable<T>]), keys);
87
- });
88
- }
89
-
90
- export function Array_distinct<T>(xs: T[], comparer: IEqualityComparer<T>): T[] {
91
- return toArray<T>(distinct<T>(xs, comparer));
92
- }
93
-
94
- export function Array_distinctBy<T, Key>(projection: ((arg0: T) => Key), xs: T[], comparer: IEqualityComparer<Key>): T[] {
95
- return toArray<T>(distinctBy<T, Key>(projection, xs, comparer));
96
- }
97
-
98
- export function Array_except<T>(itemsToExclude: Iterable<T>, xs: T[], comparer: IEqualityComparer<T>): T[] {
99
- return toArray<T>(except<T>(itemsToExclude, xs, comparer));
100
- }
101
-
102
- export function Array_countBy<T, Key>(projection: ((arg0: T) => Key), xs: T[], comparer: IEqualityComparer<Key>): [Key, int32][] {
103
- return toArray<[Key, int32]>(countBy<T, Key>(projection, xs, comparer));
104
- }
105
-
106
- export function Array_groupBy<T, Key>(projection: ((arg0: T) => Key), xs: T[], comparer: IEqualityComparer<Key>): [Key, T[]][] {
107
- return toArray<[Key, T[]]>(map<[Key, Iterable<T>], [Key, T[]]>((tupledArg: [Key, Iterable<T>]): [Key, T[]] => ([tupledArg[0], toArray<T>(tupledArg[1])] as [Key, T[]]), groupBy<T, Key>(projection, xs, comparer)));
108
- }
109
-
110
- export function List_distinct<T>(xs: FSharpList<T>, comparer: IEqualityComparer<T>): FSharpList<T> {
111
- return toList<T>(distinct<T>(xs, comparer));
112
- }
113
-
114
- export function List_distinctBy<T, Key>(projection: ((arg0: T) => Key), xs: FSharpList<T>, comparer: IEqualityComparer<Key>): FSharpList<T> {
115
- return toList<T>(distinctBy<T, Key>(projection, xs, comparer));
116
- }
117
-
118
- export function List_except<T>(itemsToExclude: Iterable<T>, xs: FSharpList<T>, comparer: IEqualityComparer<T>): FSharpList<T> {
119
- return toList<T>(except<T>(itemsToExclude, xs, comparer));
120
- }
121
-
122
- export function List_countBy<T, Key>(projection: ((arg0: T) => Key), xs: FSharpList<T>, comparer: IEqualityComparer<Key>): FSharpList<[Key, int32]> {
123
- return toList<[Key, int32]>(countBy<T, Key>(projection, xs, comparer));
124
- }
125
-
126
- export function List_groupBy<T, Key>(projection: ((arg0: T) => Key), xs: FSharpList<T>, comparer: IEqualityComparer<Key>): FSharpList<[Key, FSharpList<T>]> {
127
- return toList<[Key, FSharpList<T>]>(map<[Key, Iterable<T>], [Key, FSharpList<T>]>((tupledArg: [Key, Iterable<T>]): [Key, FSharpList<T>] => ([tupledArg[0], toList<T>(tupledArg[1])] as [Key, FSharpList<T>]), groupBy<T, Key>(projection, xs, comparer)));
128
- }
129
-
1
+
2
+ import { toList, toArray, map, filter, delay } from "./Seq.ts";
3
+ import { HashSet } from "./MutableSet.ts";
4
+ import { MutableArray, defaultOf, IDisposable, disposeSafe, IEnumerator, getEnumerator, IMap, IEqualityComparer, ISet } from "./Util.ts";
5
+ import { addToDict, getItemFromDict, tryGetValue, addToSet } from "./MapUtil.ts";
6
+ import { Dictionary } from "./MutableMap.ts";
7
+ import { int32 } from "./Int32.ts";
8
+ import { FSharpRef } from "./Types.ts";
9
+ import { FSharpList } from "./List.ts";
10
+
11
+ export function distinct<T>(xs: Iterable<T>, comparer: IEqualityComparer<T>): Iterable<T> {
12
+ return delay<T>((): Iterable<T> => {
13
+ const hashSet: ISet<T> = new HashSet<T>([], comparer);
14
+ return filter<T>((x: T): boolean => addToSet(x, hashSet), xs);
15
+ });
16
+ }
17
+
18
+ export function distinctBy<T, Key>(projection: ((arg0: T) => Key), xs: Iterable<T>, comparer: IEqualityComparer<Key>): Iterable<T> {
19
+ return delay<T>((): Iterable<T> => {
20
+ const hashSet: ISet<Key> = new HashSet<Key>([], comparer);
21
+ return filter<T>((x: T): boolean => addToSet(projection(x), hashSet), xs);
22
+ });
23
+ }
24
+
25
+ export function except<T>(itemsToExclude: Iterable<T>, xs: Iterable<T>, comparer: IEqualityComparer<T>): Iterable<T> {
26
+ return delay<T>((): Iterable<T> => {
27
+ const hashSet: ISet<T> = new HashSet<T>(itemsToExclude, comparer);
28
+ return filter<T>((x: T): boolean => addToSet(x, hashSet), xs);
29
+ });
30
+ }
31
+
32
+ export function countBy<T, Key>(projection: ((arg0: T) => Key), xs: Iterable<T>, comparer: IEqualityComparer<Key>): Iterable<[Key, int32]> {
33
+ return delay<[Key, int32]>((): Iterable<[Key, int32]> => {
34
+ const dict: IMap<Key, int32> = new Dictionary<Key, int32>([], comparer);
35
+ const keys: Key[] = [];
36
+ const enumerator: IEnumerator<T> = getEnumerator(xs);
37
+ try {
38
+ while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
39
+ const key: Key = projection(enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]());
40
+ let matchValue: [boolean, int32];
41
+ let outArg = 0;
42
+ matchValue = ([tryGetValue(dict, key, new FSharpRef<int32>((): int32 => (outArg | 0), (v: int32): void => {
43
+ outArg = (v | 0);
44
+ })), outArg] as [boolean, int32]);
45
+ if (matchValue[0]) {
46
+ dict.set(key, matchValue[1] + 1);
47
+ }
48
+ else {
49
+ dict.set(key, 1);
50
+ void (keys.push(key));
51
+ }
52
+ }
53
+ }
54
+ finally {
55
+ disposeSafe(enumerator as IDisposable);
56
+ }
57
+ return map<Key, [Key, int32]>((key_1: Key): [Key, int32] => ([key_1, getItemFromDict(dict, key_1)] as [Key, int32]), keys);
58
+ });
59
+ }
60
+
61
+ export function groupBy<T, Key>(projection: ((arg0: T) => Key), xs: Iterable<T>, comparer: IEqualityComparer<Key>): Iterable<[Key, Iterable<T>]> {
62
+ return delay<[Key, Iterable<T>]>((): Iterable<[Key, Iterable<T>]> => {
63
+ const dict: IMap<Key, T[]> = new Dictionary<Key, T[]>([], comparer);
64
+ const keys: Key[] = [];
65
+ const enumerator: IEnumerator<T> = getEnumerator(xs);
66
+ try {
67
+ while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
68
+ const x: T = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
69
+ const key: Key = projection(x);
70
+ let matchValue: [boolean, T[]];
71
+ let outArg: T[] = defaultOf();
72
+ matchValue = ([tryGetValue(dict, key, new FSharpRef<T[]>((): T[] => outArg, (v: T[]): void => {
73
+ outArg = v;
74
+ })), outArg] as [boolean, T[]]);
75
+ if (matchValue[0]) {
76
+ void (matchValue[1].push(x));
77
+ }
78
+ else {
79
+ addToDict(dict, key, [x]);
80
+ void (keys.push(key));
81
+ }
82
+ }
83
+ }
84
+ finally {
85
+ disposeSafe(enumerator as IDisposable);
86
+ }
87
+ return map<Key, [Key, Iterable<T>]>((key_1: Key): [Key, Iterable<T>] => ([key_1, getItemFromDict(dict, key_1)] as [Key, Iterable<T>]), keys);
88
+ });
89
+ }
90
+
91
+ export function Array_distinct<T>(xs: MutableArray<T>, comparer: IEqualityComparer<T>): MutableArray<T> {
92
+ return toArray<T>(distinct<T>(xs, comparer));
93
+ }
94
+
95
+ export function Array_distinctBy<T, Key>(projection: ((arg0: T) => Key), xs: MutableArray<T>, comparer: IEqualityComparer<Key>): MutableArray<T> {
96
+ return toArray<T>(distinctBy<T, Key>(projection, xs, comparer));
97
+ }
98
+
99
+ export function Array_except<T>(itemsToExclude: Iterable<T>, xs: MutableArray<T>, comparer: IEqualityComparer<T>): MutableArray<T> {
100
+ return toArray<T>(except<T>(itemsToExclude, xs, comparer));
101
+ }
102
+
103
+ export function Array_countBy<T, Key>(projection: ((arg0: T) => Key), xs: MutableArray<T>, comparer: IEqualityComparer<Key>): MutableArray<[Key, int32]> {
104
+ return toArray<[Key, int32]>(countBy<T, Key>(projection, xs, comparer));
105
+ }
106
+
107
+ export function Array_groupBy<T, Key>(projection: ((arg0: T) => Key), xs: MutableArray<T>, comparer: IEqualityComparer<Key>): MutableArray<[Key, MutableArray<T>]> {
108
+ return toArray<[Key, MutableArray<T>]>(map<[Key, Iterable<T>], [Key, MutableArray<T>]>((tupledArg: [Key, Iterable<T>]): [Key, MutableArray<T>] => ([tupledArg[0], toArray<T>(tupledArg[1])] as [Key, MutableArray<T>]), groupBy<T, Key>(projection, xs, comparer)));
109
+ }
110
+
111
+ export function List_distinct<T>(xs: FSharpList<T>, comparer: IEqualityComparer<T>): FSharpList<T> {
112
+ return toList<T>(distinct<T>(xs, comparer));
113
+ }
114
+
115
+ export function List_distinctBy<T, Key>(projection: ((arg0: T) => Key), xs: FSharpList<T>, comparer: IEqualityComparer<Key>): FSharpList<T> {
116
+ return toList<T>(distinctBy<T, Key>(projection, xs, comparer));
117
+ }
118
+
119
+ export function List_except<T>(itemsToExclude: Iterable<T>, xs: FSharpList<T>, comparer: IEqualityComparer<T>): FSharpList<T> {
120
+ return toList<T>(except<T>(itemsToExclude, xs, comparer));
121
+ }
122
+
123
+ export function List_countBy<T, Key>(projection: ((arg0: T) => Key), xs: FSharpList<T>, comparer: IEqualityComparer<Key>): FSharpList<[Key, int32]> {
124
+ return toList<[Key, int32]>(countBy<T, Key>(projection, xs, comparer));
125
+ }
126
+
127
+ export function List_groupBy<T, Key>(projection: ((arg0: T) => Key), xs: FSharpList<T>, comparer: IEqualityComparer<Key>): FSharpList<[Key, FSharpList<T>]> {
128
+ return toList<[Key, FSharpList<T>]>(map<[Key, Iterable<T>], [Key, FSharpList<T>]>((tupledArg: [Key, Iterable<T>]): [Key, FSharpList<T>] => ([tupledArg[0], toList<T>(tupledArg[1])] as [Key, FSharpList<T>]), groupBy<T, Key>(projection, xs, comparer)));
129
+ }
130
+