@fable-org/fable-library-js 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 (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 +14 -0
  7. package/Char.js +64 -31
  8. package/CollectionUtil.js +3 -3
  9. package/Date.js +50 -46
  10. package/DateOffset.js +37 -47
  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/Array.js CHANGED
@@ -1,15 +1,15 @@
1
+ import { disposeSafe, getEnumerator, copyToArray, defaultOf, Exception } from "./Util.js";
1
2
  import { Helpers_allocateArrayFromCons } from "./Native.js";
2
3
  import { setItem as setItem_1, item as item_2 } from "./Array.js";
3
4
  import { value as value_2, map as map_1, defaultArg, some } from "./Option.js";
4
5
  import { min as min_1, max as max_1 } from "./Double.js";
5
- import { disposeSafe, getEnumerator, copyToArray, defaultOf } from "./Util.js";
6
6
  import { SR_indexOutOfBounds } from "./Global.js";
7
7
  import { Operators_IsNull } from "./FSharp.Core.js";
8
8
  function indexNotFound() {
9
- throw new Error("An index satisfying the predicate was not found in the collection.");
9
+ throw new Exception("An index satisfying the predicate was not found in the collection.");
10
10
  }
11
11
  function differentLengths() {
12
- throw new Error("Arrays had different lengths");
12
+ throw new Exception("Arrays had different lengths");
13
13
  }
14
14
  export function append(array1, array2, cons) {
15
15
  const len1 = array1.length | 0;
@@ -36,7 +36,7 @@ export function getSubArray(array, start, count) {
36
36
  }
37
37
  export function last(array) {
38
38
  if (array.length === 0) {
39
- throw new Error("The input array was empty\\nParameter name: array");
39
+ throw new Exception("The input array was empty\\nParameter name: array");
40
40
  }
41
41
  return item_2(array.length - 1, array);
42
42
  }
@@ -66,7 +66,7 @@ export function map(f, source, cons) {
66
66
  }
67
67
  export function mapIndexed2(f, source1, source2, cons) {
68
68
  if (source1.length !== source2.length) {
69
- throw new Error("Arrays had different lengths");
69
+ throw new Exception("Arrays had different lengths");
70
70
  }
71
71
  const result = Helpers_allocateArrayFromCons(cons, source1.length);
72
72
  for (let i = 0; i <= (source1.length - 1); i++) {
@@ -76,7 +76,7 @@ export function mapIndexed2(f, source1, source2, cons) {
76
76
  }
77
77
  export function map2(f, source1, source2, cons) {
78
78
  if (source1.length !== source2.length) {
79
- throw new Error("Arrays had different lengths");
79
+ throw new Exception("Arrays had different lengths");
80
80
  }
81
81
  const result = Helpers_allocateArrayFromCons(cons, source1.length);
82
82
  for (let i = 0; i <= (source1.length - 1); i++) {
@@ -86,7 +86,7 @@ export function map2(f, source1, source2, cons) {
86
86
  }
87
87
  export function mapIndexed3(f, source1, source2, source3, cons) {
88
88
  if ((source1.length !== source2.length) ? true : (source2.length !== source3.length)) {
89
- throw new Error("Arrays had different lengths");
89
+ throw new Exception("Arrays had different lengths");
90
90
  }
91
91
  const result = Helpers_allocateArrayFromCons(cons, source1.length);
92
92
  for (let i = 0; i <= (source1.length - 1); i++) {
@@ -96,7 +96,7 @@ export function mapIndexed3(f, source1, source2, source3, cons) {
96
96
  }
97
97
  export function map3(f, source1, source2, source3, cons) {
98
98
  if ((source1.length !== source2.length) ? true : (source2.length !== source3.length)) {
99
- throw new Error("Arrays had different lengths");
99
+ throw new Exception("Arrays had different lengths");
100
100
  }
101
101
  const result = Helpers_allocateArrayFromCons(cons, source1.length);
102
102
  for (let i = 0; i <= (source1.length - 1); i++) {
@@ -215,7 +215,7 @@ export function singleton(value, cons) {
215
215
  }
216
216
  export function initialize(count, initializer, cons) {
217
217
  if (count < 0) {
218
- throw new Error("The input must be non-negative\\nParameter name: count");
218
+ throw new Exception("The input must be non-negative\\nParameter name: count");
219
219
  }
220
220
  const result = Helpers_allocateArrayFromCons(cons, count);
221
221
  for (let i = 0; i <= (count - 1); i++) {
@@ -238,7 +238,7 @@ export function pairwise(array) {
238
238
  }
239
239
  export function replicate(count, initial, cons) {
240
240
  if (count < 0) {
241
- throw new Error("The input must be non-negative\\nParameter name: count");
241
+ throw new Exception("The input must be non-negative\\nParameter name: count");
242
242
  }
243
243
  const result = Helpers_allocateArrayFromCons(cons, count);
244
244
  for (let i = 0; i <= (result.length - 1); i++) {
@@ -274,7 +274,7 @@ export function scanBack(folder, array, state, cons) {
274
274
  }
275
275
  export function skip(count, array, cons) {
276
276
  if (count > array.length) {
277
- throw new Error("count is greater than array length\\nParameter name: count");
277
+ throw new Exception("count is greater than array length\\nParameter name: count");
278
278
  }
279
279
  if (count === array.length) {
280
280
  return Helpers_allocateArrayFromCons(cons, 0);
@@ -299,10 +299,10 @@ export function skipWhile(predicate, array, cons) {
299
299
  }
300
300
  export function take(count, array, cons) {
301
301
  if (count < 0) {
302
- throw new Error("The input must be non-negative\\nParameter name: count");
302
+ throw new Exception("The input must be non-negative\\nParameter name: count");
303
303
  }
304
304
  if (count > array.length) {
305
- throw new Error("count is greater than array length\\nParameter name: count");
305
+ throw new Exception("count is greater than array length\\nParameter name: count");
306
306
  }
307
307
  if (count === 0) {
308
308
  return Helpers_allocateArrayFromCons(cons, 0);
@@ -324,6 +324,13 @@ export function takeWhile(predicate, array, cons) {
324
324
  return array.slice(0, (0 + count_1));
325
325
  }
326
326
  }
327
+ export function findAll(predicate, array) {
328
+ return array.filter(predicate);
329
+ }
330
+ export function getRange(array, start, count) {
331
+ const start_1 = start | 0;
332
+ return array.slice(start_1, (start_1 + count));
333
+ }
327
334
  export function addInPlace(x, array) {
328
335
  array.push(x);
329
336
  }
@@ -343,7 +350,7 @@ export function insertRangeInPlace(index, range, array) {
343
350
  const enumerator = getEnumerator(range);
344
351
  try {
345
352
  while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
346
- let index_1;
353
+ let index_1 = undefined;
347
354
  const x = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
348
355
  (index_1 = (i | 0), array.splice(index_1, 0, x));
349
356
  i = ((i + 1) | 0);
@@ -365,7 +372,9 @@ export function removeInPlace(item_1, array, eq) {
365
372
  }
366
373
  export function removeAllInPlace(predicate, array) {
367
374
  const countRemoveAll = (count) => {
368
- const i = (array.findIndex(predicate)) | 0;
375
+ let i;
376
+ const array_1 = array;
377
+ i = (array_1.findIndex(predicate));
369
378
  if (i > -1) {
370
379
  array.splice(i, 1);
371
380
  return (countRemoveAll(count) + 1) | 0;
@@ -627,13 +636,13 @@ export function permute(f, array) {
627
636
  iterateIndexed((i, x) => {
628
637
  const j = f(i) | 0;
629
638
  if ((j < 0) ? true : (j >= size)) {
630
- throw new Error("Not a valid permutation");
639
+ throw new Exception("Not a valid permutation");
631
640
  }
632
641
  setItem_1(res, j, x);
633
642
  setItem_1(checkFlags, j, 1);
634
643
  }, array);
635
644
  if (!(checkFlags.every((y) => (1 === y)))) {
636
- throw new Error("Not a valid permutation");
645
+ throw new Exception("Not a valid permutation");
637
646
  }
638
647
  return res;
639
648
  }
@@ -751,25 +760,23 @@ export function zip3(array1, array2, array3) {
751
760
  }
752
761
  export function chunkBySize(chunkSize, array) {
753
762
  if (chunkSize < 1) {
754
- throw new Error("The input must be positive.\\nParameter name: size");
755
- }
756
- if (array.length === 0) {
757
- return [[]];
763
+ throw new Exception("The input must be positive.\\nParameter name: size");
758
764
  }
759
- else {
760
- const result = [];
761
- for (let x = 0; x <= (~~Math.ceil(array.length / chunkSize) - 1); x++) {
765
+ const result = [];
766
+ if (array.length > 0) {
767
+ const chunks = ~~Math.ceil(array.length / chunkSize) | 0;
768
+ for (let x = 0; x <= (chunks - 1); x++) {
762
769
  let slice;
763
770
  const start_1 = (x * chunkSize) | 0;
764
771
  slice = (array.slice(start_1, (start_1 + chunkSize)));
765
772
  result.push(slice);
766
773
  }
767
- return result;
768
774
  }
775
+ return result;
769
776
  }
770
777
  export function splitAt(index, array) {
771
778
  if ((index < 0) ? true : (index > array.length)) {
772
- throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
779
+ throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
773
780
  }
774
781
  return [array.slice(0, (0 + index)), array.slice(index)];
775
782
  }
@@ -878,9 +885,9 @@ export function exactlyOne(array) {
878
885
  case 1:
879
886
  return item_2(0, array);
880
887
  case 0:
881
- throw new Error("The input sequence was empty\\nParameter name: array");
888
+ throw new Exception("The input sequence was empty\\nParameter name: array");
882
889
  default:
883
- throw new Error("Input array too long\\nParameter name: array");
890
+ throw new Exception("Input array too long\\nParameter name: array");
884
891
  }
885
892
  }
886
893
  export function tryExactlyOne(array) {
@@ -893,7 +900,7 @@ export function tryExactlyOne(array) {
893
900
  }
894
901
  export function head(array) {
895
902
  if (array.length === 0) {
896
- throw new Error("The input array was empty\\nParameter name: array");
903
+ throw new Exception("The input array was empty\\nParameter name: array");
897
904
  }
898
905
  else {
899
906
  return item_2(0, array);
@@ -909,13 +916,13 @@ export function tryHead(array) {
909
916
  }
910
917
  export function tail(array) {
911
918
  if (array.length === 0) {
912
- throw new Error("Not enough elements\\nParameter name: array");
919
+ throw new Exception("Not enough elements\\nParameter name: array");
913
920
  }
914
921
  return array.slice(1);
915
922
  }
916
923
  export function item(index, array) {
917
924
  if ((index < 0) ? true : (index >= array.length)) {
918
- throw new Error("Index was outside the bounds of the array.\\nParameter name: index");
925
+ throw new Exception("Index was outside the bounds of the array.\\nParameter name: index");
919
926
  }
920
927
  else {
921
928
  return array[index];
@@ -923,7 +930,7 @@ export function item(index, array) {
923
930
  }
924
931
  export function setItem(array, index, value) {
925
932
  if ((index < 0) ? true : (index >= array.length)) {
926
- throw new Error("Index was outside the bounds of the array.\\nParameter name: index");
933
+ throw new Exception("Index was outside the bounds of the array.\\nParameter name: index");
927
934
  }
928
935
  else {
929
936
  array[index] = value;
@@ -946,7 +953,7 @@ export function foldBack(folder, array, state) {
946
953
  export function foldIndexed2(folder, state, array1, array2) {
947
954
  let acc = state;
948
955
  if (array1.length !== array2.length) {
949
- throw new Error("Arrays have different lengths");
956
+ throw new Exception("Arrays have different lengths");
950
957
  }
951
958
  for (let i = 0; i <= (array1.length - 1); i++) {
952
959
  acc = folder(i, acc, item_2(i, array1), item_2(i, array2));
@@ -972,14 +979,14 @@ export function foldBack2(f, array1, array2, state) {
972
979
  }
973
980
  export function reduce(reduction, array) {
974
981
  if (array.length === 0) {
975
- throw new Error("The input array was empty");
982
+ throw new Exception("The input array was empty");
976
983
  }
977
984
  const reduction_1 = reduction;
978
985
  return array.reduce(reduction_1);
979
986
  }
980
987
  export function reduceBack(reduction, array) {
981
988
  if (array.length === 0) {
982
- throw new Error("The input array was empty");
989
+ throw new Exception("The input array was empty");
983
990
  }
984
991
  const reduction_1 = reduction;
985
992
  return array.reduceRight(reduction_1);
@@ -1061,7 +1068,7 @@ export function min(xs, comparer) {
1061
1068
  }
1062
1069
  export function average(array, averager) {
1063
1070
  if (array.length === 0) {
1064
- throw new Error("The input array was empty\\nParameter name: array");
1071
+ throw new Exception("The input array was empty\\nParameter name: array");
1065
1072
  }
1066
1073
  let total = averager.GetZero();
1067
1074
  for (let i = 0; i <= (array.length - 1); i++) {
@@ -1071,7 +1078,7 @@ export function average(array, averager) {
1071
1078
  }
1072
1079
  export function averageBy(projection, array, averager) {
1073
1080
  if (array.length === 0) {
1074
- throw new Error("The input array was empty\\nParameter name: array");
1081
+ throw new Exception("The input array was empty\\nParameter name: array");
1075
1082
  }
1076
1083
  let total = averager.GetZero();
1077
1084
  for (let i = 0; i <= (array.length - 1); i++) {
@@ -1081,7 +1088,7 @@ export function averageBy(projection, array, averager) {
1081
1088
  }
1082
1089
  export function windowed(windowSize, source) {
1083
1090
  if (windowSize <= 0) {
1084
- throw new Error("windowSize must be positive");
1091
+ throw new Exception("windowSize must be positive");
1085
1092
  }
1086
1093
  let res;
1087
1094
  const len = max_1(0, (source.length - windowSize) + 1) | 0;
@@ -1093,13 +1100,10 @@ export function windowed(windowSize, source) {
1093
1100
  }
1094
1101
  export function splitInto(chunks, array) {
1095
1102
  if (chunks < 1) {
1096
- throw new Error("The input must be positive.\\nParameter name: chunks");
1097
- }
1098
- if (array.length === 0) {
1099
- return [[]];
1103
+ throw new Exception("The input must be positive.\\nParameter name: chunks");
1100
1104
  }
1101
- else {
1102
- const result = [];
1105
+ const result = [];
1106
+ if (array.length > 0) {
1103
1107
  const chunks_1 = min_1(chunks, array.length) | 0;
1104
1108
  const minChunkSize = ~~(array.length / chunks_1) | 0;
1105
1109
  const chunksWithExtraItem = (array.length % chunks_1) | 0;
@@ -1110,8 +1114,8 @@ export function splitInto(chunks, array) {
1110
1114
  slice = (array.slice(start_1, (start_1 + chunkSize)));
1111
1115
  result.push(slice);
1112
1116
  }
1113
- return result;
1114
1117
  }
1118
+ return result;
1115
1119
  }
1116
1120
  export function transpose(arrays, cons) {
1117
1121
  const arrays_1 = Array.isArray(arrays) ? arrays : (Array.from(arrays));
@@ -1138,7 +1142,7 @@ export function transpose(arrays, cons) {
1138
1142
  export function insertAt(index, y, xs, cons) {
1139
1143
  const len = xs.length | 0;
1140
1144
  if ((index < 0) ? true : (index > len)) {
1141
- throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1145
+ throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1142
1146
  }
1143
1147
  const target = Helpers_allocateArrayFromCons(cons, len + 1);
1144
1148
  for (let i = 0; i <= (index - 1); i++) {
@@ -1153,7 +1157,7 @@ export function insertAt(index, y, xs, cons) {
1153
1157
  export function insertManyAt(index, ys, xs, cons) {
1154
1158
  const len = xs.length | 0;
1155
1159
  if ((index < 0) ? true : (index > len)) {
1156
- throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1160
+ throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1157
1161
  }
1158
1162
  const ys_1 = Array.from(ys);
1159
1163
  const len2 = ys_1.length | 0;
@@ -1171,7 +1175,7 @@ export function insertManyAt(index, ys, xs, cons) {
1171
1175
  }
1172
1176
  export function removeAt(index, xs) {
1173
1177
  if ((index < 0) ? true : (index >= xs.length)) {
1174
- throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1178
+ throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1175
1179
  }
1176
1180
  let i = -1;
1177
1181
  return filter((_arg) => {
@@ -1203,14 +1207,14 @@ export function removeManyAt(index, count, xs) {
1203
1207
  }, xs);
1204
1208
  const status_1 = (((status === 0) && ((i + 1) === (index + count))) ? 1 : status) | 0;
1205
1209
  if (status_1 < 1) {
1206
- throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + ((status_1 < 0) ? "index" : "count"));
1210
+ throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + ((status_1 < 0) ? "index" : "count"));
1207
1211
  }
1208
1212
  return ys;
1209
1213
  }
1210
1214
  export function updateAt(index, y, xs, cons) {
1211
1215
  const len = xs.length | 0;
1212
1216
  if ((index < 0) ? true : (index >= len)) {
1213
- throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1217
+ throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
1214
1218
  }
1215
1219
  const target = Helpers_allocateArrayFromCons(cons, len);
1216
1220
  for (let i = 0; i <= (len - 1); i++) {
@@ -1219,9 +1223,9 @@ export function updateAt(index, y, xs, cons) {
1219
1223
  return target;
1220
1224
  }
1221
1225
  export function resize(xs, newSize, zero, cons) {
1222
- let array, array_1, start_2, count_2;
1226
+ let array = undefined, array_1 = undefined, start_2 = undefined, count_2 = undefined;
1223
1227
  if (newSize < 0) {
1224
- throw new Error("The input must be non-negative.\\nParameter name: newSize");
1228
+ throw new Exception("The input must be non-negative.\\nParameter name: newSize");
1225
1229
  }
1226
1230
  const zero_1 = defaultArg(zero, defaultOf());
1227
1231
  if (Operators_IsNull(xs.contents)) {
package/Async.js CHANGED
@@ -1,8 +1,9 @@
1
- import { OperationCanceledError, Trampoline } from "./AsyncBuilder.js";
1
+ import { OperationCanceledException, Trampoline } from "./AsyncBuilder.js";
2
2
  import { CancellationToken } from "./AsyncBuilder.js";
3
3
  import { protectedCont, protectedBind, protectedReturn } from "./AsyncBuilder.js";
4
4
  import { Choice_makeChoice1Of2, Choice_makeChoice2Of2 } from "./Choice.js";
5
- import { TimeoutException } from "./SystemException.js";
5
+ import { TimeoutException_$ctor } from "./System.js";
6
+ import { Exception } from "./Util.js";
6
7
  function emptyContinuation(_x) {
7
8
  // NOP
8
9
  }
@@ -44,7 +45,7 @@ export function isCancellationRequested(token) {
44
45
  }
45
46
  export function throwIfCancellationRequested(token) {
46
47
  if (token != null && token.isCancelled) {
47
- throw new Error("Operation is cancelled");
48
+ throw new Exception("Operation is cancelled");
48
49
  }
49
50
  }
50
51
  function throwAfter(millisecondsDueTime) {
@@ -52,11 +53,11 @@ function throwAfter(millisecondsDueTime) {
52
53
  let tokenId;
53
54
  const timeoutId = setTimeout(() => {
54
55
  ctx.cancelToken.removeListener(tokenId);
55
- ctx.onError(new TimeoutException());
56
+ ctx.onError(TimeoutException_$ctor());
56
57
  }, millisecondsDueTime);
57
58
  tokenId = ctx.cancelToken.addListener(() => {
58
59
  clearTimeout(timeoutId);
59
- ctx.onCancel(new OperationCanceledError());
60
+ ctx.onCancel(new OperationCanceledException());
60
61
  });
61
62
  });
62
63
  }
@@ -71,7 +72,7 @@ export function startChild(computation, ms) {
71
72
  return protectedCont((ctx) => protectedReturn(awaitPromise(promise))(ctx));
72
73
  }
73
74
  export function awaitPromise(p) {
74
- return fromContinuations((conts) => p.then(conts[0]).catch((err) => (err instanceof OperationCanceledError
75
+ return fromContinuations((conts) => p.then(conts[0]).catch((err) => (err instanceof OperationCanceledException
75
76
  ? conts[2] : conts[1])(err)));
76
77
  }
77
78
  export function cancellationToken() {
@@ -120,7 +121,7 @@ export function sleep(millisecondsDueTime) {
120
121
  }, millisecondsDueTime);
121
122
  tokenId = ctx.cancelToken.addListener(() => {
122
123
  clearTimeout(timeoutId);
123
- ctx.onCancel(new OperationCanceledError());
124
+ ctx.onCancel(new OperationCanceledException());
124
125
  });
125
126
  });
126
127
  }
package/AsyncBuilder.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ensureErrorOrException } from './Types.js';
1
+ import { Exception, ensureErrorOrException } from "./Util.js";
2
2
  export class CancellationToken {
3
3
  constructor(cancelled = false) {
4
4
  this._id = 0;
@@ -35,10 +35,10 @@ export class CancellationToken {
35
35
  // https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtokensource.dispose?view=net-6.0
36
36
  }
37
37
  }
38
- export class OperationCanceledError extends Error {
39
- constructor() {
40
- super("The operation was canceled");
41
- Object.setPrototypeOf(this, OperationCanceledError.prototype);
38
+ export class OperationCanceledException extends Exception {
39
+ constructor(msg) {
40
+ super(msg ?? "The operation was canceled");
41
+ // Object.setPrototypeOf(this, OperationCanceledException.prototype);
42
42
  }
43
43
  }
44
44
  export class Trampoline {
@@ -59,7 +59,7 @@ export class Trampoline {
59
59
  export function protectedCont(f) {
60
60
  return (ctx) => {
61
61
  if (ctx.cancelToken.isCancelled) {
62
- ctx.onCancel(new OperationCanceledError());
62
+ ctx.onCancel(new OperationCanceledException());
63
63
  }
64
64
  else if (ctx.trampoline.incrementAndCheck()) {
65
65
  ctx.trampoline.hijack(() => {
package/BigInt.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { fromParts, truncate } from "./Decimal.js";
2
- import { bigintHash } from "./Util.js";
2
+ import { Exception, bigintHash } from "./Util.js";
3
3
  const isBigEndian = false;
4
4
  BigInt.prototype.toJSON = function () {
5
5
  return `${this.toString()}`;
@@ -102,7 +102,7 @@ export function toIntN(bits, x, signed) {
102
102
  let higher_bits = abs(x) >> BigInt(bits);
103
103
  if (higher_bits !== 0n) {
104
104
  const s = signed ? "a signed" : "an unsigned";
105
- throw new Error(`Value was either too large or too small for ${s} ${bits}-bit integer.`);
105
+ throw new Exception(`Value was either too large or too small for ${s} ${bits}-bit integer.`);
106
106
  }
107
107
  return signed ? BigInt.asIntN(bits, x) : BigInt.asUintN(bits, x);
108
108
  }
@@ -280,7 +280,7 @@ function toSignedBytes(x, isBigEndian) {
280
280
  }
281
281
  function fromSignedBytes(bytes, isBigEndian) {
282
282
  if (bytes == null) {
283
- throw new Error("bytes is null");
283
+ throw new Exception("bytes is null");
284
284
  }
285
285
  const len = bytes.length;
286
286
  const first = isBigEndian ? 0 : len - 1;
package/Boolean.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { FSharpRef } from "./Types.js";
2
+ import { Exception } from "./Util.js";
2
3
  export function tryParse(str, defValue) {
3
4
  if (str != null && str.match(/^\s*true\s*$/i)) {
4
5
  defValue.contents = true;
@@ -16,6 +17,6 @@ export function parse(str) {
16
17
  return defValue.contents;
17
18
  }
18
19
  else {
19
- throw new Error(`String '${str}' was not recognized as a valid Boolean.`);
20
+ throw new Exception(`String '${str}' was not recognized as a valid Boolean.`);
20
21
  }
21
22
  }
package/CHANGELOG.md CHANGED
@@ -7,8 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## 2.0.0-beta.6 - 2025-12-26
11
+
12
+ ### Fixed
13
+
14
+ * [JS/TS] Fix #4305 `DateTimeOffset.Now` returns wrong time (by @ncave)
15
+
16
+ ## 2.0.0-beta.5 - 2025-11-19
17
+
18
+ ### Changed
19
+
20
+ * [JS/TS] Replace the deprecated `substr` method with `slice` (by @Thorium)
21
+
10
22
  ## 2.0.0-beta.4 - 2025-07-25
11
23
 
24
+ ### Added
25
+
12
26
  * [JS/TS] Initial support for Nullable Reference Types (by @ncave)
13
27
 
14
28
  ## 2.0.0-beta.3 - 2025-03-14
package/Char.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as Unicode from "./Unicode.13.0.0.js";
2
+ import { Exception } from "./Util.js";
2
3
  function getCategoryFunc() {
3
4
  // unpack Unicode codepoint ranges (delta encoded) and general categories
4
5
  const offset = 35; // offsets unprintable characters
@@ -30,49 +31,81 @@ function getCategoryFunc() {
30
31
  return categories[lo];
31
32
  };
32
33
  }
33
- const isControlMask = 1 << 14 /* UnicodeCategory.Control */;
34
- const isDigitMask = 1 << 8 /* UnicodeCategory.DecimalDigitNumber */;
34
+ export const UnicodeCategory = {
35
+ UppercaseLetter: 0,
36
+ LowercaseLetter: 1,
37
+ TitlecaseLetter: 2,
38
+ ModifierLetter: 3,
39
+ OtherLetter: 4,
40
+ NonSpacingMark: 5,
41
+ SpacingCombiningMark: 6,
42
+ EnclosingMark: 7,
43
+ DecimalDigitNumber: 8,
44
+ LetterNumber: 9,
45
+ OtherNumber: 10,
46
+ SpaceSeparator: 11,
47
+ LineSeparator: 12,
48
+ ParagraphSeparator: 13,
49
+ Control: 14,
50
+ Format: 15,
51
+ Surrogate: 16,
52
+ PrivateUse: 17,
53
+ ConnectorPunctuation: 18,
54
+ DashPunctuation: 19,
55
+ OpenPunctuation: 20,
56
+ ClosePunctuation: 21,
57
+ InitialQuotePunctuation: 22,
58
+ FinalQuotePunctuation: 23,
59
+ OtherPunctuation: 24,
60
+ MathSymbol: 25,
61
+ CurrencySymbol: 26,
62
+ ModifierSymbol: 27,
63
+ OtherSymbol: 28,
64
+ OtherNotAssigned: 29,
65
+ };
66
+ const isControlMask = 1 << UnicodeCategory.Control;
67
+ const isDigitMask = 1 << UnicodeCategory.DecimalDigitNumber;
35
68
  const isLetterMask = 0
36
- | 1 << 0 /* UnicodeCategory.UppercaseLetter */
37
- | 1 << 1 /* UnicodeCategory.LowercaseLetter */
38
- | 1 << 2 /* UnicodeCategory.TitlecaseLetter */
39
- | 1 << 3 /* UnicodeCategory.ModifierLetter */
40
- | 1 << 4 /* UnicodeCategory.OtherLetter */;
69
+ | 1 << UnicodeCategory.UppercaseLetter
70
+ | 1 << UnicodeCategory.LowercaseLetter
71
+ | 1 << UnicodeCategory.TitlecaseLetter
72
+ | 1 << UnicodeCategory.ModifierLetter
73
+ | 1 << UnicodeCategory.OtherLetter;
41
74
  const isLetterOrDigitMask = isLetterMask | isDigitMask;
42
- const isUpperMask = 1 << 0 /* UnicodeCategory.UppercaseLetter */;
43
- const isLowerMask = 1 << 1 /* UnicodeCategory.LowercaseLetter */;
75
+ const isUpperMask = 1 << UnicodeCategory.UppercaseLetter;
76
+ const isLowerMask = 1 << UnicodeCategory.LowercaseLetter;
44
77
  const isNumberMask = 0
45
- | 1 << 8 /* UnicodeCategory.DecimalDigitNumber */
46
- | 1 << 9 /* UnicodeCategory.LetterNumber */
47
- | 1 << 10 /* UnicodeCategory.OtherNumber */;
78
+ | 1 << UnicodeCategory.DecimalDigitNumber
79
+ | 1 << UnicodeCategory.LetterNumber
80
+ | 1 << UnicodeCategory.OtherNumber;
48
81
  const isPunctuationMask = 0
49
- | 1 << 18 /* UnicodeCategory.ConnectorPunctuation */
50
- | 1 << 19 /* UnicodeCategory.DashPunctuation */
51
- | 1 << 20 /* UnicodeCategory.OpenPunctuation */
52
- | 1 << 21 /* UnicodeCategory.ClosePunctuation */
53
- | 1 << 22 /* UnicodeCategory.InitialQuotePunctuation */
54
- | 1 << 23 /* UnicodeCategory.FinalQuotePunctuation */
55
- | 1 << 24 /* UnicodeCategory.OtherPunctuation */;
82
+ | 1 << UnicodeCategory.ConnectorPunctuation
83
+ | 1 << UnicodeCategory.DashPunctuation
84
+ | 1 << UnicodeCategory.OpenPunctuation
85
+ | 1 << UnicodeCategory.ClosePunctuation
86
+ | 1 << UnicodeCategory.InitialQuotePunctuation
87
+ | 1 << UnicodeCategory.FinalQuotePunctuation
88
+ | 1 << UnicodeCategory.OtherPunctuation;
56
89
  const isSeparatorMask = 0
57
- | 1 << 11 /* UnicodeCategory.SpaceSeparator */
58
- | 1 << 12 /* UnicodeCategory.LineSeparator */
59
- | 1 << 13 /* UnicodeCategory.ParagraphSeparator */;
90
+ | 1 << UnicodeCategory.SpaceSeparator
91
+ | 1 << UnicodeCategory.LineSeparator
92
+ | 1 << UnicodeCategory.ParagraphSeparator;
60
93
  const isSymbolMask = 0
61
- | 1 << 25 /* UnicodeCategory.MathSymbol */
62
- | 1 << 26 /* UnicodeCategory.CurrencySymbol */
63
- | 1 << 27 /* UnicodeCategory.ModifierSymbol */
64
- | 1 << 28 /* UnicodeCategory.OtherSymbol */;
94
+ | 1 << UnicodeCategory.MathSymbol
95
+ | 1 << UnicodeCategory.CurrencySymbol
96
+ | 1 << UnicodeCategory.ModifierSymbol
97
+ | 1 << UnicodeCategory.OtherSymbol;
65
98
  const isWhiteSpaceMask = 0
66
- | 1 << 11 /* UnicodeCategory.SpaceSeparator */
67
- | 1 << 12 /* UnicodeCategory.LineSeparator */
68
- | 1 << 13 /* UnicodeCategory.ParagraphSeparator */;
99
+ | 1 << UnicodeCategory.SpaceSeparator
100
+ | 1 << UnicodeCategory.LineSeparator
101
+ | 1 << UnicodeCategory.ParagraphSeparator;
69
102
  const unicodeCategoryFunc = getCategoryFunc();
70
103
  function charCodeAt(s, index) {
71
104
  if (index >= 0 && index < s.length) {
72
105
  return s.charCodeAt(index);
73
106
  }
74
107
  else {
75
- throw new Error("Index out of range.");
108
+ throw new Exception("Index out of range.");
76
109
  }
77
110
  }
78
111
  export const getUnicodeCategory = (s) => getUnicodeCategory2(s, 0);
@@ -164,6 +197,6 @@ export function parse(input) {
164
197
  return input[0];
165
198
  }
166
199
  else {
167
- throw new Error("String must be exactly one character long.");
200
+ throw new Exception("String must be exactly one character long.");
168
201
  }
169
202
  }
package/CollectionUtil.js CHANGED
@@ -1,4 +1,4 @@
1
- import { equals, isArrayLike } from "./Util.js";
1
+ import { Exception, equals, isArrayLike } from "./Util.js";
2
2
  export function count(col) {
3
3
  if (typeof col["System.Collections.Generic.ICollection`1.get_Count"] === "function") {
4
4
  return col["System.Collections.Generic.ICollection`1.get_Count"](); // collection
@@ -32,7 +32,7 @@ export function isReadOnly(col) {
32
32
  }
33
33
  else {
34
34
  if (isArrayLike(col)) {
35
- return ArrayBuffer.isView(col); // true for typed arrays, false for other arrays
35
+ return false; // array, resize array
36
36
  }
37
37
  else {
38
38
  if (typeof col.size === "number") {
@@ -105,7 +105,7 @@ export function add(col, item) {
105
105
  col.set(item[0], item[1]); // map
106
106
  }
107
107
  else {
108
- throw new Error("An item with the same key has already been added. Key: " + item[0]);
108
+ throw new Exception("An item with the same key has already been added. Key: " + item[0]);
109
109
  }
110
110
  }
111
111
  else {