@fable-org/fable-library-js 2.0.0-beta.4 → 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 (97) hide show
  1. package/Array.js +56 -52
  2. package/Async.js +8 -7
  3. package/AsyncBuilder.js +6 -6
  4. package/BigInt.js +3 -3
  5. package/Boolean.js +2 -1
  6. package/CHANGELOG.md +8 -0
  7. package/Char.js +64 -31
  8. package/CollectionUtil.js +3 -3
  9. package/Date.js +50 -46
  10. package/DateOffset.js +38 -48
  11. package/DateOnly.js +6 -6
  12. package/Decimal.js +4 -4
  13. package/Double.js +2 -1
  14. package/FSharp.Collections.js +28 -10
  15. package/FSharp.Core.js +23 -23
  16. package/Global.js +21 -0
  17. package/Guid.js +5 -4
  18. package/Int32.js +17 -17
  19. package/List.js +36 -35
  20. package/Long.js +3 -2
  21. package/MailboxProcessor.js +2 -1
  22. package/Map.js +29 -27
  23. package/MapUtil.js +4 -4
  24. package/MutableMap.js +22 -10
  25. package/MutableSet.js +3 -3
  26. package/Option.js +3 -3
  27. package/Random.js +12 -11
  28. package/Range.js +2 -2
  29. package/Reflection.js +16 -16
  30. package/RegExp.js +4 -3
  31. package/Seq.js +31 -29
  32. package/Set.js +34 -33
  33. package/String.js +44 -35
  34. package/System.Collections.Generic.js +20 -4
  35. package/System.Text.js +3 -3
  36. package/System.js +283 -0
  37. package/TimeOnly.js +6 -6
  38. package/TimeSpan.js +5 -5
  39. package/Types.js +1 -17
  40. package/Uri.js +25 -19
  41. package/Util.js +31 -17
  42. package/package.json +1 -1
  43. package/Array.d.ts +0 -123
  44. package/Async.d.ts +0 -26
  45. package/AsyncBuilder.d.ts +0 -59
  46. package/BigInt.d.ts +0 -129
  47. package/BitConverter.d.ts +0 -27
  48. package/Boolean.d.ts +0 -3
  49. package/Char.d.ts +0 -65
  50. package/Choice.d.ts +0 -121
  51. package/CollectionUtil.d.ts +0 -7
  52. package/ConditionalWeakTable.d.ts +0 -9
  53. package/Date.d.ts +0 -69
  54. package/DateOffset.d.ts +0 -64
  55. package/DateOnly.d.ts +0 -18
  56. package/Decimal.d.ts +0 -63
  57. package/Double.d.ts +0 -11
  58. package/Encoding.d.ts +0 -12
  59. package/Event.d.ts +0 -31
  60. package/FSharp.Collections.d.ts +0 -7
  61. package/FSharp.Core.CompilerServices.d.ts +0 -12
  62. package/FSharp.Core.d.ts +0 -30
  63. package/Global.d.ts +0 -24
  64. package/Guid.d.ts +0 -10
  65. package/Int32.d.ts +0 -28
  66. package/List.d.ts +0 -143
  67. package/Long.d.ts +0 -3
  68. package/MailboxProcessor.d.ts +0 -25
  69. package/Map.d.ts +0 -178
  70. package/MapUtil.d.ts +0 -12
  71. package/MutableMap.d.ts +0 -52
  72. package/MutableSet.d.ts +0 -39
  73. package/Native.d.ts +0 -3
  74. package/Numeric.d.ts +0 -20
  75. package/Observable.d.ts +0 -32
  76. package/Option.d.ts +0 -29
  77. package/Random.d.ts +0 -37
  78. package/Range.d.ts +0 -12
  79. package/Reflection.d.ts +0 -119
  80. package/RegExp.d.ts +0 -10
  81. package/Result.d.ts +0 -37
  82. package/Seq.d.ts +0 -164
  83. package/Seq2.d.ts +0 -18
  84. package/Set.d.ts +0 -190
  85. package/String.d.ts +0 -58
  86. package/System.Collections.Generic.d.ts +0 -79
  87. package/System.Text.d.ts +0 -40
  88. package/SystemException.d.ts +0 -5
  89. package/SystemException.js +0 -5
  90. package/TimeOnly.d.ts +0 -15
  91. package/TimeSpan.d.ts +0 -35
  92. package/Timer.d.ts +0 -19
  93. package/Types.d.ts +0 -58
  94. package/Unicode.13.0.0.d.ts +0 -2
  95. package/Uri.d.ts +0 -31
  96. package/Util.d.ts +0 -212
  97. package/lib/big.d.ts +0 -5
package/Map.js CHANGED
@@ -1,11 +1,13 @@
1
1
  import { record_type, bool_type, list_type, option_type, class_type } from "./Reflection.js";
2
2
  import { some, value as value_1 } from "./Option.js";
3
- import { structuralHash, compare, toIterator, equals, disposeSafe, getEnumerator, isArrayLike } from "./Util.js";
3
+ import { structuralHash, compare, toIterator, equals, disposeSafe, getEnumerator, isArrayLike, Exception } from "./Util.js";
4
+ import { KeyNotFoundException_$ctor } from "./System.Collections.Generic.js";
4
5
  import { singleton, ofArrayWithTail, head, tail, isEmpty as isEmpty_1, fold as fold_1, empty as empty_1, FSharpList, cons } from "./List.js";
5
6
  import { map as map_2, item, fill, setItem } from "./Array.js";
6
7
  import { Record } from "./Types.js";
7
8
  import { tryPick as tryPick_1, pick as pick_1, iterate as iterate_1, compareWith, map as map_1, unfold } from "./Seq.js";
8
9
  import { format, join } from "./String.js";
10
+ import { NotSupportedException_$ctor_Z721C83C5 } from "./System.js";
9
11
  export class MapTreeLeaf$2 {
10
12
  constructor(k, v) {
11
13
  this.k = k;
@@ -75,7 +77,7 @@ export function MapTreeModule_size(x) {
75
77
  return MapTreeModule_sizeAux(0, x) | 0;
76
78
  }
77
79
  export function MapTreeModule_mk(l, k, v, r) {
78
- let mn, mn_1;
80
+ let mn = undefined, mn_1 = undefined;
79
81
  let hl;
80
82
  const m = l;
81
83
  if (m != null) {
@@ -103,7 +105,7 @@ export function MapTreeModule_mk(l, k, v, r) {
103
105
  }
104
106
  }
105
107
  export function MapTreeModule_rebalance(t1, k, v, t2) {
106
- let mn, mn_1, m_2, m2_2, mn_2, m_3, m2_3, mn_3;
108
+ let mn = undefined, mn_1 = undefined, m_2 = undefined, m2_2 = undefined, mn_2 = undefined, m_3 = undefined, m2_3 = undefined, mn_3 = undefined;
107
109
  let t1h;
108
110
  const m = t1;
109
111
  if (m != null) {
@@ -133,7 +135,7 @@ export function MapTreeModule_rebalance(t1, k, v, t2) {
133
135
  return MapTreeModule_mk(MapTreeModule_mk(t1, k, v, MapTreeNode$2__get_Left(t2l)), MapTreeLeaf$2__get_Key(t2l), MapTreeLeaf$2__get_Value(t2l), MapTreeModule_mk(MapTreeNode$2__get_Right(t2l), MapTreeLeaf$2__get_Key(t2$0027), MapTreeLeaf$2__get_Value(t2$0027), MapTreeNode$2__get_Right(t2$0027)));
134
136
  }
135
137
  else {
136
- throw new Error("internal error: Map.rebalance");
138
+ throw new Exception("internal error: Map.rebalance");
137
139
  }
138
140
  }
139
141
  else {
@@ -141,7 +143,7 @@ export function MapTreeModule_rebalance(t1, k, v, t2) {
141
143
  }
142
144
  }
143
145
  else {
144
- throw new Error("internal error: Map.rebalance");
146
+ throw new Exception("internal error: Map.rebalance");
145
147
  }
146
148
  }
147
149
  else if (t1h > (t2h + 2)) {
@@ -155,7 +157,7 @@ export function MapTreeModule_rebalance(t1, k, v, t2) {
155
157
  return MapTreeModule_mk(MapTreeModule_mk(MapTreeNode$2__get_Left(t1$0027), MapTreeLeaf$2__get_Key(t1$0027), MapTreeLeaf$2__get_Value(t1$0027), MapTreeNode$2__get_Left(t1r)), MapTreeLeaf$2__get_Key(t1r), MapTreeLeaf$2__get_Value(t1r), MapTreeModule_mk(MapTreeNode$2__get_Right(t1r), k, v, t2));
156
158
  }
157
159
  else {
158
- throw new Error("internal error: Map.rebalance");
160
+ throw new Exception("internal error: Map.rebalance");
159
161
  }
160
162
  }
161
163
  else {
@@ -163,7 +165,7 @@ export function MapTreeModule_rebalance(t1, k, v, t2) {
163
165
  }
164
166
  }
165
167
  else {
166
- throw new Error("internal error: Map.rebalance");
168
+ throw new Exception("internal error: Map.rebalance");
167
169
  }
168
170
  }
169
171
  else {
@@ -229,7 +231,7 @@ export function MapTreeModule_tryFind(comparer_mut, k_mut, m_mut) {
229
231
  export function MapTreeModule_find(comparer, k, m) {
230
232
  const matchValue = MapTreeModule_tryFind(comparer, k, m);
231
233
  if (matchValue == null) {
232
- throw new Error();
234
+ throw KeyNotFoundException_$ctor();
233
235
  }
234
236
  else {
235
237
  return value_1(matchValue);
@@ -327,7 +329,7 @@ export function MapTreeModule_spliceOutSuccessor(m) {
327
329
  }
328
330
  }
329
331
  else {
330
- throw new Error("internal error: Map.spliceOutSuccessor");
332
+ throw new Exception("internal error: Map.spliceOutSuccessor");
331
333
  }
332
334
  }
333
335
  export function MapTreeModule_remove(comparer, k, m) {
@@ -846,10 +848,10 @@ export function MapTreeModule_mkIterator(m) {
846
848
  return new MapTreeModule_MapIterator$2(MapTreeModule_collapseLHS(singleton(m)), false);
847
849
  }
848
850
  export function MapTreeModule_notStarted() {
849
- throw new Error("enumeration not started");
851
+ throw new Exception("enumeration not started");
850
852
  }
851
853
  export function MapTreeModule_alreadyFinished() {
852
- throw new Error("enumeration already finished");
854
+ throw new Exception("enumeration already finished");
853
855
  }
854
856
  export function MapTreeModule_current(i) {
855
857
  if (i.started) {
@@ -858,14 +860,14 @@ export function MapTreeModule_current(i) {
858
860
  if (head(matchValue) != null) {
859
861
  const m = value_1(head(matchValue));
860
862
  if (m instanceof MapTreeNode$2) {
861
- throw new Error("Please report error: Map iterator, unexpected stack for current");
863
+ throw new Exception("Please report error: Map iterator, unexpected stack for current");
862
864
  }
863
865
  else {
864
866
  return [MapTreeLeaf$2__get_Key(m), MapTreeLeaf$2__get_Value(m)];
865
867
  }
866
868
  }
867
869
  else {
868
- throw new Error("Please report error: Map iterator, unexpected stack for current");
870
+ throw new Exception("Please report error: Map iterator, unexpected stack for current");
869
871
  }
870
872
  }
871
873
  else {
@@ -883,7 +885,7 @@ export function MapTreeModule_moveNext(i) {
883
885
  if (head(matchValue) != null) {
884
886
  const m = value_1(head(matchValue));
885
887
  if (m instanceof MapTreeNode$2) {
886
- throw new Error("Please report error: Map iterator, unexpected stack for moveNext");
888
+ throw new Exception("Please report error: Map iterator, unexpected stack for moveNext");
887
889
  }
888
890
  else {
889
891
  i.stack = MapTreeModule_collapseLHS(tail(matchValue));
@@ -891,7 +893,7 @@ export function MapTreeModule_moveNext(i) {
891
893
  }
892
894
  }
893
895
  else {
894
- throw new Error("Please report error: Map iterator, unexpected stack for moveNext");
896
+ throw new Exception("Please report error: Map iterator, unexpected stack for moveNext");
895
897
  }
896
898
  }
897
899
  else {
@@ -937,7 +939,7 @@ export function MapTreeModule_leftmost(m_mut) {
937
939
  const m = m_mut;
938
940
  if (m != null) {
939
941
  const m2 = value_1(m);
940
- let matchResult, nd_1;
942
+ let matchResult = undefined, nd_1 = undefined;
941
943
  if (m2 instanceof MapTreeNode$2) {
942
944
  if (MapTreeNode$2__get_Height(m2) > 1) {
943
945
  matchResult = 0;
@@ -964,7 +966,7 @@ export function MapTreeModule_leftmost(m_mut) {
964
966
  }
965
967
  }
966
968
  else {
967
- throw new Error();
969
+ throw KeyNotFoundException_$ctor();
968
970
  }
969
971
  break;
970
972
  }
@@ -974,7 +976,7 @@ export function MapTreeModule_rightmost(m_mut) {
974
976
  const m = m_mut;
975
977
  if (m != null) {
976
978
  const m2 = value_1(m);
977
- let matchResult, nd_1;
979
+ let matchResult = undefined, nd_1 = undefined;
978
980
  if (m2 instanceof MapTreeNode$2) {
979
981
  if (MapTreeNode$2__get_Height(m2) > 1) {
980
982
  matchResult = 0;
@@ -1001,7 +1003,7 @@ export function MapTreeModule_rightmost(m_mut) {
1001
1003
  }
1002
1004
  }
1003
1005
  else {
1004
- throw new Error();
1006
+ throw KeyNotFoundException_$ctor();
1005
1007
  }
1006
1008
  break;
1007
1009
  }
@@ -1081,7 +1083,7 @@ export class FSharpMap {
1081
1083
  return MapTreeModule_mkIEnumerator(_.tree);
1082
1084
  }
1083
1085
  CompareTo(other) {
1084
- let that;
1086
+ let that = undefined;
1085
1087
  const this$ = this;
1086
1088
  return ((other instanceof FSharpMap) ? ((that = other, compareWith((kvp1, kvp2) => {
1087
1089
  const c = this$.comparer.Compare(kvp1[0], kvp2[0]) | 0;
@@ -1089,13 +1091,13 @@ export class FSharpMap {
1089
1091
  }, this$, that))) : 1) | 0;
1090
1092
  }
1091
1093
  "System.Collections.Generic.ICollection`1.Add2B595"(x) {
1092
- throw new Error("Map cannot be mutated");
1094
+ throw NotSupportedException_$ctor_Z721C83C5("Map cannot be mutated");
1093
1095
  }
1094
1096
  "System.Collections.Generic.ICollection`1.Clear"() {
1095
- throw new Error("Map cannot be mutated");
1097
+ throw NotSupportedException_$ctor_Z721C83C5("Map cannot be mutated");
1096
1098
  }
1097
1099
  "System.Collections.Generic.ICollection`1.Remove2B595"(x) {
1098
- throw new Error("Map cannot be mutated");
1100
+ throw NotSupportedException_$ctor_Z721C83C5("Map cannot be mutated");
1099
1101
  }
1100
1102
  "System.Collections.Generic.ICollection`1.Contains2B595"(x) {
1101
1103
  const m = this;
@@ -1121,10 +1123,10 @@ export class FSharpMap {
1121
1123
  return FSharpMap__get_Count(m) | 0;
1122
1124
  }
1123
1125
  clear() {
1124
- throw new Error("Map cannot be mutated");
1126
+ throw new Exception("Map cannot be mutated");
1125
1127
  }
1126
1128
  delete(_arg) {
1127
- throw new Error("Map cannot be mutated");
1129
+ throw new Exception("Map cannot be mutated");
1128
1130
  return false;
1129
1131
  }
1130
1132
  entries() {
@@ -1145,7 +1147,7 @@ export class FSharpMap {
1145
1147
  }
1146
1148
  set(k, v) {
1147
1149
  const m = this;
1148
- throw new Error("Map cannot be mutated");
1150
+ throw new Exception("Map cannot be mutated");
1149
1151
  return m;
1150
1152
  }
1151
1153
  values() {
@@ -1307,7 +1309,7 @@ export function pick(chooser, table) {
1307
1309
  return value_1(matchValue);
1308
1310
  }
1309
1311
  else {
1310
- throw new Error();
1312
+ throw KeyNotFoundException_$ctor();
1311
1313
  }
1312
1314
  }
1313
1315
  export function exists(predicate, table) {
package/MapUtil.js CHANGED
@@ -1,4 +1,4 @@
1
- import { equals } from "./Util.js";
1
+ import { Exception, equals } from "./Util.js";
2
2
  import { Union } from "./Types.js";
3
3
  const CaseRules = {
4
4
  None: 0,
@@ -34,7 +34,7 @@ export function keyValueList(fields, caseRule = CaseRules.None) {
34
34
  const obj = {};
35
35
  const definedCaseRule = caseRule;
36
36
  function fail(kvPair) {
37
- throw new Error("Cannot infer key and value of " + String(kvPair));
37
+ throw new Exception("Cannot infer key and value of " + String(kvPair));
38
38
  }
39
39
  function assign(key, caseRule, value) {
40
40
  key = changeCase(key, caseRule);
@@ -108,7 +108,7 @@ export function tryAddToDict(dict, k, v) {
108
108
  }
109
109
  export function addToDict(dict, k, v) {
110
110
  if (dict.has(k)) {
111
- throw new Error("An item with the same key has already been added. Key: " + k);
111
+ throw new Exception("An item with the same key has already been added. Key: " + k);
112
112
  }
113
113
  dict.set(k, v);
114
114
  }
@@ -117,7 +117,7 @@ export function getItemFromDict(map, key) {
117
117
  return map.get(key);
118
118
  }
119
119
  else {
120
- throw new Error(`The given key '${key}' was not present in the dictionary.`);
120
+ throw new Exception(`The given key '${key}' was not present in the dictionary.`);
121
121
  }
122
122
  }
123
123
  export function getItemFromDictOrCreate(map, key, createValue) {
package/MutableMap.js CHANGED
@@ -5,6 +5,8 @@ import { setItem } from "./Array.js";
5
5
  import { FSharpRef } from "./Types.js";
6
6
  import { class_type } from "./Reflection.js";
7
7
  import { getItemFromDict, tryGetValue } from "./MapUtil.js";
8
+ import { KeyNotFoundException_$ctor_Z721C83C5 } from "./System.Collections.Generic.js";
9
+ import { ArgumentException_$ctor_Z721C83C5 } from "./System.js";
8
10
  import { format } from "./String.js";
9
11
  export class Dictionary {
10
12
  constructor(pairs, comparer) {
@@ -53,11 +55,11 @@ export class Dictionary {
53
55
  "System.Collections.Generic.ICollection`1.Contains2B595"(item) {
54
56
  const this$ = this;
55
57
  const matchValue = Dictionary__TryFind_2B595(this$, item[0]);
56
- let matchResult, p_1;
58
+ let matchResult = undefined, pair_1 = undefined;
57
59
  if (matchValue != null) {
58
60
  if (equals(value_1(matchValue)[1], item[1])) {
59
61
  matchResult = 0;
60
- p_1 = value_1(matchValue);
62
+ pair_1 = value_1(matchValue);
61
63
  }
62
64
  else {
63
65
  matchResult = 1;
@@ -89,14 +91,24 @@ export class Dictionary {
89
91
  "System.Collections.Generic.ICollection`1.Remove2B595"(item) {
90
92
  const this$ = this;
91
93
  const matchValue = Dictionary__TryFind_2B595(this$, item[0]);
94
+ let matchResult = undefined, pair_1 = undefined;
92
95
  if (matchValue != null) {
93
96
  if (equals(value_1(matchValue)[1], item[1])) {
94
- Dictionary__Remove_2B595(this$, item[0]);
97
+ matchResult = 0;
98
+ pair_1 = value_1(matchValue);
99
+ }
100
+ else {
101
+ matchResult = 1;
95
102
  }
96
- return true;
97
103
  }
98
104
  else {
99
- return false;
105
+ matchResult = 1;
106
+ }
107
+ switch (matchResult) {
108
+ case 0:
109
+ return Dictionary__Remove_2B595(this$, item[0]);
110
+ default:
111
+ return false;
100
112
  }
101
113
  }
102
114
  "System.Collections.Generic.IDictionary`2.Add5BDDA1"(key, value) {
@@ -205,7 +217,7 @@ function Dictionary__TryFindIndex_2B595(this$, k) {
205
217
  }
206
218
  export function Dictionary__TryFind_2B595(this$, k) {
207
219
  const matchValue = Dictionary__TryFindIndex_2B595(this$, k);
208
- let matchResult;
220
+ let matchResult = undefined;
209
221
  if (matchValue[0]) {
210
222
  if (matchValue[2] > -1) {
211
223
  matchResult = 0;
@@ -250,7 +262,7 @@ export function Dictionary__get_Item_2B595(this$, k) {
250
262
  return value_1(matchValue)[1];
251
263
  }
252
264
  else {
253
- throw new Error("The item was not found in collection");
265
+ throw KeyNotFoundException_$ctor_Z721C83C5("The item was not found in collection");
254
266
  }
255
267
  }
256
268
  export function Dictionary__set_Item_5BDDA1(this$, k, v) {
@@ -271,7 +283,7 @@ export function Dictionary__Add_5BDDA1(this$, k, v) {
271
283
  const matchValue = Dictionary__TryFindIndex_2B595(this$, k);
272
284
  if (matchValue[0]) {
273
285
  if (matchValue[2] > -1) {
274
- throw new Error(format("An item with the same key has already been added. Key: {0}", k));
286
+ throw ArgumentException_$ctor_Z721C83C5(format("An item with the same key has already been added. Key: {0}", k));
275
287
  }
276
288
  else {
277
289
  const value = void (getItemFromDict(this$.hashMap, matchValue[1]).push([k, v]));
@@ -283,7 +295,7 @@ export function Dictionary__Add_5BDDA1(this$, k, v) {
283
295
  }
284
296
  export function Dictionary__ContainsKey_2B595(this$, k) {
285
297
  const matchValue = Dictionary__TryFindIndex_2B595(this$, k);
286
- let matchResult;
298
+ let matchResult = undefined;
287
299
  if (matchValue[0]) {
288
300
  if (matchValue[2] > -1) {
289
301
  matchResult = 0;
@@ -304,7 +316,7 @@ export function Dictionary__ContainsKey_2B595(this$, k) {
304
316
  }
305
317
  export function Dictionary__Remove_2B595(this$, k) {
306
318
  const matchValue = Dictionary__TryFindIndex_2B595(this$, k);
307
- let matchResult;
319
+ let matchResult = undefined;
308
320
  if (matchValue[0]) {
309
321
  if (matchValue[2] > -1) {
310
322
  matchResult = 0;
package/MutableSet.js CHANGED
@@ -132,7 +132,7 @@ function HashSet__TryFindIndex_2B595(this$, k) {
132
132
  }
133
133
  function HashSet__TryFind_2B595(this$, k) {
134
134
  const matchValue = HashSet__TryFindIndex_2B595(this$, k);
135
- let matchResult;
135
+ let matchResult = undefined;
136
136
  if (matchValue[0]) {
137
137
  if (matchValue[2] > -1) {
138
138
  matchResult = 0;
@@ -189,7 +189,7 @@ export function HashSet__Add_2B595(this$, k) {
189
189
  }
190
190
  export function HashSet__Contains_2B595(this$, k) {
191
191
  const matchValue = HashSet__TryFindIndex_2B595(this$, k);
192
- let matchResult;
192
+ let matchResult = undefined;
193
193
  if (matchValue[0]) {
194
194
  if (matchValue[2] > -1) {
195
195
  matchResult = 0;
@@ -210,7 +210,7 @@ export function HashSet__Contains_2B595(this$, k) {
210
210
  }
211
211
  export function HashSet__Remove_2B595(this$, k) {
212
212
  const matchValue = HashSet__TryFindIndex_2B595(this$, k);
213
- let matchResult;
213
+ let matchResult = undefined;
214
214
  if (matchValue[0]) {
215
215
  if (matchValue[2] > -1) {
216
216
  matchResult = 0;
package/Option.js CHANGED
@@ -1,4 +1,4 @@
1
- import { structuralHash, equals, compare } from "./Util.js";
1
+ import { Exception, structuralHash, equals, compare } from "./Util.js";
2
2
  // Using a class here for better compatibility with TS files importing Some
3
3
  export class Some {
4
4
  constructor(value) {
@@ -33,7 +33,7 @@ export class Some {
33
33
  }
34
34
  export function nonNullValue(x) {
35
35
  if (x == null) {
36
- throw new Error("Nullable has no value");
36
+ throw new Exception("Nullable has no value");
37
37
  }
38
38
  else {
39
39
  return x;
@@ -41,7 +41,7 @@ export function nonNullValue(x) {
41
41
  }
42
42
  export function value(x) {
43
43
  if (x == null) {
44
- throw new Error("Option has no value");
44
+ throw new Exception("Option has no value");
45
45
  }
46
46
  else {
47
47
  return x instanceof Some ? x.value : x;
package/Random.js CHANGED
@@ -1,19 +1,20 @@
1
+ import { ArgumentNullException_$ctor_Z721C83C5, ArgumentOutOfRangeException_$ctor_Z721C83C5 } from "./System.js";
1
2
  import { Operators_IsNull } from "./FSharp.Core.js";
2
3
  import { class_type } from "./Reflection.js";
3
4
  import { fromFloat64, op_Addition, toInt32_unchecked, toFloat64, compare, fromInt32, toInt64_unchecked } from "./BigInt.js";
4
- import { item, fill, setItem } from "./Array.js";
5
+ import { item, setItem } from "./Array.js";
5
6
  function Native_random() {
6
7
  return Math.random();
7
8
  }
8
- function Native_randomNext(min, max) {
9
- if (max < min) {
10
- throw new Error("minValue must be less than maxValue");
9
+ function Native_randomNext(minValue, maxValue) {
10
+ if (maxValue < minValue) {
11
+ throw ArgumentOutOfRangeException_$ctor_Z721C83C5("minValue must be less than maxValue");
11
12
  }
12
- return Math.floor(Math.random() * (max - min)) + min;
13
+ return Math.floor(Math.random() * (maxValue - minValue)) + minValue;
13
14
  }
14
15
  function Native_randomBytes(buffer) {
15
- if (buffer == null) {
16
- throw new Error("Buffer cannot be null");
16
+ if (Operators_IsNull(buffer)) {
17
+ throw ArgumentNullException_$ctor_Z721C83C5("buffer");
17
18
  }
18
19
  for (let i = 0; i < buffer.length; i += 6) {
19
20
  // Pick random 48-bit number. Fill buffer in 2 24-bit chunks to avoid bitwise truncation.
@@ -59,7 +60,7 @@ export class Seeded {
59
60
  this.MBIG = 2147483647;
60
61
  this.inext = 0;
61
62
  this.inextp = 0;
62
- this.seedArray = fill(new Array(56), 0, 56, 0);
63
+ this.seedArray = (new Int32Array(56));
63
64
  let ii = 0;
64
65
  let mj = 0;
65
66
  let mk = 0;
@@ -94,14 +95,14 @@ export class Seeded {
94
95
  Next1(maxValue) {
95
96
  const this$ = this;
96
97
  if (maxValue < 0) {
97
- throw new Error("maxValue must be positive");
98
+ throw ArgumentOutOfRangeException_$ctor_Z721C83C5("maxValue must be positive");
98
99
  }
99
100
  return ~~(Seeded__Sample(this$) * maxValue) | 0;
100
101
  }
101
102
  Next2(minValue, maxValue) {
102
103
  const this$ = this;
103
104
  if (minValue > maxValue) {
104
- throw new Error("minValue must be less than maxValue");
105
+ throw ArgumentOutOfRangeException_$ctor_Z721C83C5("minValue must be less than maxValue");
105
106
  }
106
107
  const range = toInt64_unchecked(fromInt32(maxValue - minValue));
107
108
  return ((compare(range, toInt64_unchecked(fromInt32(2147483647))) <= 0) ? (~~(Seeded__Sample(this$) * toFloat64(range)) + minValue) : ~~toInt32_unchecked(toInt64_unchecked(op_Addition(toInt64_unchecked(fromFloat64(Seeded__GetSampleForLargeRange(this$) * toFloat64(range))), toInt64_unchecked(fromInt32(minValue)))))) | 0;
@@ -113,7 +114,7 @@ export class Seeded {
113
114
  NextBytes(buffer) {
114
115
  const this$ = this;
115
116
  if (Operators_IsNull(buffer)) {
116
- throw new Error("buffer");
117
+ throw ArgumentNullException_$ctor_Z721C83C5("buffer");
117
118
  }
118
119
  for (let i = 0; i <= (buffer.length - 1); i++) {
119
120
  setItem(buffer, i, (Seeded__InternalSample(this$) % (~~255 + 1)) & 0xFF);
package/Range.js CHANGED
@@ -1,11 +1,11 @@
1
- import { compare } from "./Util.js";
1
+ import { Exception, compare } from "./Util.js";
2
2
  import { unfold, delay } from "./Seq.js";
3
3
  import { toUInt64_unchecked, toInt64_unchecked, op_Addition, fromZero } from "./BigInt.js";
4
4
  import { op_Addition as op_Addition_1, fromParts } from "./Decimal.js";
5
5
  export function makeRangeStepFunction(step, stop, zero, add) {
6
6
  const stepComparedWithZero = compare(step, zero) | 0;
7
7
  if (stepComparedWithZero === 0) {
8
- throw new Error("The step of a range cannot be zero");
8
+ throw new Exception("The step of a range cannot be zero");
9
9
  }
10
10
  const stepGreaterThanZero = stepComparedWithZero > 0;
11
11
  return (x) => {
package/Reflection.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Record, Union } from "./Types.js";
2
- import { combineHashCodes, equalArraysWith, stringHash } from "./Util.js";
2
+ import { Exception, combineHashCodes, equalArraysWith, stringHash } from "./Util.js";
3
3
  import Decimal from "./Decimal.js";
4
4
  export class CaseInfo {
5
5
  constructor(declaringType, tag, name, fields) {
@@ -135,7 +135,7 @@ export function name(info) {
135
135
  }
136
136
  else {
137
137
  const i = info.fullname.lastIndexOf(".");
138
- return i === -1 ? info.fullname : info.fullname.substr(i + 1);
138
+ return i === -1 ? info.fullname : info.fullname.slice(i + 1);
139
139
  }
140
140
  }
141
141
  else {
@@ -161,7 +161,7 @@ export function namespace(t) {
161
161
  }
162
162
  else {
163
163
  const i = t.fullname.lastIndexOf(".");
164
- return i === -1 ? "" : t.fullname.substr(0, i);
164
+ return i === -1 ? "" : t.fullname.slice(0, i);
165
165
  }
166
166
  }
167
167
  export function isArray(t) {
@@ -239,7 +239,7 @@ export function getEnumValues(t) {
239
239
  return t.enumCases.map((kv) => kv[1]);
240
240
  }
241
241
  else {
242
- throw new Error(`${t.fullname} is not an enum type`);
242
+ throw new Exception(`${t.fullname} is not an enum type`);
243
243
  }
244
244
  }
245
245
  export function getEnumNames(t) {
@@ -247,7 +247,7 @@ export function getEnumNames(t) {
247
247
  return t.enumCases.map((kv) => kv[0]);
248
248
  }
249
249
  else {
250
- throw new Error(`${t.fullname} is not an enum type`);
250
+ throw new Exception(`${t.fullname} is not an enum type`);
251
251
  }
252
252
  }
253
253
  function getEnumCase(t, v) {
@@ -258,7 +258,7 @@ function getEnumCase(t, v) {
258
258
  return kv;
259
259
  }
260
260
  }
261
- throw new Error(`'${v}' was not found in ${t.fullname}`);
261
+ throw new Exception(`'${v}' was not found in ${t.fullname}`);
262
262
  }
263
263
  else {
264
264
  for (const kv of t.enumCases) {
@@ -271,7 +271,7 @@ function getEnumCase(t, v) {
271
271
  }
272
272
  }
273
273
  else {
274
- throw new Error(`${t.fullname} is not an enum type`);
274
+ throw new Exception(`${t.fullname} is not an enum type`);
275
275
  }
276
276
  }
277
277
  export function parseEnum(t, str) {
@@ -307,7 +307,7 @@ export function getUnionCases(t) {
307
307
  return t.cases();
308
308
  }
309
309
  else {
310
- throw new Error(`${t.fullname} is not an F# union type`);
310
+ throw new Exception(`${t.fullname} is not an F# union type`);
311
311
  }
312
312
  }
313
313
  export function getRecordElements(t) {
@@ -315,7 +315,7 @@ export function getRecordElements(t) {
315
315
  return t.fields();
316
316
  }
317
317
  else {
318
- throw new Error(`${t.fullname} is not an F# record type`);
318
+ throw new Exception(`${t.fullname} is not an F# record type`);
319
319
  }
320
320
  }
321
321
  export function getTupleElements(t) {
@@ -323,7 +323,7 @@ export function getTupleElements(t) {
323
323
  return t.generics;
324
324
  }
325
325
  else {
326
- throw new Error(`${t.fullname} is not a tuple type`);
326
+ throw new Exception(`${t.fullname} is not a tuple type`);
327
327
  }
328
328
  }
329
329
  export function getFunctionElements(t) {
@@ -332,7 +332,7 @@ export function getFunctionElements(t) {
332
332
  return [gen[0], gen[1]];
333
333
  }
334
334
  else {
335
- throw new Error(`${t.fullname} is not an F# function type`);
335
+ throw new Exception(`${t.fullname} is not an F# function type`);
336
336
  }
337
337
  }
338
338
  export function isUnion(t) {
@@ -353,7 +353,7 @@ export function getUnionFields(v, t) {
353
353
  const cases = getUnionCases(t);
354
354
  const case_ = cases[v.tag];
355
355
  if (case_ == null) {
356
- throw new Error(`Cannot find case ${v.name} in union type`);
356
+ throw new Exception(`Cannot find case ${v.name} in union type`);
357
357
  }
358
358
  return [case_, v.fields];
359
359
  }
@@ -378,7 +378,7 @@ export function getTupleField(v, i) {
378
378
  export function makeUnion(uci, values) {
379
379
  const expectedLength = (uci.fields || []).length;
380
380
  if (values.length !== expectedLength) {
381
- throw new Error(`Expected an array of length ${expectedLength} but got ${values.length}`);
381
+ throw new Exception(`Expected an array of length ${expectedLength} but got ${values.length}`);
382
382
  }
383
383
  const construct = uci.declaringType.construct;
384
384
  if (construct == null) {
@@ -395,7 +395,7 @@ export function makeUnion(uci, values) {
395
395
  export function makeRecord(t, values) {
396
396
  const fields = getRecordElements(t);
397
397
  if (fields.length !== values.length) {
398
- throw new Error(`Expected an array of length ${fields.length} but got ${values.length}`);
398
+ throw new Exception(`Expected an array of length ${fields.length} but got ${values.length}`);
399
399
  }
400
400
  return t.construct != null
401
401
  ? new t.construct(...values)
@@ -434,7 +434,7 @@ export function createInstance(t, consArgs) {
434
434
  // Even though char is a value type, it's erased to string, and Unchecked.defaultof<char> is null
435
435
  return null;
436
436
  default:
437
- throw new Error(`Cannot access constructor of ${t.fullname}`);
437
+ throw new Exception(`Cannot access constructor of ${t.fullname}`);
438
438
  }
439
439
  }
440
440
  }
@@ -444,7 +444,7 @@ export function getValue(propertyInfo, v) {
444
444
  // Fable.Core.Reflection
445
445
  function assertUnion(x) {
446
446
  if (!(x instanceof Union)) {
447
- throw new Error(`Value is not an F# union type`);
447
+ throw new Exception(`Value is not an F# union type`);
448
448
  }
449
449
  }
450
450
  export function getCaseTag(x) {
package/RegExp.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { Exception } from "./Util.js";
1
2
  export function create(pattern, options = 0) {
2
3
  // Supported RegexOptions
3
4
  // * IgnoreCase: 0x0001
@@ -6,7 +7,7 @@ export function create(pattern, options = 0) {
6
7
  // * Singleline: 0x0010
7
8
  // * ECMAScript: 0x0100 (ignored)
8
9
  if ((options & ~(1 ^ 2 ^ 8 ^ 16 ^ 256)) !== 0) {
9
- throw new Error("RegexOptions only supports: IgnoreCase, Multiline, Compiled, Singleline and ECMAScript");
10
+ throw new Exception("RegexOptions only supports: IgnoreCase, Multiline, Compiled, Singleline and ECMAScript");
10
11
  }
11
12
  // Set always global and unicode flags for compatibility with dotnet, see #2925
12
13
  let flags = "gu";
@@ -32,10 +33,10 @@ export function match(reg, input, startAt = 0) {
32
33
  }
33
34
  export function matches(reg, input, startAt = 0) {
34
35
  if (input == null) {
35
- throw new Error("Input cannot ve null");
36
+ throw new Exception("Input cannot ve null");
36
37
  }
37
38
  if (!reg.global) {
38
- throw new Error("Non-global RegExp"); // Prevent infinite loop
39
+ throw new Exception("Non-global RegExp"); // Prevent infinite loop
39
40
  }
40
41
  reg.lastIndex = startAt;
41
42
  const matches = [];