@fable-org/fable-library-js 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 (98) hide show
  1. package/Array.js +64 -60
  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 +12 -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 +19 -19
  16. package/Global.js +21 -0
  17. package/Guid.js +5 -4
  18. package/Int32.js +17 -17
  19. package/List.js +74 -63
  20. package/Long.js +3 -2
  21. package/MailboxProcessor.js +2 -1
  22. package/Map.js +39 -42
  23. package/MapUtil.js +4 -4
  24. package/MutableMap.js +22 -10
  25. package/MutableSet.js +3 -3
  26. package/Native.js +9 -3
  27. package/Option.js +10 -2
  28. package/Random.js +13 -12
  29. package/Range.js +2 -2
  30. package/Reflection.js +16 -16
  31. package/RegExp.js +4 -3
  32. package/Seq.js +38 -46
  33. package/Set.js +41 -42
  34. package/String.js +44 -35
  35. package/System.Collections.Generic.js +22 -6
  36. package/System.Text.js +8 -8
  37. package/System.js +283 -0
  38. package/TimeOnly.js +6 -6
  39. package/TimeSpan.js +5 -5
  40. package/Types.js +1 -17
  41. package/Uri.js +25 -19
  42. package/Util.js +32 -9
  43. package/package.json +23 -23
  44. package/Array.d.ts +0 -123
  45. package/Async.d.ts +0 -26
  46. package/AsyncBuilder.d.ts +0 -59
  47. package/BigInt.d.ts +0 -129
  48. package/BitConverter.d.ts +0 -27
  49. package/Boolean.d.ts +0 -3
  50. package/Char.d.ts +0 -65
  51. package/Choice.d.ts +0 -121
  52. package/CollectionUtil.d.ts +0 -7
  53. package/ConditionalWeakTable.d.ts +0 -9
  54. package/Date.d.ts +0 -69
  55. package/DateOffset.d.ts +0 -64
  56. package/DateOnly.d.ts +0 -18
  57. package/Decimal.d.ts +0 -63
  58. package/Double.d.ts +0 -11
  59. package/Encoding.d.ts +0 -12
  60. package/Event.d.ts +0 -31
  61. package/FSharp.Collections.d.ts +0 -7
  62. package/FSharp.Core.CompilerServices.d.ts +0 -12
  63. package/FSharp.Core.d.ts +0 -31
  64. package/Global.d.ts +0 -24
  65. package/Guid.d.ts +0 -10
  66. package/Int32.d.ts +0 -28
  67. package/List.d.ts +0 -143
  68. package/Long.d.ts +0 -3
  69. package/MailboxProcessor.d.ts +0 -25
  70. package/Map.d.ts +0 -178
  71. package/MapUtil.d.ts +0 -12
  72. package/MutableMap.d.ts +0 -52
  73. package/MutableSet.d.ts +0 -39
  74. package/Native.d.ts +0 -2
  75. package/Numeric.d.ts +0 -20
  76. package/Observable.d.ts +0 -32
  77. package/Option.d.ts +0 -28
  78. package/Random.d.ts +0 -37
  79. package/Range.d.ts +0 -12
  80. package/Reflection.d.ts +0 -119
  81. package/RegExp.d.ts +0 -10
  82. package/Result.d.ts +0 -37
  83. package/Seq.d.ts +0 -165
  84. package/Seq2.d.ts +0 -18
  85. package/Set.d.ts +0 -190
  86. package/String.d.ts +0 -58
  87. package/System.Collections.Generic.d.ts +0 -79
  88. package/System.Text.d.ts +0 -39
  89. package/SystemException.d.ts +0 -5
  90. package/SystemException.js +0 -5
  91. package/TimeOnly.d.ts +0 -15
  92. package/TimeSpan.d.ts +0 -35
  93. package/Timer.d.ts +0 -19
  94. package/Types.d.ts +0 -58
  95. package/Unicode.13.0.0.d.ts +0 -2
  96. package/Uri.d.ts +0 -31
  97. package/Util.d.ts +0 -210
  98. package/lib/big.d.ts +0 -5
package/Set.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { record_type, bool_type, list_type, option_type, class_type } from "./Reflection.js";
2
2
  import { some, value as value_3 } from "./Option.js";
3
- import { structuralHash, toIterator, disposeSafe, getEnumerator, isArrayLike } from "./Util.js";
4
- import { toString, Record } from "./Types.js";
3
+ import { structuralHash, toIterator, disposeSafe, getEnumerator, isArrayLike, Exception } from "./Util.js";
4
+ import { Record } from "./Types.js";
5
5
  import { fold as fold_2, cons, singleton as singleton_1, empty as empty_1, ofArrayWithTail, tail, head, isEmpty as isEmpty_1, FSharpList } from "./List.js";
6
6
  import { fold as fold_1, fill, setItem } from "./Array.js";
7
7
  import { join } from "./String.js";
8
+ import { NotSupportedException_$ctor_Z721C83C5 } from "./System.js";
8
9
  import { exists as exists_1, cache, forAll as forAll_1, fold as fold_3, reduce, iterate as iterate_1, map as map_1 } from "./Seq.js";
9
10
  import { HashSet__get_Comparer, HashSet_$ctor_Z6150332D, HashSet } from "./MutableSet.js";
10
11
  export class SetTreeLeaf$1 {
@@ -72,7 +73,7 @@ export function SetTreeModule_count(s) {
72
73
  return SetTreeModule_countAux(s, 0) | 0;
73
74
  }
74
75
  export function SetTreeModule_mk(l, k, r) {
75
- let tn, tn_1;
76
+ let tn = undefined, tn_1 = undefined;
76
77
  let hl;
77
78
  const t = l;
78
79
  if (t != null) {
@@ -100,7 +101,7 @@ export function SetTreeModule_mk(l, k, r) {
100
101
  }
101
102
  }
102
103
  export function SetTreeModule_rebalance(t1, v, t2) {
103
- let tn, tn_1, t_2, t2_3, tn_2, t_3, t2_4, tn_3;
104
+ let tn = undefined, tn_1 = undefined, t_2 = undefined, t2_3 = undefined, tn_2 = undefined, t_3 = undefined, t2_4 = undefined, tn_3 = undefined;
104
105
  let t1h;
105
106
  const t = t1;
106
107
  if (t != null) {
@@ -130,7 +131,7 @@ export function SetTreeModule_rebalance(t1, v, t2) {
130
131
  return SetTreeModule_mk(SetTreeModule_mk(t1, v, SetTreeNode$1__get_Left(t2l)), SetTreeLeaf$1__get_Key(t2l), SetTreeModule_mk(SetTreeNode$1__get_Right(t2l), SetTreeLeaf$1__get_Key(t2$0027), SetTreeNode$1__get_Right(t2$0027)));
131
132
  }
132
133
  else {
133
- throw new Error("internal error: Set.rebalance");
134
+ throw new Exception("internal error: Set.rebalance");
134
135
  }
135
136
  }
136
137
  else {
@@ -138,7 +139,7 @@ export function SetTreeModule_rebalance(t1, v, t2) {
138
139
  }
139
140
  }
140
141
  else {
141
- throw new Error("internal error: Set.rebalance");
142
+ throw new Exception("internal error: Set.rebalance");
142
143
  }
143
144
  }
144
145
  else if (t1h > (t2h + 2)) {
@@ -152,7 +153,7 @@ export function SetTreeModule_rebalance(t1, v, t2) {
152
153
  return SetTreeModule_mk(SetTreeModule_mk(SetTreeNode$1__get_Left(t1$0027), SetTreeLeaf$1__get_Key(t1$0027), SetTreeNode$1__get_Left(t1r)), SetTreeLeaf$1__get_Key(t1r), SetTreeModule_mk(SetTreeNode$1__get_Right(t1r), v, t2));
153
154
  }
154
155
  else {
155
- throw new Error("internal error: Set.rebalance");
156
+ throw new Exception("internal error: Set.rebalance");
156
157
  }
157
158
  }
158
159
  else {
@@ -160,7 +161,7 @@ export function SetTreeModule_rebalance(t1, v, t2) {
160
161
  }
161
162
  }
162
163
  else {
163
- throw new Error("internal error: Set.rebalance");
164
+ throw new Exception("internal error: Set.rebalance");
164
165
  }
165
166
  }
166
167
  else {
@@ -288,7 +289,7 @@ export function SetTreeModule_spliceOutSuccessor(t) {
288
289
  }
289
290
  }
290
291
  else {
291
- throw new Error("internal error: Set.spliceOutSuccessor");
292
+ throw new Exception("internal error: Set.spliceOutSuccessor");
292
293
  }
293
294
  }
294
295
  export function SetTreeModule_remove(comparer, k, t) {
@@ -730,7 +731,7 @@ export function SetTreeModule_maximumElementOpt(t) {
730
731
  export function SetTreeModule_minimumElement(s) {
731
732
  const matchValue = SetTreeModule_minimumElementOpt(s);
732
733
  if (matchValue == null) {
733
- throw new Error("Set contains no elements");
734
+ throw new Exception("Set contains no elements");
734
735
  }
735
736
  else {
736
737
  return value_3(matchValue);
@@ -739,7 +740,7 @@ export function SetTreeModule_minimumElement(s) {
739
740
  export function SetTreeModule_maximumElement(s) {
740
741
  const matchValue = SetTreeModule_maximumElementOpt(s);
741
742
  if (matchValue == null) {
742
- throw new Error("Set contains no elements");
743
+ throw new Exception("Set contains no elements");
743
744
  }
744
745
  else {
745
746
  return value_3(matchValue);
@@ -787,10 +788,10 @@ export function SetTreeModule_mkIterator(s) {
787
788
  return new SetTreeModule_SetIterator$1(SetTreeModule_collapseLHS(singleton_1(s)), false);
788
789
  }
789
790
  export function SetTreeModule_notStarted() {
790
- throw new Error("Enumeration not started");
791
+ throw new Exception("Enumeration not started");
791
792
  }
792
793
  export function SetTreeModule_alreadyFinished() {
793
- throw new Error("Enumeration already started");
794
+ throw new Exception("Enumeration already started");
794
795
  }
795
796
  export function SetTreeModule_current(i) {
796
797
  if (i.started) {
@@ -803,7 +804,7 @@ export function SetTreeModule_current(i) {
803
804
  return SetTreeLeaf$1__get_Key(t);
804
805
  }
805
806
  else {
806
- throw new Error("Please report error: Set iterator, unexpected stack for current");
807
+ throw new Exception("Please report error: Set iterator, unexpected stack for current");
807
808
  }
808
809
  }
809
810
  else {
@@ -817,7 +818,7 @@ export function SetTreeModule_moveNext(i) {
817
818
  if (head(matchValue) != null) {
818
819
  const t = value_3(head(matchValue));
819
820
  if (t instanceof SetTreeNode$1) {
820
- throw new Error("Please report error: Set iterator, unexpected stack for moveNext");
821
+ throw new Exception("Please report error: Set iterator, unexpected stack for moveNext");
821
822
  }
822
823
  else {
823
824
  i.stack = SetTreeModule_collapseLHS(tail(matchValue));
@@ -825,7 +826,7 @@ export function SetTreeModule_moveNext(i) {
825
826
  }
826
827
  }
827
828
  else {
828
- throw new Error("Please report error: Set iterator, unexpected stack for moveNext");
829
+ throw new Exception("Please report error: Set iterator, unexpected stack for moveNext");
829
830
  }
830
831
  }
831
832
  else {
@@ -886,7 +887,7 @@ export function SetTreeModule_compareStacks(comparer_mut, l1_mut, l2_mut) {
886
887
  }
887
888
  }
888
889
  else {
889
- let matchResult, t1_6, x1_4, t2_6, x2_4;
890
+ let matchResult = undefined, t1_6 = undefined, x1_4 = undefined, t2_6 = undefined, x2_4 = undefined;
890
891
  if (!isEmpty_1(l1)) {
891
892
  if (head(l1) != null) {
892
893
  matchResult = 0;
@@ -950,7 +951,7 @@ export function SetTreeModule_compareStacks(comparer_mut, l1_mut, l2_mut) {
950
951
  continue SetTreeModule_compareStacks;
951
952
  }
952
953
  default:
953
- throw new Error("unexpected state in SetTree.compareStacks");
954
+ throw new Exception("unexpected state in SetTree.compareStacks");
954
955
  }
955
956
  }
956
957
  }
@@ -968,7 +969,7 @@ export function SetTreeModule_compareStacks(comparer_mut, l1_mut, l2_mut) {
968
969
  }
969
970
  }
970
971
  else {
971
- let matchResult_1, t1_7, x1_5, t2_7, x2_5;
972
+ let matchResult_1 = undefined, t1_7 = undefined, x1_5 = undefined, t2_7 = undefined, x2_5 = undefined;
972
973
  if (!isEmpty_1(l1)) {
973
974
  if (head(l1) != null) {
974
975
  matchResult_1 = 0;
@@ -1032,7 +1033,7 @@ export function SetTreeModule_compareStacks(comparer_mut, l1_mut, l2_mut) {
1032
1033
  continue SetTreeModule_compareStacks;
1033
1034
  }
1034
1035
  default:
1035
- throw new Error("unexpected state in SetTree.compareStacks");
1036
+ throw new Exception("unexpected state in SetTree.compareStacks");
1036
1037
  }
1037
1038
  }
1038
1039
  }
@@ -1051,7 +1052,7 @@ export function SetTreeModule_compareStacks(comparer_mut, l1_mut, l2_mut) {
1051
1052
  }
1052
1053
  }
1053
1054
  else {
1054
- let matchResult_2, t1_8, x1_6, t2_8, x2_6;
1055
+ let matchResult_2 = undefined, t1_8 = undefined, x1_6 = undefined, t2_8 = undefined, x2_6 = undefined;
1055
1056
  if (!isEmpty_1(l1)) {
1056
1057
  if (head(l1) != null) {
1057
1058
  matchResult_2 = 0;
@@ -1115,7 +1116,7 @@ export function SetTreeModule_compareStacks(comparer_mut, l1_mut, l2_mut) {
1115
1116
  continue SetTreeModule_compareStacks;
1116
1117
  }
1117
1118
  default:
1118
- throw new Error("unexpected state in SetTree.compareStacks");
1119
+ throw new Exception("unexpected state in SetTree.compareStacks");
1119
1120
  }
1120
1121
  }
1121
1122
  }
@@ -1134,7 +1135,7 @@ export function SetTreeModule_compareStacks(comparer_mut, l1_mut, l2_mut) {
1134
1135
  }
1135
1136
  else {
1136
1137
  const x2 = value_3(head(l2));
1137
- let matchResult_3, t1_2, x1, t2_2, x2_1;
1138
+ let matchResult_3 = undefined, t1_2 = undefined, x1 = undefined, t2_2 = undefined, x2_1 = undefined;
1138
1139
  if (!isEmpty_1(l1)) {
1139
1140
  if (head(l1) != null) {
1140
1141
  matchResult_3 = 0;
@@ -1198,13 +1199,13 @@ export function SetTreeModule_compareStacks(comparer_mut, l1_mut, l2_mut) {
1198
1199
  continue SetTreeModule_compareStacks;
1199
1200
  }
1200
1201
  default:
1201
- throw new Error("unexpected state in SetTree.compareStacks");
1202
+ throw new Exception("unexpected state in SetTree.compareStacks");
1202
1203
  }
1203
1204
  }
1204
1205
  }
1205
1206
  else if (head(l1) != null) {
1206
1207
  const x1_1 = value_3(head(l1));
1207
- let matchResult_4, t1_4, x1_2, t2_4, x2_2;
1208
+ let matchResult_4 = undefined, t1_4 = undefined, x1_2 = undefined, t2_4 = undefined, x2_2 = undefined;
1208
1209
  if (!isEmpty_1(l1)) {
1209
1210
  if (head(l1) != null) {
1210
1211
  matchResult_4 = 0;
@@ -1268,7 +1269,7 @@ export function SetTreeModule_compareStacks(comparer_mut, l1_mut, l2_mut) {
1268
1269
  continue SetTreeModule_compareStacks;
1269
1270
  }
1270
1271
  default:
1271
- throw new Error("unexpected state in SetTree.compareStacks");
1272
+ throw new Exception("unexpected state in SetTree.compareStacks");
1272
1273
  }
1273
1274
  }
1274
1275
  else {
@@ -1394,17 +1395,14 @@ export class FSharpSet {
1394
1395
  const this$ = this;
1395
1396
  return FSharpSet__ComputeHashCode(this$) | 0;
1396
1397
  }
1397
- Equals(that) {
1398
- let that_1;
1398
+ Equals(other) {
1399
+ let that = undefined;
1399
1400
  const this$ = this;
1400
- return (that instanceof FSharpSet) && ((that_1 = that, SetTreeModule_compare(FSharpSet__get_Comparer(this$), FSharpSet__get_Tree(this$), FSharpSet__get_Tree(that_1)) === 0));
1401
+ return (other instanceof FSharpSet) && ((that = other, SetTreeModule_compare(FSharpSet__get_Comparer(this$), FSharpSet__get_Tree(this$), FSharpSet__get_Tree(that)) === 0));
1401
1402
  }
1402
1403
  toString() {
1403
1404
  const this$ = this;
1404
- return ("set [" + join("; ", map_1((x) => {
1405
- let copyOfStruct = x;
1406
- return toString(copyOfStruct);
1407
- }, this$))) + "]";
1405
+ return ("set [" + join("; ", this$)) + "]";
1408
1406
  }
1409
1407
  get [Symbol.toStringTag]() {
1410
1408
  return "FSharpSet";
@@ -1413,18 +1411,19 @@ export class FSharpSet {
1413
1411
  const this$ = this;
1414
1412
  return Array.from(this$);
1415
1413
  }
1416
- CompareTo(that) {
1417
- const s = this;
1418
- return SetTreeModule_compare(FSharpSet__get_Comparer(s), FSharpSet__get_Tree(s), FSharpSet__get_Tree(that)) | 0;
1414
+ CompareTo(other) {
1415
+ let that = undefined;
1416
+ const this$ = this;
1417
+ return ((other instanceof FSharpSet) ? ((that = other, SetTreeModule_compare(FSharpSet__get_Comparer(this$), FSharpSet__get_Tree(this$), FSharpSet__get_Tree(that)))) : 1) | 0;
1419
1418
  }
1420
1419
  "System.Collections.Generic.ICollection`1.Add2B595"(x) {
1421
- throw new Error("ReadOnlyCollection");
1420
+ throw NotSupportedException_$ctor_Z721C83C5("ReadOnlyCollection");
1422
1421
  }
1423
1422
  "System.Collections.Generic.ICollection`1.Clear"() {
1424
- throw new Error("ReadOnlyCollection");
1423
+ throw NotSupportedException_$ctor_Z721C83C5("ReadOnlyCollection");
1425
1424
  }
1426
1425
  "System.Collections.Generic.ICollection`1.Remove2B595"(x) {
1427
- throw new Error("ReadOnlyCollection");
1426
+ throw NotSupportedException_$ctor_Z721C83C5("ReadOnlyCollection");
1428
1427
  }
1429
1428
  "System.Collections.Generic.ICollection`1.Contains2B595"(x) {
1430
1429
  const s = this;
@@ -1462,14 +1461,14 @@ export class FSharpSet {
1462
1461
  }
1463
1462
  add(k) {
1464
1463
  const s = this;
1465
- throw new Error("Set cannot be mutated");
1464
+ throw new Exception("Set cannot be mutated");
1466
1465
  return s;
1467
1466
  }
1468
1467
  clear() {
1469
- throw new Error("Set cannot be mutated");
1468
+ throw new Exception("Set cannot be mutated");
1470
1469
  }
1471
1470
  delete(k) {
1472
- throw new Error("Set cannot be mutated");
1471
+ throw new Exception("Set cannot be mutated");
1473
1472
  return false;
1474
1473
  }
1475
1474
  has(k) {
package/String.js CHANGED
@@ -2,22 +2,31 @@ import { toString as dateToString } from "./Date.js";
2
2
  import { compare as numericCompare, isNumeric, isIntegral, multiply, toExponential, toFixed, toHex, toPrecision } from "./Numeric.js";
3
3
  import { escape } from "./RegExp.js";
4
4
  import { toString } from "./Types.js";
5
+ import { Exception } from "./Util.js";
5
6
  const fsFormatRegExp = /(^|[^%])%([0+\- ]*)(\*|\d+)?(?:\.(\d+))?(\w)/g;
6
7
  const interpolateRegExp = /(?:(^|[^%])%([0+\- ]*)(\d+)?(?:\.(\d+))?(\w))?%P\(\)/g;
7
8
  const formatRegExp = /\{(\d+)(,-?\d+)?(?:\:([a-zA-Z])(\d{0,2})|\:(.+?))?\}/g;
8
9
  function isLessThan(x, y) {
9
10
  return numericCompare(x, y) < 0;
10
11
  }
12
+ export const StringComparison = {
13
+ CurrentCulture: 0,
14
+ CurrentCultureIgnoreCase: 1,
15
+ InvariantCulture: 2,
16
+ InvariantCultureIgnoreCase: 3,
17
+ Ordinal: 4,
18
+ OrdinalIgnoreCase: 5,
19
+ };
11
20
  function cmp(x, y, ic) {
12
21
  function isIgnoreCase(i) {
13
22
  return i === true ||
14
- i === 1 /* StringComparison.CurrentCultureIgnoreCase */ ||
15
- i === 3 /* StringComparison.InvariantCultureIgnoreCase */ ||
16
- i === 5 /* StringComparison.OrdinalIgnoreCase */;
23
+ i === StringComparison.CurrentCultureIgnoreCase ||
24
+ i === StringComparison.InvariantCultureIgnoreCase ||
25
+ i === StringComparison.OrdinalIgnoreCase;
17
26
  }
18
27
  function isOrdinal(i) {
19
- return i === 4 /* StringComparison.Ordinal */ ||
20
- i === 5 /* StringComparison.OrdinalIgnoreCase */;
28
+ return i === StringComparison.Ordinal ||
29
+ i === StringComparison.OrdinalIgnoreCase;
21
30
  }
22
31
  if (x == null) {
23
32
  return y == null ? 0 : -1;
@@ -45,33 +54,33 @@ export function compare(...args) {
45
54
  case 2: return cmp(args[0], args[1], false);
46
55
  case 3: return cmp(args[0], args[1], args[2]);
47
56
  case 4: return cmp(args[0], args[1], args[2] === true);
48
- case 5: return cmp(args[0].substr(args[1], args[4]), args[2].substr(args[3], args[4]), false);
49
- case 6: return cmp(args[0].substr(args[1], args[4]), args[2].substr(args[3], args[4]), args[5]);
50
- case 7: return cmp(args[0].substr(args[1], args[4]), args[2].substr(args[3], args[4]), args[5] === true);
51
- default: throw new Error("String.compare: Unsupported number of parameters");
57
+ case 5: return cmp(args[0].slice(args[1], args[1] + args[4]), args[2].slice(args[3], args[3] + args[4]), false);
58
+ case 6: return cmp(args[0].slice(args[1], args[1] + args[4]), args[2].slice(args[3], args[3] + args[4]), args[5]);
59
+ case 7: return cmp(args[0].slice(args[1], args[1] + args[4]), args[2].slice(args[3], args[3] + args[4]), args[5] === true);
60
+ default: throw new Exception("String.compare: Unsupported number of parameters");
52
61
  }
53
62
  }
54
63
  export function compareOrdinal(x, y) {
55
- return cmp(x, y, 4 /* StringComparison.Ordinal */);
64
+ return cmp(x, y, StringComparison.Ordinal);
56
65
  }
57
66
  export function compareTo(x, y) {
58
- return cmp(x, y, 0 /* StringComparison.CurrentCulture */);
67
+ return cmp(x, y, StringComparison.CurrentCulture);
59
68
  }
60
69
  export function startsWith(str, pattern, ic) {
61
- if (ic === 4 /* StringComparison.Ordinal */) { // to avoid substring allocation
70
+ if (ic === StringComparison.Ordinal) { // to avoid substring allocation
62
71
  return str.startsWith(pattern);
63
72
  }
64
73
  if (str.length >= pattern.length) {
65
- return cmp(str.substr(0, pattern.length), pattern, ic) === 0;
74
+ return cmp(str.slice(0, pattern.length), pattern, ic) === 0;
66
75
  }
67
76
  return false;
68
77
  }
69
78
  export function endsWith(str, pattern, ic) {
70
- if (ic === 4 /* StringComparison.Ordinal */) { // to avoid substring allocation
79
+ if (ic === StringComparison.Ordinal) { // to avoid substring allocation
71
80
  return str.endsWith(pattern);
72
81
  }
73
82
  if (str.length >= pattern.length) {
74
- return cmp(str.substr(str.length - pattern.length, pattern.length), pattern, ic) === 0;
83
+ return cmp(str.slice(-pattern.length), pattern, ic) === 0;
75
84
  }
76
85
  return false;
77
86
  }
@@ -81,14 +90,14 @@ export function indexOfAny(str, anyOf, ...args) {
81
90
  }
82
91
  const startIndex = (args.length > 0) ? args[0] : 0;
83
92
  if (startIndex < 0) {
84
- throw new Error("Start index cannot be negative");
93
+ throw new Exception("Start index cannot be negative");
85
94
  }
86
95
  const length = (args.length > 1) ? args[1] : str.length - startIndex;
87
96
  if (length < 0) {
88
- throw new Error("Length cannot be negative");
97
+ throw new Exception("Length cannot be negative");
89
98
  }
90
99
  if (startIndex + length > str.length) {
91
- throw new Error("Invalid startIndex and length");
100
+ throw new Exception("Invalid startIndex and length");
92
101
  }
93
102
  const endIndex = startIndex + length;
94
103
  const anyOfAsStr = "".concat.apply("", anyOf);
@@ -143,7 +152,7 @@ export function toText(arg) {
143
152
  }
144
153
  export function toFail(arg) {
145
154
  return continuePrint((x) => {
146
- throw new Error(x);
155
+ throw new Exception(x);
147
156
  }, arg);
148
157
  }
149
158
  function formatReplacement(rep, flags, padLength, precision, format) {
@@ -230,7 +239,7 @@ function createPrinter(cont, _strParts, _matches, _result = "", padArg = -1) {
230
239
  }
231
240
  else if (padLength === "*") {
232
241
  if (arg < 0) {
233
- throw new Error("Non-negative number required");
242
+ throw new Exception("Non-negative number required");
234
243
  }
235
244
  padArg = arg;
236
245
  continue;
@@ -299,7 +308,7 @@ export function format(str, ...args) {
299
308
  }
300
309
  return str2.replace(formatRegExp, (_, idx, padLength, format, precision, pattern) => {
301
310
  if (idx < 0 || idx >= args.length) {
302
- throw new Error("Index must be greater or equal to zero and less than the arguments' length.");
311
+ throw new Exception("Index must be greater or equal to zero and less than the arguments' length.");
303
312
  }
304
313
  let rep = args[idx];
305
314
  let parts;
@@ -309,7 +318,7 @@ export function format(str, ...args) {
309
318
  case "b":
310
319
  case "B":
311
320
  if (!isIntegral(rep)) {
312
- throw new Error("Format specifier was invalid.");
321
+ throw new Exception("Format specifier was invalid.");
313
322
  }
314
323
  rep = (rep >>> 0).toString(2).replace(/^0+/, "").padStart(precision || 1, "0");
315
324
  break;
@@ -330,7 +339,7 @@ export function format(str, ...args) {
330
339
  case "d":
331
340
  case "D":
332
341
  if (!isIntegral(rep)) {
333
- throw new Error("Format specifier was invalid.");
342
+ throw new Exception("Format specifier was invalid.");
334
343
  }
335
344
  rep = String(rep);
336
345
  if (precision != null) {
@@ -377,11 +386,11 @@ export function format(str, ...args) {
377
386
  break;
378
387
  case "r":
379
388
  case "R":
380
- throw new Error("The round-trip format is not supported by Fable");
389
+ throw new Exception("The round-trip format is not supported by Fable");
381
390
  case "x":
382
391
  case "X":
383
392
  if (!isIntegral(rep)) {
384
- throw new Error("Format specifier was invalid.");
393
+ throw new Exception("Format specifier was invalid.");
385
394
  }
386
395
  precision = precision != null ? precision : 2;
387
396
  rep = padLeft(toHex(rep), precision, "0");
@@ -393,7 +402,7 @@ export function format(str, ...args) {
393
402
  // If we have format and were not able to handle it throw
394
403
  // See: https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings#standard-format-specifiers
395
404
  if (format) {
396
- throw new Error("Format specifier was invalid.");
405
+ throw new Exception("Format specifier was invalid.");
397
406
  }
398
407
  if (pattern) {
399
408
  let sign = "";
@@ -446,7 +455,7 @@ export function format(str, ...args) {
446
455
  }
447
456
  export function initialize(n, f) {
448
457
  if (n < 0) {
449
- throw new Error("String length must be non-negative");
458
+ throw new Exception("String length must be non-negative");
450
459
  }
451
460
  const xs = new Array(n);
452
461
  for (let i = 0; i < n; i++) {
@@ -456,7 +465,7 @@ export function initialize(n, f) {
456
465
  }
457
466
  export function insert(str, startIndex, value) {
458
467
  if (startIndex < 0 || startIndex > str.length) {
459
- throw new Error("startIndex is negative or greater than the length of this instance.");
468
+ throw new Exception("startIndex is negative or greater than the length of this instance.");
460
469
  }
461
470
  return str.substring(0, startIndex) + value + str.substring(startIndex);
462
471
  }
@@ -480,12 +489,12 @@ export function join(delimiter, xs) {
480
489
  export function joinWithIndices(delimiter, xs, startIndex, count) {
481
490
  const endIndexPlusOne = startIndex + count;
482
491
  if (endIndexPlusOne > xs.length) {
483
- throw new Error("Index and count must refer to a location within the buffer.");
492
+ throw new Exception("Index and count must refer to a location within the buffer.");
484
493
  }
485
494
  return xs.slice(startIndex, endIndexPlusOne).join(delimiter);
486
495
  }
487
496
  function notSupported(name) {
488
- throw new Error("The environment doesn't support '" + name + "', please use a polyfill.");
497
+ throw new Exception("The environment doesn't support '" + name + "', please use a polyfill.");
489
498
  }
490
499
  export function toBase64String(inArray) {
491
500
  let str = "";
@@ -518,10 +527,10 @@ export function padRight(str, len, ch) {
518
527
  }
519
528
  export function remove(str, startIndex, count) {
520
529
  if (startIndex >= str.length) {
521
- throw new Error("startIndex must be less than length of string");
530
+ throw new Exception("startIndex must be less than length of string");
522
531
  }
523
532
  if (typeof count === "number" && (startIndex + count) > str.length) {
524
- throw new Error("Index and count must refer to a location within the string.");
533
+ throw new Exception("Index and count must refer to a location within the string.");
525
534
  }
526
535
  return str.slice(0, startIndex) + (typeof count === "number" ? str.substr(startIndex + count) : "");
527
536
  }
@@ -533,7 +542,7 @@ export function replicate(n, x) {
533
542
  }
534
543
  export function getCharAtIndex(input, index) {
535
544
  if (index < 0 || index >= input.length) {
536
- throw new Error("Index was outside the bounds of the array.");
545
+ throw new Exception("Index was outside the bounds of the array.");
537
546
  }
538
547
  return input[index];
539
548
  }
@@ -541,7 +550,7 @@ export function split(str, splitters, count, options) {
541
550
  count = typeof count === "number" ? count : undefined;
542
551
  options = typeof options === "number" ? options : 0;
543
552
  if (count && count < 0) {
544
- throw new Error("Count cannot be less than zero");
553
+ throw new Exception("Count cannot be less than zero");
545
554
  }
546
555
  if (count === 0) {
547
556
  return [];
@@ -602,7 +611,7 @@ export function filter(pred, x) {
602
611
  }
603
612
  export function substring(str, startIndex, length) {
604
613
  if ((startIndex + (length || 0) > str.length)) {
605
- throw new Error("Invalid startIndex and/or length");
614
+ throw new Exception("Invalid startIndex and/or length");
606
615
  }
607
616
  return length != null ? str.substr(startIndex, length) : str.substr(startIndex);
608
617
  }
@@ -1,15 +1,31 @@
1
- import { disposeSafe, defaultOf, toIterator, getEnumerator, structuralHash, equals as equals_1, compare } from "./Util.js";
1
+ import { disposeSafe, defaultOf, toIterator, getEnumerator, structuralHash, equals as equals_1, compare, Exception } from "./Util.js";
2
2
  import { class_type } from "./Reflection.js";
3
+ import { SR_Arg_KeyNotFound } from "./Global.js";
3
4
  import { toArray, empty, singleton, append, enumerateWhile, delay } from "./Seq.js";
4
5
  import { setItem, initialize, copyTo, fill, item as item_1 } from "./Array.js";
5
6
  import { max } from "./Double.js";
7
+ import { ArgumentOutOfRangeException_$ctor_Z721C83C5 } from "./System.js";
8
+ export class KeyNotFoundException extends Exception {
9
+ constructor(message) {
10
+ super(message);
11
+ }
12
+ }
13
+ export function KeyNotFoundException_$reflection() {
14
+ return class_type("System.Collections.Generic.KeyNotFoundException", undefined, KeyNotFoundException, class_type("System.Exception"));
15
+ }
16
+ export function KeyNotFoundException_$ctor_Z721C83C5(message) {
17
+ return new KeyNotFoundException(message);
18
+ }
19
+ export function KeyNotFoundException_$ctor() {
20
+ return KeyNotFoundException_$ctor_Z721C83C5(SR_Arg_KeyNotFound);
21
+ }
6
22
  export class Comparer$1 {
7
23
  constructor(comparison) {
8
24
  this.comparison = comparison;
9
25
  }
10
26
  Compare(x, y) {
11
27
  const _ = this;
12
- return _.comparison(x, y) | 0;
28
+ return ((x == null) ? ((y == null) ? 0 : -1) : ((y == null) ? 1 : _.comparison(x, y))) | 0;
13
29
  }
14
30
  }
15
31
  export function Comparer$1_$reflection(gen0) {
@@ -34,7 +50,7 @@ export class EqualityComparer$1 {
34
50
  }
35
51
  Equals(x, y) {
36
52
  const _ = this;
37
- return _.equals(x, y);
53
+ return (x == null) ? (y == null) : ((y == null) ? false : _.equals(x, y));
38
54
  }
39
55
  GetHashCode(x) {
40
56
  const _ = this;
@@ -191,7 +207,7 @@ function Queue$1_$ctor_Z3B4C077E(initialContents, initialCount) {
191
207
  }
192
208
  export function Queue$1_$ctor_Z524259A4(initialCapacity) {
193
209
  if (initialCapacity < 0) {
194
- throw new Error("capacity is less than 0");
210
+ throw ArgumentOutOfRangeException_$ctor_Z721C83C5("capacity is less than 0");
195
211
  }
196
212
  return Queue$1_$ctor_Z3B4C077E(fill(new Array(initialCapacity), 0, initialCapacity, null), 0);
197
213
  }
@@ -215,7 +231,7 @@ export function Queue$1__Enqueue_2B595(_, value) {
215
231
  }
216
232
  export function Queue$1__Dequeue(_) {
217
233
  if (_.count === 0) {
218
- throw new Error("Queue is empty");
234
+ throw new Exception("Queue is empty");
219
235
  }
220
236
  const value = item_1(_.head, _.contents);
221
237
  _.head = (((_.head + 1) % Queue$1__size(_)) | 0);
@@ -224,7 +240,7 @@ export function Queue$1__Dequeue(_) {
224
240
  }
225
241
  export function Queue$1__Peek(_) {
226
242
  if (_.count === 0) {
227
- throw new Error("Queue is empty");
243
+ throw new Exception("Queue is empty");
228
244
  }
229
245
  return item_1(_.head, _.contents);
230
246
  }
package/System.Text.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { replace, format, replicate, substring, isNullOrEmpty, join } from "./String.js";
2
2
  import { class_type } from "./Reflection.js";
3
- import { clear, int32ToString } from "./Util.js";
4
3
  import { toString } from "./Types.js";
4
+ import { Exception, clear, int32ToString } from "./Util.js";
5
5
  export class StringBuilder {
6
6
  constructor(value, capacity) {
7
7
  this.buf = [];
@@ -30,11 +30,11 @@ export function StringBuilder_$ctor() {
30
30
  return StringBuilder_$ctor_Z18115A39("", 16);
31
31
  }
32
32
  export function StringBuilder__Append_Z721C83C5(x, s) {
33
- void (x.buf.push(s));
33
+ void (x.buf.push(toString(s)));
34
34
  return x;
35
35
  }
36
36
  export function StringBuilder__Append_487EF8FB(x, s, startIndex, count) {
37
- void (x.buf.push(substring(s, startIndex, count)));
37
+ void (x.buf.push(substring(toString(s), startIndex, count)));
38
38
  return x;
39
39
  }
40
40
  export function StringBuilder__Append_244C7CD6(x, c) {
@@ -67,7 +67,7 @@ export function StringBuilder__Append_Z372E4D23(x, cs) {
67
67
  return x;
68
68
  }
69
69
  export function StringBuilder__Append_43A65C09(x, s) {
70
- void (x.buf.push(toString(s)));
70
+ void (x.buf.push(s.toString()));
71
71
  return x;
72
72
  }
73
73
  export function StringBuilder__AppendFormat_433E080(x, fmt, o) {
@@ -123,7 +123,7 @@ export function StringBuilder__get_Chars_Z524259A4(x, index) {
123
123
  len = ((len + x.buf[i].length) | 0);
124
124
  }
125
125
  if (((index < 0) ? true : (i < 0)) ? true : (i >= x.buf.length)) {
126
- throw new Error("Index was outside the bounds of the array");
126
+ throw new Exception("Index was outside the bounds of the array");
127
127
  }
128
128
  else {
129
129
  const pos = ((len - index) - 1) | 0;
@@ -138,7 +138,7 @@ export function StringBuilder__set_Chars_413E0D0A(x, index, value) {
138
138
  len = ((len + x.buf[i].length) | 0);
139
139
  }
140
140
  if (((index < 0) ? true : (i < 0)) ? true : (i >= x.buf.length)) {
141
- throw new Error("Index was outside the bounds of the array");
141
+ throw new Exception("Index was outside the bounds of the array");
142
142
  }
143
143
  else {
144
144
  const pos = ((len - index) - 1) | 0;
@@ -152,7 +152,7 @@ export function StringBuilder__Replace_Z766F94C0(x, oldValue, newValue) {
152
152
  return x;
153
153
  }
154
154
  export function StringBuilder__Replace_Z384F8060(x, oldValue, newValue) {
155
- const str = replace(toString(x), oldValue, newValue);
155
+ const str = replace(x.toString(), oldValue, newValue);
156
156
  return StringBuilder__Append_Z721C83C5(StringBuilder__Clear(x), str);
157
157
  }
158
158
  export function StringBuilder__get_Length(x) {
@@ -163,5 +163,5 @@ export function StringBuilder__get_Length(x) {
163
163
  return len | 0;
164
164
  }
165
165
  export function StringBuilder__ToString_Z37302880(x, firstIndex, length) {
166
- return substring(toString(x), firstIndex, length);
166
+ return substring(x.toString(), firstIndex, length);
167
167
  }