@fable-org/fable-library-ts 2.0.0-beta.4 → 2.0.0-beta.6

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 +253 -247
  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 +14 -0
  8. package/Char.ts +38 -35
  9. package/Choice.ts +36 -12
  10. package/CollectionUtil.ts +4 -4
  11. package/Date.ts +67 -62
  12. package/DateOffset.ts +47 -56
  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 +31 -13
  19. package/FSharp.Core.CompilerServices.ts +4 -4
  20. package/FSharp.Core.ts +34 -34
  21. package/Global.ts +44 -2
  22. package/Guid.ts +7 -6
  23. package/Int32.ts +20 -17
  24. package/List.ts +57 -56
  25. package/Long.ts +6 -5
  26. package/MailboxProcessor.ts +8 -7
  27. package/Map.ts +67 -65
  28. package/MapUtil.ts +5 -5
  29. package/MutableMap.ts +32 -20
  30. package/MutableSet.ts +12 -12
  31. package/Native.ts +3 -3
  32. package/Numeric.ts +1 -1
  33. package/Observable.ts +3 -3
  34. package/Option.ts +3 -3
  35. package/Random.ts +34 -34
  36. package/Range.ts +7 -7
  37. package/Reflection.ts +73 -40
  38. package/RegExp.ts +5 -3
  39. package/Result.ts +31 -27
  40. package/Seq.ts +56 -54
  41. package/Seq2.ts +14 -14
  42. package/Set.ts +81 -80
  43. package/String.ts +41 -38
  44. package/System.Collections.Generic.ts +45 -25
  45. package/System.Text.ts +12 -12
  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 +74 -26
  53. package/package.json +1 -1
  54. package/tsconfig.json +18 -5
  55. package/SystemException.ts +0 -7
package/Result.ts CHANGED
@@ -1,10 +1,10 @@
1
1
 
2
- import { Union } from "./Types.js";
3
- import { union_type, TypeInfo } from "./Reflection.js";
4
- import { int32 } from "./Int32.js";
5
- import { equals } from "./Util.js";
6
- import { FSharpList, empty, singleton } from "./List.js";
7
- import { Option, some } from "./Option.js";
2
+ import { Union } from "./Types.ts";
3
+ import { union_type, TypeInfo } from "./Reflection.ts";
4
+ import { int32 } from "./Int32.ts";
5
+ import { MutableArray, equals } from "./Util.ts";
6
+ import { FSharpList, empty, singleton } from "./List.ts";
7
+ import { Option, some } from "./Option.ts";
8
8
 
9
9
  export type FSharpResult$2_$union<T, TError> =
10
10
  | FSharpResult$2<T, TError, 0>
@@ -24,9 +24,13 @@ export function FSharpResult$2_Error$<T, TError>(ErrorValue: TError) {
24
24
  }
25
25
 
26
26
  export class FSharpResult$2<T, TError, Tag extends keyof FSharpResult$2_$cases<T, TError>> extends Union<Tag, FSharpResult$2_$cases<T, TError>[Tag][0]> {
27
- constructor(readonly tag: Tag, readonly fields: FSharpResult$2_$cases<T, TError>[Tag][1]) {
27
+ constructor(tag: Tag, fields: FSharpResult$2_$cases<T, TError>[Tag][1]) {
28
28
  super();
29
+ this.tag = tag;
30
+ this.fields = fields;
29
31
  }
32
+ readonly tag: Tag;
33
+ readonly fields: FSharpResult$2_$cases<T, TError>[Tag][1];
30
34
  cases() {
31
35
  return ["Ok", "Error"];
32
36
  }
@@ -38,28 +42,28 @@ export function FSharpResult$2_$reflection(gen0: TypeInfo, gen1: TypeInfo): Type
38
42
 
39
43
  export function Result_Map<a, b, c>(mapping: ((arg0: a) => b), result: FSharpResult$2_$union<a, c>): FSharpResult$2_$union<b, c> {
40
44
  if ((result.tag as int32) === /* Ok */ 0) {
41
- return FSharpResult$2_Ok<b, c>(mapping(result.fields[0] as any));
45
+ return FSharpResult$2_Ok<b, c>(mapping(result.fields[0] as a));
42
46
  }
43
47
  else {
44
- return FSharpResult$2_Error$<b, c>(result.fields[0] as any);
48
+ return FSharpResult$2_Error$<b, c>(result.fields[0] as c);
45
49
  }
46
50
  }
47
51
 
48
52
  export function Result_MapError<a, b, c>(mapping: ((arg0: a) => b), result: FSharpResult$2_$union<c, a>): FSharpResult$2_$union<c, b> {
49
53
  if ((result.tag as int32) === /* Ok */ 0) {
50
- return FSharpResult$2_Ok<c, b>(result.fields[0] as any);
54
+ return FSharpResult$2_Ok<c, b>(result.fields[0] as c);
51
55
  }
52
56
  else {
53
- return FSharpResult$2_Error$<c, b>(mapping(result.fields[0] as any));
57
+ return FSharpResult$2_Error$<c, b>(mapping(result.fields[0] as a));
54
58
  }
55
59
  }
56
60
 
57
61
  export function Result_Bind<a, b, c>(binder: ((arg0: a) => FSharpResult$2_$union<b, c>), result: FSharpResult$2_$union<a, c>): FSharpResult$2_$union<b, c> {
58
62
  if ((result.tag as int32) === /* Ok */ 0) {
59
- return binder(result.fields[0] as any);
63
+ return binder(result.fields[0] as a);
60
64
  }
61
65
  else {
62
- return FSharpResult$2_Error$<b, c>(result.fields[0] as any);
66
+ return FSharpResult$2_Error$<b, c>(result.fields[0] as c);
63
67
  }
64
68
  }
65
69
 
@@ -83,7 +87,7 @@ export function Result_IsError<a, b>(result: FSharpResult$2_$union<a, b>): boole
83
87
 
84
88
  export function Result_Contains<a, b>(value: a, result: FSharpResult$2_$union<a, b>): boolean {
85
89
  if ((result.tag as int32) === /* Ok */ 0) {
86
- return equals(result.fields[0] as any, value);
90
+ return equals(result.fields[0] as a, value);
87
91
  }
88
92
  else {
89
93
  return false;
@@ -101,7 +105,7 @@ export function Result_Count<a, b>(result: FSharpResult$2_$union<a, b>): int32 {
101
105
 
102
106
  export function Result_DefaultValue<a, b>(defaultValue: a, result: FSharpResult$2_$union<a, b>): a {
103
107
  if ((result.tag as int32) === /* Ok */ 0) {
104
- return result.fields[0] as any;
108
+ return result.fields[0] as a;
105
109
  }
106
110
  else {
107
111
  return defaultValue;
@@ -110,16 +114,16 @@ export function Result_DefaultValue<a, b>(defaultValue: a, result: FSharpResult$
110
114
 
111
115
  export function Result_DefaultWith<b, a>(defThunk: ((arg0: b) => a), result: FSharpResult$2_$union<a, b>): a {
112
116
  if ((result.tag as int32) === /* Ok */ 0) {
113
- return result.fields[0] as any;
117
+ return result.fields[0] as a;
114
118
  }
115
119
  else {
116
- return defThunk(result.fields[0] as any);
120
+ return defThunk(result.fields[0] as b);
117
121
  }
118
122
  }
119
123
 
120
124
  export function Result_Exists<a, b>(predicate: ((arg0: a) => boolean), result: FSharpResult$2_$union<a, b>): boolean {
121
125
  if ((result.tag as int32) === /* Ok */ 0) {
122
- return predicate(result.fields[0] as any);
126
+ return predicate(result.fields[0] as a);
123
127
  }
124
128
  else {
125
129
  return false;
@@ -128,7 +132,7 @@ export function Result_Exists<a, b>(predicate: ((arg0: a) => boolean), result: F
128
132
 
129
133
  export function Result_Fold<a, b, s>(folder: ((arg0: s, arg1: a) => s), state: s, result: FSharpResult$2_$union<a, b>): s {
130
134
  if ((result.tag as int32) === /* Ok */ 0) {
131
- return folder(state, result.fields[0] as any);
135
+ return folder(state, result.fields[0] as a);
132
136
  }
133
137
  else {
134
138
  return state;
@@ -137,7 +141,7 @@ export function Result_Fold<a, b, s>(folder: ((arg0: s, arg1: a) => s), state: s
137
141
 
138
142
  export function Result_FoldBack<a, b, s>(folder: ((arg0: a, arg1: s) => s), result: FSharpResult$2_$union<a, b>, state: s): s {
139
143
  if ((result.tag as int32) === /* Ok */ 0) {
140
- return folder(result.fields[0] as any, state);
144
+ return folder(result.fields[0] as a, state);
141
145
  }
142
146
  else {
143
147
  return state;
@@ -146,7 +150,7 @@ export function Result_FoldBack<a, b, s>(folder: ((arg0: a, arg1: s) => s), resu
146
150
 
147
151
  export function Result_ForAll<a, b>(predicate: ((arg0: a) => boolean), result: FSharpResult$2_$union<a, b>): boolean {
148
152
  if ((result.tag as int32) === /* Ok */ 0) {
149
- return predicate(result.fields[0] as any);
153
+ return predicate(result.fields[0] as a);
150
154
  }
151
155
  else {
152
156
  return true;
@@ -155,13 +159,13 @@ export function Result_ForAll<a, b>(predicate: ((arg0: a) => boolean), result: F
155
159
 
156
160
  export function Result_Iterate<a, b>(action: ((arg0: a) => void), result: FSharpResult$2_$union<a, b>): void {
157
161
  if ((result.tag as int32) === /* Ok */ 0) {
158
- action(result.fields[0] as any);
162
+ action(result.fields[0] as a);
159
163
  }
160
164
  }
161
165
 
162
- export function Result_ToArray<a, b>(result: FSharpResult$2_$union<a, b>): a[] {
166
+ export function Result_ToArray<a, b>(result: FSharpResult$2_$union<a, b>): MutableArray<a> {
163
167
  if ((result.tag as int32) === /* Ok */ 0) {
164
- return [result.fields[0] as any];
168
+ return [result.fields[0] as a];
165
169
  }
166
170
  else {
167
171
  return [];
@@ -170,7 +174,7 @@ export function Result_ToArray<a, b>(result: FSharpResult$2_$union<a, b>): a[] {
170
174
 
171
175
  export function Result_ToList<a, b>(result: FSharpResult$2_$union<a, b>): FSharpList<a> {
172
176
  if ((result.tag as int32) === /* Ok */ 0) {
173
- return singleton(result.fields[0] as any);
177
+ return singleton(result.fields[0] as a);
174
178
  }
175
179
  else {
176
180
  return empty<a>();
@@ -179,7 +183,7 @@ export function Result_ToList<a, b>(result: FSharpResult$2_$union<a, b>): FSharp
179
183
 
180
184
  export function Result_ToOption<a, b>(result: FSharpResult$2_$union<a, b>): Option<a> {
181
185
  if ((result.tag as int32) === /* Ok */ 0) {
182
- return some(result.fields[0] as any);
186
+ return some(result.fields[0] as a);
183
187
  }
184
188
  else {
185
189
  return undefined;
@@ -188,7 +192,7 @@ export function Result_ToOption<a, b>(result: FSharpResult$2_$union<a, b>): Opti
188
192
 
189
193
  export function Result_ToValueOption<a, b>(result: FSharpResult$2_$union<a, b>): Option<a> {
190
194
  if ((result.tag as int32) === /* Ok */ 0) {
191
- return some(result.fields[0] as any);
195
+ return some(result.fields[0] as a);
192
196
  }
193
197
  else {
194
198
  return undefined;
package/Seq.ts CHANGED
@@ -1,13 +1,15 @@
1
1
 
2
- import { IComparer, clear, isDisposable, IEqualityComparer, isArrayLike, Nullable, toIterator, IDisposable, disposeSafe, IEnumerator, getEnumerator } from "./Util.js";
3
- import { toString } from "./Types.js";
4
- import { class_type, TypeInfo } from "./Reflection.js";
5
- import { some, value as value_1, Option } from "./Option.js";
6
- import { Operators_Lock, Operators_NullArgCheck } from "./FSharp.Core.js";
7
- 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.js";
8
- 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.js";
9
- import { int32 } from "./Int32.js";
10
- import { SR_indexOutOfBounds } from "./Global.js";
2
+ import { InvalidOperationException_$ctor_Z721C83C5, NotSupportedException_$ctor_Z721C83C5 } from "./System.ts";
3
+ import { IComparer, clear, Exception, isDisposable, IEqualityComparer, isArrayLike, MutableArray, toIterator, IDisposable, disposeSafe, IEnumerator, getEnumerator } from "./Util.ts";
4
+ import { toString } from "./Types.ts";
5
+ import { class_type, TypeInfo } from "./Reflection.ts";
6
+ import { some, value as value_1, Option } from "./Option.ts";
7
+ import { KeyNotFoundException_$ctor_Z721C83C5 } from "./System.Collections.Generic.ts";
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";
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
+ import { int32 } from "./Int32.ts";
12
+ import { SR_indexOutOfBounds } from "./Global.ts";
11
13
 
12
14
  export const SR_enumerationAlreadyFinished = "Enumeration already finished.";
13
15
 
@@ -24,15 +26,15 @@ export const SR_notEnoughElements = "The input sequence has an insufficient numb
24
26
  export const SR_resetNotSupported = "Reset is not supported on this enumerator.";
25
27
 
26
28
  export function Enumerator_noReset<$a>(): $a {
27
- throw new Error(SR_resetNotSupported);
29
+ throw NotSupportedException_$ctor_Z721C83C5(SR_resetNotSupported);
28
30
  }
29
31
 
30
32
  export function Enumerator_notStarted<$a>(): $a {
31
- throw new Error(SR_enumerationNotStarted);
33
+ throw InvalidOperationException_$ctor_Z721C83C5(SR_enumerationNotStarted);
32
34
  }
33
35
 
34
36
  export function Enumerator_alreadyFinished<$a>(): $a {
35
- throw new Error(SR_enumerationAlreadyFinished);
37
+ throw InvalidOperationException_$ctor_Z721C83C5(SR_enumerationAlreadyFinished);
36
38
  }
37
39
 
38
40
  export class Enumerator_Seq<T> implements Iterable<T> {
@@ -96,7 +98,7 @@ export class Enumerator_FromFunctions$1<T> implements IEnumerator<T>, IDisposabl
96
98
  const _: Enumerator_FromFunctions$1<T> = this;
97
99
  return _.current();
98
100
  }
99
- "System.Collections.IEnumerator.get_Current"(): Nullable<any> {
101
+ "System.Collections.IEnumerator.get_Current"(): any {
100
102
  const _: Enumerator_FromFunctions$1<T> = this;
101
103
  return _.current();
102
104
  }
@@ -177,7 +179,7 @@ export function Enumerator_concat<T, U extends Iterable<T>>(sources: Iterable<U>
177
179
  else {
178
180
  let res: Option<boolean> = undefined;
179
181
  while (res == null) {
180
- let copyOfStruct: U;
182
+ let copyOfStruct: U = undefined as any;
181
183
  const outerOpt_1: Option<IEnumerator<U>> = outerOpt;
182
184
  const innerOpt_1: Option<IEnumerator<T>> = innerOpt;
183
185
  if (outerOpt_1 != null) {
@@ -322,7 +324,7 @@ export function Enumerator_unfold<State, T>(f: ((arg0: State) => Option<[T, Stat
322
324
  }
323
325
 
324
326
  export function indexNotFound<$a>(): $a {
325
- throw new Error(SR_keyNotFoundAlt);
327
+ throw KeyNotFoundException_$ctor_Z721C83C5(SR_keyNotFoundAlt);
326
328
  }
327
329
 
328
330
  export function mkSeq<T>(f: (() => IEnumerator<T>)): Iterable<T> {
@@ -353,11 +355,11 @@ export function singleton<T>(x: T): Iterable<T> {
353
355
  return delay<T>((): Iterable<T> => singleton_1<T>(x));
354
356
  }
355
357
 
356
- export function ofArray<T>(arr: T[]): Iterable<T> {
358
+ export function ofArray<T>(arr: MutableArray<T>): Iterable<T> {
357
359
  return arr;
358
360
  }
359
361
 
360
- export function toArray<T>(xs: Iterable<T>): T[] {
362
+ export function toArray<T>(xs: Iterable<T>): MutableArray<T> {
361
363
  if (xs instanceof FSharpList) {
362
364
  const a = xs as FSharpList<T>;
363
365
  return toArray_1<T>(a);
@@ -459,7 +461,7 @@ export function contains<T>(value: T, xs: Iterable<T>, comparer: IEqualityCompar
459
461
 
460
462
  export function enumerateFromFunctions<$a, $b>(create: (() => $a), moveNext: ((arg0: $a) => boolean), current: ((arg0: $a) => $b)): Iterable<$b> {
461
463
  return generate<$a, $b>(create, (x: $a): Option<$b> => (moveNext(x) ? some(current(x)) : undefined), (x_1: $a): void => {
462
- const matchValue: Nullable<any> = x_1;
464
+ const matchValue: any = x_1;
463
465
  if (isDisposable(matchValue)) {
464
466
  const id = matchValue as IDisposable;
465
467
  disposeSafe(id);
@@ -555,14 +557,14 @@ export function exactlyOne<T>(xs: Iterable<T>): T {
555
557
  if (e["System.Collections.IEnumerator.MoveNext"]()) {
556
558
  const v: T = e["System.Collections.Generic.IEnumerator`1.get_Current"]();
557
559
  if (e["System.Collections.IEnumerator.MoveNext"]()) {
558
- throw new Error((SR_inputSequenceTooLong + "\\nParameter name: ") + "source");
560
+ throw new Exception((SR_inputSequenceTooLong + "\\nParameter name: ") + "source");
559
561
  }
560
562
  else {
561
563
  return v;
562
564
  }
563
565
  }
564
566
  else {
565
- throw new Error((SR_inputSequenceEmpty + "\\nParameter name: ") + "source");
567
+ throw new Exception((SR_inputSequenceEmpty + "\\nParameter name: ") + "source");
566
568
  }
567
569
  }
568
570
  finally {
@@ -753,7 +755,7 @@ export function tryHead<T>(xs: Iterable<T>): Option<T> {
753
755
  export function head<T>(xs: Iterable<T>): T {
754
756
  const matchValue: Option<T> = tryHead<T>(xs);
755
757
  if (matchValue == null) {
756
- throw new Error((SR_inputSequenceEmpty + "\\nParameter name: ") + "source");
758
+ throw new Exception((SR_inputSequenceEmpty + "\\nParameter name: ") + "source");
757
759
  }
758
760
  else {
759
761
  return value_1(matchValue);
@@ -770,7 +772,7 @@ export function initializeInfinite<$a>(f: ((arg0: int32) => $a)): Iterable<$a> {
770
772
 
771
773
  export function isEmpty<T>(xs: Iterable<T>): boolean {
772
774
  if (isArrayLike(xs)) {
773
- const a: T[] = xs;
775
+ const a: MutableArray<T> = xs;
774
776
  return a.length === 0;
775
777
  }
776
778
  else if (xs instanceof FSharpList) {
@@ -825,7 +827,7 @@ export function tryItem<T>(index: int32, xs: Iterable<T>): Option<T> {
825
827
  export function item<T>(index: int32, xs: Iterable<T>): T {
826
828
  const matchValue: Option<T> = tryItem<T>(index, xs);
827
829
  if (matchValue == null) {
828
- throw new Error((SR_notEnoughElements + "\\nParameter name: ") + "index");
830
+ throw new Exception((SR_notEnoughElements + "\\nParameter name: ") + "index");
829
831
  }
830
832
  else {
831
833
  return value_1(matchValue);
@@ -885,7 +887,7 @@ export function tryLast<T>(xs: Iterable<T>): Option<T> {
885
887
  export function last<T>(xs: Iterable<T>): T {
886
888
  const matchValue: Option<T> = tryLast<T>(xs);
887
889
  if (matchValue == null) {
888
- throw new Error((SR_notEnoughElements + "\\nParameter name: ") + "source");
890
+ throw new Exception((SR_notEnoughElements + "\\nParameter name: ") + "source");
889
891
  }
890
892
  else {
891
893
  return value_1(matchValue);
@@ -894,7 +896,7 @@ export function last<T>(xs: Iterable<T>): T {
894
896
 
895
897
  export function length<T>(xs: Iterable<T>): int32 {
896
898
  if (isArrayLike(xs)) {
897
- const a: T[] = xs;
899
+ const a: MutableArray<T> = xs;
898
900
  return a.length | 0;
899
901
  }
900
902
  else if (xs instanceof FSharpList) {
@@ -1029,7 +1031,7 @@ export function cache<T>(source: Iterable<T>): Iterable<T> {
1029
1031
  return CachedSeq$1_$ctor_Z7A8347D4<T>((): void => {
1030
1032
  Operators_Lock<T[], void>(prefix, (): void => {
1031
1033
  clear(prefix);
1032
- let matchResult: int32, e: IEnumerator<T>;
1034
+ let matchResult: int32 = (undefined as any), e: IEnumerator<T> = (undefined as any);
1033
1035
  if (enumeratorR != null) {
1034
1036
  if (value_1(enumeratorR) != null) {
1035
1037
  matchResult = 0;
@@ -1094,12 +1096,12 @@ export function allPairs<T1, T2>(xs: Iterable<T1>, ys: Iterable<T2>): Iterable<[
1094
1096
  }
1095
1097
 
1096
1098
  export function mapFold<State, T, Result>(mapping: ((arg0: State, arg1: T) => [Result, State]), state: State, xs: Iterable<T>): [Iterable<Result>, State] {
1097
- const patternInput: [Result[], State] = mapFold_1<T, State, Result>(mapping, state, toArray<T>(xs));
1099
+ const patternInput: [MutableArray<Result>, State] = mapFold_1<T, State, Result>(mapping, state, toArray<T>(xs));
1098
1100
  return [readOnly<Result>(patternInput[0]), patternInput[1]] as [Iterable<Result>, State];
1099
1101
  }
1100
1102
 
1101
1103
  export function mapFoldBack<T, State, Result>(mapping: ((arg0: T, arg1: State) => [Result, State]), xs: Iterable<T>, state: State): [Iterable<Result>, State] {
1102
- const patternInput: [Result[], State] = mapFoldBack_1<T, State, Result>(mapping, toArray<T>(xs), state);
1104
+ const patternInput: [MutableArray<Result>, State] = mapFoldBack_1<T, State, Result>(mapping, toArray<T>(xs), state);
1103
1105
  return [readOnly<Result>(patternInput[0]), patternInput[1]] as [Iterable<Result>, State];
1104
1106
  }
1105
1107
 
@@ -1148,7 +1150,7 @@ export function reduce<T>(folder: ((arg0: T, arg1: T) => T), xs: Iterable<T>): T
1148
1150
  return loop(e["System.Collections.Generic.IEnumerator`1.get_Current"]());
1149
1151
  }
1150
1152
  else {
1151
- throw new Error(SR_inputSequenceEmpty);
1153
+ throw new Exception(SR_inputSequenceEmpty);
1152
1154
  }
1153
1155
  }
1154
1156
  finally {
@@ -1157,12 +1159,12 @@ export function reduce<T>(folder: ((arg0: T, arg1: T) => T), xs: Iterable<T>): T
1157
1159
  }
1158
1160
 
1159
1161
  export function reduceBack<T>(folder: ((arg0: T, arg1: T) => T), xs: Iterable<T>): T {
1160
- const arr: T[] = toArray<T>(xs);
1162
+ const arr: MutableArray<T> = toArray<T>(xs);
1161
1163
  if (arr.length > 0) {
1162
1164
  return arr.reduceRight(folder);
1163
1165
  }
1164
1166
  else {
1165
- throw new Error(SR_inputSequenceEmpty);
1167
+ throw new Exception(SR_inputSequenceEmpty);
1166
1168
  }
1167
1169
  }
1168
1170
 
@@ -1194,7 +1196,7 @@ export function skip<T>(count: int32, source: Iterable<T>): Iterable<T> {
1194
1196
  try {
1195
1197
  for (let _ = 1; _ <= count; _++) {
1196
1198
  if (!e["System.Collections.IEnumerator.MoveNext"]()) {
1197
- throw new Error((SR_notEnoughElements + "\\nParameter name: ") + "source");
1199
+ throw new Exception((SR_notEnoughElements + "\\nParameter name: ") + "source");
1198
1200
  }
1199
1201
  }
1200
1202
  return Enumerator_enumerateThenFinally<T>((): void => {
@@ -1230,7 +1232,7 @@ export function take<T>(count: int32, xs: Iterable<T>): Iterable<T> {
1230
1232
  return some(e["System.Collections.Generic.IEnumerator`1.get_Current"]());
1231
1233
  }
1232
1234
  else {
1233
- throw new Error((SR_notEnoughElements + "\\nParameter name: ") + "source");
1235
+ throw new Exception((SR_notEnoughElements + "\\nParameter name: ") + "source");
1234
1236
  }
1235
1237
  }
1236
1238
  else {
@@ -1273,21 +1275,21 @@ export function pairwise<T>(xs: Iterable<T>): Iterable<[T, T]> {
1273
1275
  return delay<[T, T]>((): Iterable<[T, T]> => ofArray<[T, T]>(pairwise_1<T>(toArray<T>(xs))));
1274
1276
  }
1275
1277
 
1276
- export function splitInto<T>(chunks: int32, xs: Iterable<T>): Iterable<T[]> {
1277
- return delay<T[]>((): Iterable<T[]> => ofArray<T[]>(splitInto_1<T>(chunks, toArray<T>(xs))));
1278
+ export function splitInto<T>(chunks: int32, xs: Iterable<T>): Iterable<MutableArray<T>> {
1279
+ return delay<MutableArray<T>>((): Iterable<MutableArray<T>> => ofArray<MutableArray<T>>(splitInto_1<T>(chunks, toArray<T>(xs))));
1278
1280
  }
1279
1281
 
1280
- export function windowed<T>(windowSize: int32, xs: Iterable<T>): Iterable<T[]> {
1281
- return delay<T[]>((): Iterable<T[]> => ofArray<T[]>(windowed_1<T>(windowSize, toArray<T>(xs))));
1282
+ export function windowed<T>(windowSize: int32, xs: Iterable<T>): Iterable<MutableArray<T>> {
1283
+ return delay<MutableArray<T>>((): Iterable<MutableArray<T>> => ofArray<MutableArray<T>>(windowed_1<T>(windowSize, toArray<T>(xs))));
1282
1284
  }
1283
1285
 
1284
1286
  export function transpose<$a extends Iterable<T>, T>(xss: Iterable<$a>): Iterable<Iterable<T>> {
1285
- return delay<Iterable<T>>((): Iterable<Iterable<T>> => ofArray<Iterable<T>>(map_1<T[], Iterable<T>>(ofArray, transpose_1<T>(map_1<$a, T[]>(toArray, toArray<$a>(xss))))));
1287
+ return delay<Iterable<T>>((): Iterable<Iterable<T>> => ofArray<Iterable<T>>(map_1<MutableArray<T>, Iterable<T>>(ofArray, transpose_1<T>(map_1<$a, MutableArray<T>>(toArray, toArray<$a>(xss))))));
1286
1288
  }
1287
1289
 
1288
1290
  export function sortWith<T>(comparer: ((arg0: T, arg1: T) => int32), xs: Iterable<T>): Iterable<T> {
1289
1291
  return delay<T>((): Iterable<T> => {
1290
- const arr: T[] = toArray<T>(xs);
1292
+ const arr: MutableArray<T> = toArray<T>(xs);
1291
1293
  arr.sort(comparer);
1292
1294
  return ofArray<T>(arr);
1293
1295
  });
@@ -1340,7 +1342,7 @@ export function average<T>(xs: Iterable<T>, averager: any): T {
1340
1342
  return averager.Add(acc, x);
1341
1343
  }, averager.GetZero(), xs);
1342
1344
  if (count === 0) {
1343
- throw new Error((SR_inputSequenceEmpty + "\\nParameter name: ") + "source");
1345
+ throw new Exception((SR_inputSequenceEmpty + "\\nParameter name: ") + "source");
1344
1346
  }
1345
1347
  else {
1346
1348
  return averager.DivideByInt(total, count);
@@ -1354,7 +1356,7 @@ export function averageBy<T, U>(f: ((arg0: T) => U), xs: Iterable<T>, averager:
1354
1356
  return averager.Add(acc, f(x));
1355
1357
  }, averager.GetZero(), xs);
1356
1358
  if (count === 0) {
1357
- throw new Error((SR_inputSequenceEmpty + "\\nParameter name: ") + "source");
1359
+ throw new Exception((SR_inputSequenceEmpty + "\\nParameter name: ") + "source");
1358
1360
  }
1359
1361
  else {
1360
1362
  return averager.DivideByInt(total, count);
@@ -1365,14 +1367,14 @@ export function permute<T>(f: ((arg0: int32) => int32), xs: Iterable<T>): Iterab
1365
1367
  return delay<T>((): Iterable<T> => ofArray<T>(permute_1<T>(f, toArray<T>(xs))));
1366
1368
  }
1367
1369
 
1368
- export function chunkBySize<T>(chunkSize: int32, xs: Iterable<T>): Iterable<T[]> {
1369
- return delay<T[]>((): Iterable<T[]> => ofArray<T[]>(chunkBySize_1<T>(chunkSize, toArray<T>(xs))));
1370
+ export function chunkBySize<T>(chunkSize: int32, xs: Iterable<T>): Iterable<MutableArray<T>> {
1371
+ return delay<MutableArray<T>>((): Iterable<MutableArray<T>> => ofArray<MutableArray<T>>(chunkBySize_1<T>(chunkSize, toArray<T>(xs))));
1370
1372
  }
1371
1373
 
1372
1374
  export function insertAt<T>(index: int32, y: T, xs: Iterable<T>): Iterable<T> {
1373
1375
  let isDone = false;
1374
1376
  if (index < 0) {
1375
- throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1377
+ throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1376
1378
  }
1377
1379
  return generateIndexed<IEnumerator<T>, T>((): IEnumerator<T> => ofSeq<T>(xs), (i: int32, e: IEnumerator<T>): Option<T> => {
1378
1380
  if ((isDone ? true : (i < index)) && e["System.Collections.IEnumerator.MoveNext"]()) {
@@ -1384,7 +1386,7 @@ export function insertAt<T>(index: int32, y: T, xs: Iterable<T>): Iterable<T> {
1384
1386
  }
1385
1387
  else {
1386
1388
  if (!isDone) {
1387
- throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1389
+ throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1388
1390
  }
1389
1391
  return undefined;
1390
1392
  }
@@ -1396,7 +1398,7 @@ export function insertAt<T>(index: int32, y: T, xs: Iterable<T>): Iterable<T> {
1396
1398
  export function insertManyAt<T>(index: int32, ys: Iterable<T>, xs: Iterable<T>): Iterable<T> {
1397
1399
  let status = -1;
1398
1400
  if (index < 0) {
1399
- throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1401
+ throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1400
1402
  }
1401
1403
  return generateIndexed<[IEnumerator<T>, IEnumerator<T>], T>((): [IEnumerator<T>, IEnumerator<T>] => ([ofSeq<T>(xs), ofSeq<T>(ys)] as [IEnumerator<T>, IEnumerator<T>]), (i: int32, tupledArg: [IEnumerator<T>, IEnumerator<T>]): Option<T> => {
1402
1404
  const e1: IEnumerator<T> = tupledArg[0];
@@ -1423,7 +1425,7 @@ export function insertManyAt<T>(index: int32, ys: Iterable<T>, xs: Iterable<T>):
1423
1425
  }
1424
1426
  else {
1425
1427
  if (status < 1) {
1426
- throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1428
+ throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1427
1429
  }
1428
1430
  return undefined;
1429
1431
  }
@@ -1440,7 +1442,7 @@ export function insertManyAt<T>(index: int32, ys: Iterable<T>, xs: Iterable<T>):
1440
1442
  export function removeAt<T>(index: int32, xs: Iterable<T>): Iterable<T> {
1441
1443
  let isDone = false;
1442
1444
  if (index < 0) {
1443
- throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1445
+ throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1444
1446
  }
1445
1447
  return generateIndexed<IEnumerator<T>, T>((): IEnumerator<T> => ofSeq<T>(xs), (i: int32, e: IEnumerator<T>): Option<T> => {
1446
1448
  if ((isDone ? true : (i < index)) && e["System.Collections.IEnumerator.MoveNext"]()) {
@@ -1452,7 +1454,7 @@ export function removeAt<T>(index: int32, xs: Iterable<T>): Iterable<T> {
1452
1454
  }
1453
1455
  else {
1454
1456
  if (!isDone) {
1455
- throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1457
+ throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1456
1458
  }
1457
1459
  return undefined;
1458
1460
  }
@@ -1463,7 +1465,7 @@ export function removeAt<T>(index: int32, xs: Iterable<T>): Iterable<T> {
1463
1465
 
1464
1466
  export function removeManyAt<T>(index: int32, count: int32, xs: Iterable<T>): Iterable<T> {
1465
1467
  if (index < 0) {
1466
- throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1468
+ throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1467
1469
  }
1468
1470
  return generateIndexed<IEnumerator<T>, T>((): IEnumerator<T> => ofSeq<T>(xs), (i: int32, e: IEnumerator<T>): Option<T> => {
1469
1471
  if (i < index) {
@@ -1471,14 +1473,14 @@ export function removeManyAt<T>(index: int32, count: int32, xs: Iterable<T>): It
1471
1473
  return some(e["System.Collections.Generic.IEnumerator`1.get_Current"]());
1472
1474
  }
1473
1475
  else {
1474
- throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1476
+ throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1475
1477
  }
1476
1478
  }
1477
1479
  else {
1478
1480
  if (i === index) {
1479
1481
  for (let _ = 1; _ <= count; _++) {
1480
1482
  if (!e["System.Collections.IEnumerator.MoveNext"]()) {
1481
- throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "count");
1483
+ throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "count");
1482
1484
  }
1483
1485
  }
1484
1486
  }
@@ -1492,7 +1494,7 @@ export function removeManyAt<T>(index: int32, count: int32, xs: Iterable<T>): It
1492
1494
  export function updateAt<T>(index: int32, y: T, xs: Iterable<T>): Iterable<T> {
1493
1495
  let isDone = false;
1494
1496
  if (index < 0) {
1495
- throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1497
+ throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1496
1498
  }
1497
1499
  return generateIndexed<IEnumerator<T>, T>((): IEnumerator<T> => ofSeq<T>(xs), (i: int32, e: IEnumerator<T>): Option<T> => {
1498
1500
  if ((isDone ? true : (i < index)) && e["System.Collections.IEnumerator.MoveNext"]()) {
@@ -1504,7 +1506,7 @@ export function updateAt<T>(index: int32, y: T, xs: Iterable<T>): Iterable<T> {
1504
1506
  }
1505
1507
  else {
1506
1508
  if (!isDone) {
1507
- throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1509
+ throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1508
1510
  }
1509
1511
  return undefined;
1510
1512
  }
package/Seq2.ts CHANGED
@@ -1,12 +1,12 @@
1
1
 
2
- import { toList, toArray, map, filter, delay } from "./Seq.js";
3
- import { HashSet } from "./MutableSet.js";
4
- import { defaultOf, IDisposable, disposeSafe, IEnumerator, getEnumerator, IMap, IEqualityComparer, ISet } from "./Util.js";
5
- import { addToDict, getItemFromDict, tryGetValue, addToSet } from "./MapUtil.js";
6
- import { Dictionary } from "./MutableMap.js";
7
- import { int32 } from "./Int32.js";
8
- import { FSharpRef } from "./Types.js";
9
- import { FSharpList } from "./List.js";
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
10
 
11
11
  export function distinct<T>(xs: Iterable<T>, comparer: IEqualityComparer<T>): Iterable<T> {
12
12
  return delay<T>((): Iterable<T> => {
@@ -88,24 +88,24 @@ export function groupBy<T, Key>(projection: ((arg0: T) => Key), xs: Iterable<T>,
88
88
  });
89
89
  }
90
90
 
91
- export function Array_distinct<T>(xs: T[], comparer: IEqualityComparer<T>): T[] {
91
+ export function Array_distinct<T>(xs: MutableArray<T>, comparer: IEqualityComparer<T>): MutableArray<T> {
92
92
  return toArray<T>(distinct<T>(xs, comparer));
93
93
  }
94
94
 
95
- export function Array_distinctBy<T, Key>(projection: ((arg0: T) => Key), xs: T[], comparer: IEqualityComparer<Key>): T[] {
95
+ export function Array_distinctBy<T, Key>(projection: ((arg0: T) => Key), xs: MutableArray<T>, comparer: IEqualityComparer<Key>): MutableArray<T> {
96
96
  return toArray<T>(distinctBy<T, Key>(projection, xs, comparer));
97
97
  }
98
98
 
99
- export function Array_except<T>(itemsToExclude: Iterable<T>, xs: T[], comparer: IEqualityComparer<T>): T[] {
99
+ export function Array_except<T>(itemsToExclude: Iterable<T>, xs: MutableArray<T>, comparer: IEqualityComparer<T>): MutableArray<T> {
100
100
  return toArray<T>(except<T>(itemsToExclude, xs, comparer));
101
101
  }
102
102
 
103
- export function Array_countBy<T, Key>(projection: ((arg0: T) => Key), xs: T[], comparer: IEqualityComparer<Key>): [Key, int32][] {
103
+ export function Array_countBy<T, Key>(projection: ((arg0: T) => Key), xs: MutableArray<T>, comparer: IEqualityComparer<Key>): MutableArray<[Key, int32]> {
104
104
  return toArray<[Key, int32]>(countBy<T, Key>(projection, xs, comparer));
105
105
  }
106
106
 
107
- export function Array_groupBy<T, Key>(projection: ((arg0: T) => Key), xs: T[], comparer: IEqualityComparer<Key>): [Key, T[]][] {
108
- 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)));
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
109
  }
110
110
 
111
111
  export function List_distinct<T>(xs: FSharpList<T>, comparer: IEqualityComparer<T>): FSharpList<T> {