@fable-org/fable-library-js 2.9.0 → 2.11.0
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 +272 -167
- package/Async.js +167 -22
- package/BigInt.js +18 -6
- package/CHANGELOG.md +52 -1
- package/Date.js +1 -1
- package/Decimal.js +70 -11
- package/Double.js +25 -10
- package/FSharp.Core.js +7 -1
- package/Global.js +1 -1
- package/Int32.js +10 -1
- package/List.js +226 -156
- package/Long.js +7 -2
- package/Map.js +46 -39
- package/MutableMap.js +76 -96
- package/MutableSet.js +58 -80
- package/NumberStyles.js +56 -0
- package/Numeric.js +10 -4
- package/Random.js +3 -4
- package/Range.js +4 -3
- package/RegExp.js +3 -2
- package/Seq.js +132 -64
- package/Seq2.js +4 -8
- package/Set.js +64 -57
- package/Stopwatch.js +65 -0
- package/String.js +18 -16
- package/System.Collections.Generic.js +3 -2
- package/System.Text.js +2 -2
- package/Task.js +22 -0
- package/TimeOnly.js +1 -1
- package/Types.js +25 -10
- package/Util.js +91 -48
- package/big.d.ts +1 -0
- package/lib/big.js +113 -70
- package/package.json +1 -1
package/Seq.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { InvalidOperationException_$ctor_Z721C83C5, NotSupportedException_$ctor_Z721C83C5 } from "./System.js";
|
|
2
|
-
import { clear,
|
|
1
|
+
import { ArgumentOutOfRangeException_$ctor_Z721C83C5, InvalidOperationException_$ctor_Z721C83C5, NotSupportedException_$ctor_Z721C83C5 } from "./System.js";
|
|
2
|
+
import { clear, isDisposable, isArrayLike, toIterator, disposeSafe, getEnumerator } from "./Util.js";
|
|
3
3
|
import { toString } from "./Types.js";
|
|
4
4
|
import { class_type } from "./Reflection.js";
|
|
5
5
|
import { some, value as value_1 } from "./Option.js";
|
|
6
6
|
import { KeyNotFoundException_$ctor_Z721C83C5 } from "./System.Collections.Generic.js";
|
|
7
|
-
import { Operators_Lock, Operators_NullArgCheck } from "./FSharp.Core.js";
|
|
8
|
-
import { randomSampleBy as randomSampleBy_1, randomChoicesBy as randomChoicesBy_1, randomChoice as randomChoice_1, randomChoiceWith as randomChoiceWith_1, randomChoiceBy as randomChoiceBy_1, randomShuffleInPlaceBy, chunkBySize as chunkBySize_1, permute as permute_1,
|
|
7
|
+
import { Operators_InvalidOp, Operators_Lock, Operators_InvalidArg, Operators_NullArgCheck } from "./FSharp.Core.js";
|
|
8
|
+
import { randomSampleBy as randomSampleBy_1, randomChoicesBy as randomChoicesBy_1, randomChoice as randomChoice_1, randomChoiceWith as randomChoiceWith_1, randomChoiceBy as randomChoiceBy_1, randomShuffleInPlaceBy, chunkBySize as chunkBySize_1, permute as permute_1, windowed as windowed_1, splitInto as splitInto_1, pairwise as pairwise_1, scanBack as scanBack_1, reverse as reverse_1, reduceBack as reduceBack_1, mapFoldBack as mapFoldBack_1, mapFold as mapFold_1, tryItem as tryItem_1, tryHead as tryHead_1, item as item_1, foldBack as foldBack_1, tryFindIndexBack as tryFindIndexBack_1, tryFindBack as tryFindBack_1, singleton as singleton_1 } from "./Array.js";
|
|
9
9
|
import { length as length_1, tryItem as tryItem_2, isEmpty as isEmpty_1, tryHead as tryHead_2, ofSeq as ofSeq_1, ofArray as ofArray_1, toArray as toArray_1, FSharpList } from "./List.js";
|
|
10
10
|
import { min as min_1 } from "./Double.js";
|
|
11
|
-
import { SR_indexOutOfBounds } from "./Global.js";
|
|
11
|
+
import { SR_indexOutOfBounds, SR_inputMustBeNonNegative } from "./Global.js";
|
|
12
12
|
import { nonSeeded } from "./Random.js";
|
|
13
13
|
export const SR_enumerationAlreadyFinished = "Enumeration already finished.";
|
|
14
14
|
export const SR_enumerationNotStarted = "Enumeration has not started. Call MoveNext.";
|
|
15
|
+
export const SR_inputMustBePositive = "The input must be positive.";
|
|
15
16
|
export const SR_inputSequenceEmpty = "The input sequence was empty.";
|
|
16
17
|
export const SR_inputSequenceTooLong = "The input sequence contains more than one element.";
|
|
17
18
|
export const SR_keyNotFoundAlt = "An index satisfying the predicate was not found in the collection.";
|
|
@@ -116,7 +117,7 @@ export function Enumerator_concat(sources) {
|
|
|
116
117
|
const finish = () => {
|
|
117
118
|
finished = true;
|
|
118
119
|
if (innerOpt != null) {
|
|
119
|
-
const inner =
|
|
120
|
+
const inner = innerOpt;
|
|
120
121
|
try {
|
|
121
122
|
disposeSafe(inner);
|
|
122
123
|
}
|
|
@@ -125,7 +126,7 @@ export function Enumerator_concat(sources) {
|
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
128
|
if (outerOpt != null) {
|
|
128
|
-
const outer =
|
|
129
|
+
const outer = outerOpt;
|
|
129
130
|
try {
|
|
130
131
|
disposeSafe(outer);
|
|
131
132
|
}
|
|
@@ -162,7 +163,7 @@ export function Enumerator_concat(sources) {
|
|
|
162
163
|
const innerOpt_1 = innerOpt;
|
|
163
164
|
if (outerOpt_1 != null) {
|
|
164
165
|
if (innerOpt_1 != null) {
|
|
165
|
-
const inner_1 =
|
|
166
|
+
const inner_1 = innerOpt_1;
|
|
166
167
|
if (inner_1["System.Collections.IEnumerator.MoveNext"]()) {
|
|
167
168
|
curr = some(inner_1["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
168
169
|
res = true;
|
|
@@ -177,7 +178,7 @@ export function Enumerator_concat(sources) {
|
|
|
177
178
|
}
|
|
178
179
|
}
|
|
179
180
|
else {
|
|
180
|
-
const outer_1 =
|
|
181
|
+
const outer_1 = outerOpt_1;
|
|
181
182
|
if (outer_1["System.Collections.IEnumerator.MoveNext"]()) {
|
|
182
183
|
const ie = outer_1["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
183
184
|
innerOpt = ((copyOfStruct = ie, getEnumerator(copyOfStruct)));
|
|
@@ -276,8 +277,8 @@ export function Enumerator_unfold(f, state) {
|
|
|
276
277
|
let acc = state;
|
|
277
278
|
return Enumerator_FromFunctions$1_$ctor_58C54629(() => {
|
|
278
279
|
if (curr != null) {
|
|
279
|
-
const x =
|
|
280
|
-
|
|
280
|
+
const x = curr[0];
|
|
281
|
+
curr[1];
|
|
281
282
|
return x;
|
|
282
283
|
}
|
|
283
284
|
else {
|
|
@@ -286,8 +287,8 @@ export function Enumerator_unfold(f, state) {
|
|
|
286
287
|
}, () => {
|
|
287
288
|
curr = f(acc);
|
|
288
289
|
if (curr != null) {
|
|
289
|
-
|
|
290
|
-
const st_1 =
|
|
290
|
+
curr[0];
|
|
291
|
+
const st_1 = curr[1];
|
|
291
292
|
acc = st_1;
|
|
292
293
|
return true;
|
|
293
294
|
}
|
|
@@ -325,12 +326,24 @@ export function ofArray(arr) {
|
|
|
325
326
|
return arr;
|
|
326
327
|
}
|
|
327
328
|
export function toArray(xs) {
|
|
328
|
-
if (xs
|
|
329
|
-
|
|
330
|
-
|
|
329
|
+
if (isArrayLike(xs)) {
|
|
330
|
+
return Array.from(xs);
|
|
331
|
+
}
|
|
332
|
+
else if (xs instanceof FSharpList) {
|
|
333
|
+
return toArray_1(xs);
|
|
331
334
|
}
|
|
332
335
|
else {
|
|
333
|
-
|
|
336
|
+
const res = [];
|
|
337
|
+
const e = getEnumerator(xs);
|
|
338
|
+
try {
|
|
339
|
+
while (e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
340
|
+
void (res.push(e["System.Collections.Generic.IEnumerator`1.get_Current"]()));
|
|
341
|
+
}
|
|
342
|
+
return res.slice();
|
|
343
|
+
}
|
|
344
|
+
finally {
|
|
345
|
+
disposeSafe(e);
|
|
346
|
+
}
|
|
334
347
|
}
|
|
335
348
|
}
|
|
336
349
|
export function ofList(xs) {
|
|
@@ -473,7 +486,7 @@ export function enumerateTryWith(source, catchFilter, catchHandler) {
|
|
|
473
486
|
en_2 = en_1;
|
|
474
487
|
}
|
|
475
488
|
else {
|
|
476
|
-
en_2 =
|
|
489
|
+
en_2 = e;
|
|
477
490
|
}
|
|
478
491
|
if (en_2["System.Collections.IEnumerator.MoveNext"]()) {
|
|
479
492
|
curr = some(en_2["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
@@ -492,7 +505,7 @@ export function enumerateTryWith(source, catchFilter, catchHandler) {
|
|
|
492
505
|
if (e == null) {
|
|
493
506
|
}
|
|
494
507
|
else {
|
|
495
|
-
const en_3 =
|
|
508
|
+
const en_3 = e;
|
|
496
509
|
try {
|
|
497
510
|
disposeSafe(en_3);
|
|
498
511
|
}
|
|
@@ -539,7 +552,7 @@ export function enumerateTryWith(source, catchFilter, catchHandler) {
|
|
|
539
552
|
if (e == null) {
|
|
540
553
|
}
|
|
541
554
|
else {
|
|
542
|
-
disposeSafe(
|
|
555
|
+
disposeSafe(e);
|
|
543
556
|
}
|
|
544
557
|
});
|
|
545
558
|
});
|
|
@@ -592,14 +605,14 @@ export function exactlyOne(xs) {
|
|
|
592
605
|
if (e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
593
606
|
const v = e["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
594
607
|
if (e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
595
|
-
throw
|
|
608
|
+
throw Operators_InvalidArg("source", SR_inputSequenceTooLong);
|
|
596
609
|
}
|
|
597
610
|
else {
|
|
598
611
|
return v;
|
|
599
612
|
}
|
|
600
613
|
}
|
|
601
614
|
else {
|
|
602
|
-
throw
|
|
615
|
+
throw Operators_InvalidArg("source", SR_inputSequenceEmpty);
|
|
603
616
|
}
|
|
604
617
|
}
|
|
605
618
|
finally {
|
|
@@ -692,7 +705,7 @@ export function findIndex(predicate, xs) {
|
|
|
692
705
|
return -1;
|
|
693
706
|
}
|
|
694
707
|
else {
|
|
695
|
-
return
|
|
708
|
+
return matchValue | 0;
|
|
696
709
|
}
|
|
697
710
|
}
|
|
698
711
|
export function tryFindIndexBack(predicate, xs) {
|
|
@@ -705,7 +718,7 @@ export function findIndexBack(predicate, xs) {
|
|
|
705
718
|
return -1;
|
|
706
719
|
}
|
|
707
720
|
else {
|
|
708
|
-
return
|
|
721
|
+
return matchValue | 0;
|
|
709
722
|
}
|
|
710
723
|
}
|
|
711
724
|
export function fold(folder, state, xs) {
|
|
@@ -779,13 +792,16 @@ export function tryHead(xs) {
|
|
|
779
792
|
export function head(xs) {
|
|
780
793
|
const matchValue = tryHead(xs);
|
|
781
794
|
if (matchValue == null) {
|
|
782
|
-
throw
|
|
795
|
+
throw Operators_InvalidArg("source", SR_inputSequenceEmpty);
|
|
783
796
|
}
|
|
784
797
|
else {
|
|
785
798
|
return value_1(matchValue);
|
|
786
799
|
}
|
|
787
800
|
}
|
|
788
801
|
export function initialize(count, f) {
|
|
802
|
+
if (count < 0) {
|
|
803
|
+
throw Operators_InvalidArg("count", SR_inputMustBeNonNegative);
|
|
804
|
+
}
|
|
789
805
|
return unfold((i) => ((i < count) ? [f(i), i + 1] : undefined), 0);
|
|
790
806
|
}
|
|
791
807
|
export function initializeInfinite(f) {
|
|
@@ -845,7 +861,7 @@ export function tryItem(index, xs) {
|
|
|
845
861
|
export function item(index, xs) {
|
|
846
862
|
const matchValue = tryItem(index, xs);
|
|
847
863
|
if (matchValue == null) {
|
|
848
|
-
throw
|
|
864
|
+
throw Operators_InvalidArg("index", SR_notEnoughElements);
|
|
849
865
|
}
|
|
850
866
|
else {
|
|
851
867
|
return value_1(matchValue);
|
|
@@ -898,7 +914,7 @@ export function tryLast(xs) {
|
|
|
898
914
|
export function last(xs) {
|
|
899
915
|
const matchValue = tryLast(xs);
|
|
900
916
|
if (matchValue == null) {
|
|
901
|
-
throw
|
|
917
|
+
throw Operators_InvalidArg("source", SR_notEnoughElements);
|
|
902
918
|
}
|
|
903
919
|
else {
|
|
904
920
|
return value_1(matchValue);
|
|
@@ -1031,7 +1047,7 @@ export function cache(source) {
|
|
|
1031
1047
|
if (enumeratorR != null) {
|
|
1032
1048
|
if (value_1(enumeratorR) != null) {
|
|
1033
1049
|
matchResult = 0;
|
|
1034
|
-
e = value_1(
|
|
1050
|
+
e = value_1(enumeratorR);
|
|
1035
1051
|
}
|
|
1036
1052
|
else {
|
|
1037
1053
|
matchResult = 1;
|
|
@@ -1066,7 +1082,7 @@ export function cache(source) {
|
|
|
1066
1082
|
if (optEnumerator_2 == null) {
|
|
1067
1083
|
}
|
|
1068
1084
|
else {
|
|
1069
|
-
const enumerator =
|
|
1085
|
+
const enumerator = optEnumerator_2;
|
|
1070
1086
|
if (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1071
1087
|
void (prefix.push(enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]()));
|
|
1072
1088
|
}
|
|
@@ -1139,7 +1155,7 @@ export function reduce(folder, xs) {
|
|
|
1139
1155
|
return loop(e["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
1140
1156
|
}
|
|
1141
1157
|
else {
|
|
1142
|
-
throw
|
|
1158
|
+
throw Operators_InvalidArg("source", SR_inputSequenceEmpty);
|
|
1143
1159
|
}
|
|
1144
1160
|
}
|
|
1145
1161
|
finally {
|
|
@@ -1149,13 +1165,16 @@ export function reduce(folder, xs) {
|
|
|
1149
1165
|
export function reduceBack(folder, xs) {
|
|
1150
1166
|
const arr = toArray(xs);
|
|
1151
1167
|
if (arr.length > 0) {
|
|
1152
|
-
return
|
|
1168
|
+
return reduceBack_1(folder, arr);
|
|
1153
1169
|
}
|
|
1154
1170
|
else {
|
|
1155
|
-
throw
|
|
1171
|
+
throw Operators_InvalidArg("source", SR_inputSequenceEmpty);
|
|
1156
1172
|
}
|
|
1157
1173
|
}
|
|
1158
1174
|
export function replicate(n, x) {
|
|
1175
|
+
if (n < 0) {
|
|
1176
|
+
throw ArgumentOutOfRangeException_$ctor_Z721C83C5("count");
|
|
1177
|
+
}
|
|
1159
1178
|
return initialize(n, (_arg) => x);
|
|
1160
1179
|
}
|
|
1161
1180
|
export function reverse(xs) {
|
|
@@ -1179,7 +1198,7 @@ export function skip(count, source) {
|
|
|
1179
1198
|
try {
|
|
1180
1199
|
for (let _ = 1; _ <= count; _++) {
|
|
1181
1200
|
if (!e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1182
|
-
throw
|
|
1201
|
+
throw Operators_InvalidOp(SR_notEnoughElements);
|
|
1183
1202
|
}
|
|
1184
1203
|
}
|
|
1185
1204
|
return Enumerator_enumerateThenFinally(() => {
|
|
@@ -1203,16 +1222,32 @@ export function skipWhile(predicate, xs) {
|
|
|
1203
1222
|
});
|
|
1204
1223
|
}
|
|
1205
1224
|
export function tail(xs) {
|
|
1206
|
-
return
|
|
1225
|
+
return mkSeq(() => {
|
|
1226
|
+
const e = ofSeq(xs);
|
|
1227
|
+
try {
|
|
1228
|
+
if (!e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1229
|
+
throw Operators_InvalidArg("source", SR_notEnoughElements);
|
|
1230
|
+
}
|
|
1231
|
+
return Enumerator_enumerateThenFinally(() => {
|
|
1232
|
+
}, e);
|
|
1233
|
+
}
|
|
1234
|
+
catch (matchValue) {
|
|
1235
|
+
disposeSafe(e);
|
|
1236
|
+
throw matchValue;
|
|
1237
|
+
}
|
|
1238
|
+
});
|
|
1207
1239
|
}
|
|
1208
1240
|
export function take(count, xs) {
|
|
1241
|
+
if (count < 0) {
|
|
1242
|
+
throw Operators_InvalidArg("count", SR_inputMustBeNonNegative);
|
|
1243
|
+
}
|
|
1209
1244
|
return generateIndexed(() => ofSeq(xs), (i, e) => {
|
|
1210
1245
|
if (i < count) {
|
|
1211
1246
|
if (e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1212
1247
|
return some(e["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
1213
1248
|
}
|
|
1214
1249
|
else {
|
|
1215
|
-
throw
|
|
1250
|
+
throw Operators_InvalidOp(SR_notEnoughElements);
|
|
1216
1251
|
}
|
|
1217
1252
|
}
|
|
1218
1253
|
else {
|
|
@@ -1248,13 +1283,47 @@ export function pairwise(xs) {
|
|
|
1248
1283
|
return delay(() => ofArray(pairwise_1(toArray(xs))));
|
|
1249
1284
|
}
|
|
1250
1285
|
export function splitInto(chunks, xs) {
|
|
1286
|
+
if (chunks < 1) {
|
|
1287
|
+
throw Operators_InvalidArg("count", SR_inputMustBePositive);
|
|
1288
|
+
}
|
|
1251
1289
|
return delay(() => ofArray(splitInto_1(chunks, toArray(xs))));
|
|
1252
1290
|
}
|
|
1253
1291
|
export function windowed(windowSize, xs) {
|
|
1292
|
+
if (windowSize < 1) {
|
|
1293
|
+
throw Operators_InvalidArg("windowSize", SR_inputMustBePositive);
|
|
1294
|
+
}
|
|
1254
1295
|
return delay(() => ofArray(windowed_1(windowSize, toArray(xs))));
|
|
1255
1296
|
}
|
|
1256
1297
|
export function transpose(xss) {
|
|
1257
|
-
return delay(() =>
|
|
1298
|
+
return delay(() => {
|
|
1299
|
+
const rows = [];
|
|
1300
|
+
const enumerator = getEnumerator(xss);
|
|
1301
|
+
try {
|
|
1302
|
+
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1303
|
+
let i = 0;
|
|
1304
|
+
let enumerator_1;
|
|
1305
|
+
let copyOfStruct = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
1306
|
+
enumerator_1 = getEnumerator(copyOfStruct);
|
|
1307
|
+
try {
|
|
1308
|
+
while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1309
|
+
const x = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
1310
|
+
if (i === rows.length) {
|
|
1311
|
+
void (rows.push([]));
|
|
1312
|
+
}
|
|
1313
|
+
void (item_1(i, rows).push(x));
|
|
1314
|
+
i = ((i + 1) | 0);
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
finally {
|
|
1318
|
+
disposeSafe(enumerator_1);
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
finally {
|
|
1323
|
+
disposeSafe(enumerator);
|
|
1324
|
+
}
|
|
1325
|
+
return map((row) => row, rows);
|
|
1326
|
+
});
|
|
1258
1327
|
}
|
|
1259
1328
|
export function sortWith(comparer, xs) {
|
|
1260
1329
|
return delay(() => {
|
|
@@ -1300,7 +1369,7 @@ export function average(xs, averager) {
|
|
|
1300
1369
|
return averager.Add(acc, x);
|
|
1301
1370
|
}, averager.GetZero(), xs);
|
|
1302
1371
|
if (count === 0) {
|
|
1303
|
-
throw
|
|
1372
|
+
throw Operators_InvalidArg("source", SR_inputSequenceEmpty);
|
|
1304
1373
|
}
|
|
1305
1374
|
else {
|
|
1306
1375
|
return averager.DivideByInt(total, count);
|
|
@@ -1313,7 +1382,7 @@ export function averageBy(f, xs, averager) {
|
|
|
1313
1382
|
return averager.Add(acc, f(x));
|
|
1314
1383
|
}, averager.GetZero(), xs);
|
|
1315
1384
|
if (count === 0) {
|
|
1316
|
-
throw
|
|
1385
|
+
throw Operators_InvalidArg("source", SR_inputSequenceEmpty);
|
|
1317
1386
|
}
|
|
1318
1387
|
else {
|
|
1319
1388
|
return averager.DivideByInt(total, count);
|
|
@@ -1323,12 +1392,15 @@ export function permute(f, xs) {
|
|
|
1323
1392
|
return delay(() => ofArray(permute_1(f, toArray(xs))));
|
|
1324
1393
|
}
|
|
1325
1394
|
export function chunkBySize(chunkSize, xs) {
|
|
1395
|
+
if (chunkSize < 1) {
|
|
1396
|
+
throw Operators_InvalidArg("chunkSize", SR_inputMustBePositive);
|
|
1397
|
+
}
|
|
1326
1398
|
return delay(() => ofArray(chunkBySize_1(chunkSize, toArray(xs))));
|
|
1327
1399
|
}
|
|
1328
1400
|
export function insertAt(index, y, xs) {
|
|
1329
1401
|
let isDone = false;
|
|
1330
1402
|
if (index < 0) {
|
|
1331
|
-
throw
|
|
1403
|
+
throw Operators_InvalidArg("index", SR_indexOutOfBounds);
|
|
1332
1404
|
}
|
|
1333
1405
|
return generateIndexed(() => ofSeq(xs), (i, e) => {
|
|
1334
1406
|
if ((isDone ? true : (i < index)) && e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
@@ -1340,7 +1412,7 @@ export function insertAt(index, y, xs) {
|
|
|
1340
1412
|
}
|
|
1341
1413
|
else {
|
|
1342
1414
|
if (!isDone) {
|
|
1343
|
-
throw
|
|
1415
|
+
throw Operators_InvalidArg("index", SR_indexOutOfBounds);
|
|
1344
1416
|
}
|
|
1345
1417
|
return undefined;
|
|
1346
1418
|
}
|
|
@@ -1351,7 +1423,7 @@ export function insertAt(index, y, xs) {
|
|
|
1351
1423
|
export function insertManyAt(index, ys, xs) {
|
|
1352
1424
|
let status = -1;
|
|
1353
1425
|
if (index < 0) {
|
|
1354
|
-
throw
|
|
1426
|
+
throw Operators_InvalidArg("index", SR_indexOutOfBounds);
|
|
1355
1427
|
}
|
|
1356
1428
|
return generateIndexed(() => [ofSeq(xs), ofSeq(ys)], (i, tupledArg) => {
|
|
1357
1429
|
const e1 = tupledArg[0];
|
|
@@ -1378,7 +1450,7 @@ export function insertManyAt(index, ys, xs) {
|
|
|
1378
1450
|
}
|
|
1379
1451
|
else {
|
|
1380
1452
|
if (status < 1) {
|
|
1381
|
-
throw
|
|
1453
|
+
throw Operators_InvalidArg("index", SR_indexOutOfBounds);
|
|
1382
1454
|
}
|
|
1383
1455
|
return undefined;
|
|
1384
1456
|
}
|
|
@@ -1394,7 +1466,7 @@ export function insertManyAt(index, ys, xs) {
|
|
|
1394
1466
|
export function removeAt(index, xs) {
|
|
1395
1467
|
let isDone = false;
|
|
1396
1468
|
if (index < 0) {
|
|
1397
|
-
throw
|
|
1469
|
+
throw Operators_InvalidArg("index", SR_indexOutOfBounds);
|
|
1398
1470
|
}
|
|
1399
1471
|
return generateIndexed(() => ofSeq(xs), (i, e) => {
|
|
1400
1472
|
if ((isDone ? true : (i < index)) && e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
@@ -1406,7 +1478,7 @@ export function removeAt(index, xs) {
|
|
|
1406
1478
|
}
|
|
1407
1479
|
else {
|
|
1408
1480
|
if (!isDone) {
|
|
1409
|
-
throw
|
|
1481
|
+
throw Operators_InvalidArg("index", SR_indexOutOfBounds);
|
|
1410
1482
|
}
|
|
1411
1483
|
return undefined;
|
|
1412
1484
|
}
|
|
@@ -1416,35 +1488,31 @@ export function removeAt(index, xs) {
|
|
|
1416
1488
|
}
|
|
1417
1489
|
export function removeManyAt(index, count, xs) {
|
|
1418
1490
|
if (index < 0) {
|
|
1419
|
-
throw
|
|
1491
|
+
throw Operators_InvalidArg("index", "index must be within bounds of the array");
|
|
1420
1492
|
}
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1493
|
+
const endIndex = (index + count) | 0;
|
|
1494
|
+
return delay(() => {
|
|
1495
|
+
let i = -1;
|
|
1496
|
+
return append(filter((_arg) => {
|
|
1497
|
+
i = ((i + 1) | 0);
|
|
1498
|
+
if (i < index) {
|
|
1499
|
+
return true;
|
|
1425
1500
|
}
|
|
1426
1501
|
else {
|
|
1427
|
-
|
|
1502
|
+
return i >= endIndex;
|
|
1428
1503
|
}
|
|
1429
|
-
}
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
for (let _ = 1; _ <= count; _++) {
|
|
1433
|
-
if (!e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1434
|
-
throw new Exception(SR_indexOutOfBounds + " (Parameter \'count\')");
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1504
|
+
}, xs), delay(() => {
|
|
1505
|
+
if (i < index) {
|
|
1506
|
+
throw Operators_InvalidArg("index", "index must be within bounds of the array");
|
|
1437
1507
|
}
|
|
1438
|
-
return
|
|
1439
|
-
}
|
|
1440
|
-
}, (e_1) => {
|
|
1441
|
-
disposeSafe(e_1);
|
|
1508
|
+
return empty();
|
|
1509
|
+
}));
|
|
1442
1510
|
});
|
|
1443
1511
|
}
|
|
1444
1512
|
export function updateAt(index, y, xs) {
|
|
1445
1513
|
let isDone = false;
|
|
1446
1514
|
if (index < 0) {
|
|
1447
|
-
throw
|
|
1515
|
+
throw Operators_InvalidArg("index", SR_indexOutOfBounds);
|
|
1448
1516
|
}
|
|
1449
1517
|
return generateIndexed(() => ofSeq(xs), (i, e) => {
|
|
1450
1518
|
if ((isDone ? true : (i < index)) && e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
@@ -1456,7 +1524,7 @@ export function updateAt(index, y, xs) {
|
|
|
1456
1524
|
}
|
|
1457
1525
|
else {
|
|
1458
1526
|
if (!isDone) {
|
|
1459
|
-
throw
|
|
1527
|
+
throw Operators_InvalidArg("index", SR_indexOutOfBounds);
|
|
1460
1528
|
}
|
|
1461
1529
|
return undefined;
|
|
1462
1530
|
}
|
package/Seq2.js
CHANGED
|
@@ -31,10 +31,8 @@ export function countBy(projection, xs, comparer) {
|
|
|
31
31
|
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
32
32
|
const key = projection(enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
33
33
|
let matchValue;
|
|
34
|
-
|
|
35
|
-
matchValue = [tryGetValue(dict, key,
|
|
36
|
-
outArg = (v | 0);
|
|
37
|
-
})), outArg];
|
|
34
|
+
const cell = new FSharpRef(0);
|
|
35
|
+
matchValue = [tryGetValue(dict, key, cell), cell.contents];
|
|
38
36
|
if (matchValue[0]) {
|
|
39
37
|
dict.set(key, matchValue[1] + 1);
|
|
40
38
|
}
|
|
@@ -60,10 +58,8 @@ export function groupBy(projection, xs, comparer) {
|
|
|
60
58
|
const x = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
61
59
|
const key = projection(x);
|
|
62
60
|
let matchValue;
|
|
63
|
-
|
|
64
|
-
matchValue = [tryGetValue(dict, key,
|
|
65
|
-
outArg = v;
|
|
66
|
-
})), outArg];
|
|
61
|
+
const cell = new FSharpRef(defaultOf());
|
|
62
|
+
matchValue = [tryGetValue(dict, key, cell), cell.contents];
|
|
67
63
|
if (matchValue[0]) {
|
|
68
64
|
void (matchValue[1].push(x));
|
|
69
65
|
}
|