@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.
- package/Array.js +64 -60
- package/Async.js +8 -7
- package/AsyncBuilder.js +6 -6
- package/BigInt.js +3 -3
- package/Boolean.js +2 -1
- package/CHANGELOG.md +12 -0
- package/Char.js +64 -31
- package/CollectionUtil.js +3 -3
- package/Date.js +50 -46
- package/DateOffset.js +38 -48
- package/DateOnly.js +6 -6
- package/Decimal.js +4 -4
- package/Double.js +2 -1
- package/FSharp.Collections.js +28 -10
- package/FSharp.Core.js +19 -19
- package/Global.js +21 -0
- package/Guid.js +5 -4
- package/Int32.js +17 -17
- package/List.js +74 -63
- package/Long.js +3 -2
- package/MailboxProcessor.js +2 -1
- package/Map.js +39 -42
- package/MapUtil.js +4 -4
- package/MutableMap.js +22 -10
- package/MutableSet.js +3 -3
- package/Native.js +9 -3
- package/Option.js +10 -2
- package/Random.js +13 -12
- package/Range.js +2 -2
- package/Reflection.js +16 -16
- package/RegExp.js +4 -3
- package/Seq.js +38 -46
- package/Set.js +41 -42
- package/String.js +44 -35
- package/System.Collections.Generic.js +22 -6
- package/System.Text.js +8 -8
- package/System.js +283 -0
- package/TimeOnly.js +6 -6
- package/TimeSpan.js +5 -5
- package/Types.js +1 -17
- package/Uri.js +25 -19
- package/Util.js +32 -9
- package/package.json +23 -23
- package/Array.d.ts +0 -123
- package/Async.d.ts +0 -26
- package/AsyncBuilder.d.ts +0 -59
- package/BigInt.d.ts +0 -129
- package/BitConverter.d.ts +0 -27
- package/Boolean.d.ts +0 -3
- package/Char.d.ts +0 -65
- package/Choice.d.ts +0 -121
- package/CollectionUtil.d.ts +0 -7
- package/ConditionalWeakTable.d.ts +0 -9
- package/Date.d.ts +0 -69
- package/DateOffset.d.ts +0 -64
- package/DateOnly.d.ts +0 -18
- package/Decimal.d.ts +0 -63
- package/Double.d.ts +0 -11
- package/Encoding.d.ts +0 -12
- package/Event.d.ts +0 -31
- package/FSharp.Collections.d.ts +0 -7
- package/FSharp.Core.CompilerServices.d.ts +0 -12
- package/FSharp.Core.d.ts +0 -31
- package/Global.d.ts +0 -24
- package/Guid.d.ts +0 -10
- package/Int32.d.ts +0 -28
- package/List.d.ts +0 -143
- package/Long.d.ts +0 -3
- package/MailboxProcessor.d.ts +0 -25
- package/Map.d.ts +0 -178
- package/MapUtil.d.ts +0 -12
- package/MutableMap.d.ts +0 -52
- package/MutableSet.d.ts +0 -39
- package/Native.d.ts +0 -2
- package/Numeric.d.ts +0 -20
- package/Observable.d.ts +0 -32
- package/Option.d.ts +0 -28
- package/Random.d.ts +0 -37
- package/Range.d.ts +0 -12
- package/Reflection.d.ts +0 -119
- package/RegExp.d.ts +0 -10
- package/Result.d.ts +0 -37
- package/Seq.d.ts +0 -165
- package/Seq2.d.ts +0 -18
- package/Set.d.ts +0 -190
- package/String.d.ts +0 -58
- package/System.Collections.Generic.d.ts +0 -79
- package/System.Text.d.ts +0 -39
- package/SystemException.d.ts +0 -5
- package/SystemException.js +0 -5
- package/TimeOnly.d.ts +0 -15
- package/TimeSpan.d.ts +0 -35
- package/Timer.d.ts +0 -19
- package/Types.d.ts +0 -58
- package/Unicode.13.0.0.d.ts +0 -2
- package/Uri.d.ts +0 -31
- package/Util.d.ts +0 -210
- 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 { equals as equals_1, 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
|
|
9
|
+
throw new Exception("An index satisfying the predicate was not found in the collection.");
|
|
10
10
|
}
|
|
11
11
|
function differentLengths() {
|
|
12
|
-
throw new
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
302
|
+
throw new Exception("The input must be non-negative\\nParameter name: count");
|
|
303
303
|
}
|
|
304
304
|
if (count > array.length) {
|
|
305
|
-
throw new
|
|
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
|
-
|
|
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;
|
|
@@ -574,7 +583,7 @@ export function choose(chooser, array, cons) {
|
|
|
574
583
|
res.push(y);
|
|
575
584
|
}
|
|
576
585
|
}
|
|
577
|
-
if (
|
|
586
|
+
if (cons == null) {
|
|
578
587
|
return res;
|
|
579
588
|
}
|
|
580
589
|
else {
|
|
@@ -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
|
|
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
|
|
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
|
|
763
|
+
throw new Exception("The input must be positive.\\nParameter name: size");
|
|
755
764
|
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
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
|
|
779
|
+
throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
|
|
773
780
|
}
|
|
774
781
|
return [array.slice(0, (0 + index)), array.slice(index)];
|
|
775
782
|
}
|
|
@@ -841,23 +848,23 @@ export function compareTo(comparer, source1, source2) {
|
|
|
841
848
|
}
|
|
842
849
|
}
|
|
843
850
|
}
|
|
844
|
-
export function equalsWith(equals,
|
|
845
|
-
if (Operators_IsNull(
|
|
846
|
-
if (Operators_IsNull(
|
|
851
|
+
export function equalsWith(equals, source1, source2) {
|
|
852
|
+
if (Operators_IsNull(source1)) {
|
|
853
|
+
if (Operators_IsNull(source2)) {
|
|
847
854
|
return true;
|
|
848
855
|
}
|
|
849
856
|
else {
|
|
850
857
|
return false;
|
|
851
858
|
}
|
|
852
859
|
}
|
|
853
|
-
else if (Operators_IsNull(
|
|
860
|
+
else if (Operators_IsNull(source2)) {
|
|
854
861
|
return false;
|
|
855
862
|
}
|
|
856
863
|
else {
|
|
857
864
|
let i = 0;
|
|
858
865
|
let result = true;
|
|
859
|
-
const length1 =
|
|
860
|
-
const length2 =
|
|
866
|
+
const length1 = source1.length | 0;
|
|
867
|
+
const length2 = source2.length | 0;
|
|
861
868
|
if (length1 > length2) {
|
|
862
869
|
return false;
|
|
863
870
|
}
|
|
@@ -866,7 +873,7 @@ export function equalsWith(equals, array1, array2) {
|
|
|
866
873
|
}
|
|
867
874
|
else {
|
|
868
875
|
while ((i < length1) && result) {
|
|
869
|
-
result = equals(item_2(i,
|
|
876
|
+
result = equals(item_2(i, source1), item_2(i, source2));
|
|
870
877
|
i = ((i + 1) | 0);
|
|
871
878
|
}
|
|
872
879
|
return result;
|
|
@@ -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
|
|
888
|
+
throw new Exception("The input sequence was empty\\nParameter name: array");
|
|
882
889
|
default:
|
|
883
|
-
throw new
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
1103
|
+
throw new Exception("The input must be positive.\\nParameter name: chunks");
|
|
1097
1104
|
}
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
}
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 {
|
|
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 {
|
|
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
|
|
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(
|
|
56
|
+
ctx.onError(TimeoutException_$ctor());
|
|
56
57
|
}, millisecondsDueTime);
|
|
57
58
|
tokenId = ctx.cancelToken.addListener(() => {
|
|
58
59
|
clearTimeout(timeoutId);
|
|
59
|
-
ctx.onCancel(new
|
|
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
|
|
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
|
|
124
|
+
ctx.onCancel(new OperationCanceledException());
|
|
124
125
|
});
|
|
125
126
|
});
|
|
126
127
|
}
|
package/AsyncBuilder.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ensureErrorOrException } from
|
|
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
|
|
39
|
-
constructor() {
|
|
40
|
-
super("The operation was canceled");
|
|
41
|
-
Object.setPrototypeOf(this,
|
|
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
|
|
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
|
|
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
|
|
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
|
|
20
|
+
throw new Exception(`String '${str}' was not recognized as a valid Boolean.`);
|
|
20
21
|
}
|
|
21
22
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,18 @@ 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.5 - 2025-11-19
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
* [JS/TS] Replace the deprecated `substr` method with `slice` (by @Thorium)
|
|
15
|
+
|
|
16
|
+
## 2.0.0-beta.4 - 2025-07-25
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
* [JS/TS] Initial support for Nullable Reference Types (by @ncave)
|
|
21
|
+
|
|
10
22
|
## 2.0.0-beta.3 - 2025-03-14
|
|
11
23
|
|
|
12
24
|
### Fixed
|
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
|
|
34
|
-
|
|
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 <<
|
|
37
|
-
| 1 <<
|
|
38
|
-
| 1 <<
|
|
39
|
-
| 1 <<
|
|
40
|
-
| 1 <<
|
|
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 <<
|
|
43
|
-
const isLowerMask = 1 <<
|
|
75
|
+
const isUpperMask = 1 << UnicodeCategory.UppercaseLetter;
|
|
76
|
+
const isLowerMask = 1 << UnicodeCategory.LowercaseLetter;
|
|
44
77
|
const isNumberMask = 0
|
|
45
|
-
| 1 <<
|
|
46
|
-
| 1 <<
|
|
47
|
-
| 1 <<
|
|
78
|
+
| 1 << UnicodeCategory.DecimalDigitNumber
|
|
79
|
+
| 1 << UnicodeCategory.LetterNumber
|
|
80
|
+
| 1 << UnicodeCategory.OtherNumber;
|
|
48
81
|
const isPunctuationMask = 0
|
|
49
|
-
| 1 <<
|
|
50
|
-
| 1 <<
|
|
51
|
-
| 1 <<
|
|
52
|
-
| 1 <<
|
|
53
|
-
| 1 <<
|
|
54
|
-
| 1 <<
|
|
55
|
-
| 1 <<
|
|
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 <<
|
|
58
|
-
| 1 <<
|
|
59
|
-
| 1 <<
|
|
90
|
+
| 1 << UnicodeCategory.SpaceSeparator
|
|
91
|
+
| 1 << UnicodeCategory.LineSeparator
|
|
92
|
+
| 1 << UnicodeCategory.ParagraphSeparator;
|
|
60
93
|
const isSymbolMask = 0
|
|
61
|
-
| 1 <<
|
|
62
|
-
| 1 <<
|
|
63
|
-
| 1 <<
|
|
64
|
-
| 1 <<
|
|
94
|
+
| 1 << UnicodeCategory.MathSymbol
|
|
95
|
+
| 1 << UnicodeCategory.CurrencySymbol
|
|
96
|
+
| 1 << UnicodeCategory.ModifierSymbol
|
|
97
|
+
| 1 << UnicodeCategory.OtherSymbol;
|
|
65
98
|
const isWhiteSpaceMask = 0
|
|
66
|
-
| 1 <<
|
|
67
|
-
| 1 <<
|
|
68
|
-
| 1 <<
|
|
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
|
|
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
|
|
200
|
+
throw new Exception("String must be exactly one character long.");
|
|
168
201
|
}
|
|
169
202
|
}
|