@fable-org/fable-library-js 1.0.0 → 1.1.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.d.ts +2 -1
- package/Array.js +99 -85
- package/CHANGELOG.md +10 -0
- package/List.js +3 -3
- package/Map.js +3 -3
- package/MutableMap.js +2 -1
- package/MutableSet.js +2 -1
- package/Random.js +7 -7
- package/Set.js +2 -2
- package/String.d.ts +1 -0
- package/String.js +3 -0
- package/System.Collections.Generic.js +11 -11
- package/System.Text.d.ts +9 -1
- package/System.Text.js +60 -8
- package/package.json +1 -1
package/Array.d.ts
CHANGED
|
@@ -88,7 +88,8 @@ export declare function tryExactlyOne<T>(array: T[]): Option<T>;
|
|
|
88
88
|
export declare function head<T>(array: T[]): T;
|
|
89
89
|
export declare function tryHead<T>(array: T[]): Option<T>;
|
|
90
90
|
export declare function tail<T>(array: T[]): T[];
|
|
91
|
-
export declare function item
|
|
91
|
+
export declare function item<T>(index: int32, array: T[]): T;
|
|
92
|
+
export declare function setItem<T>(array: T[], index: int32, value: T): void;
|
|
92
93
|
export declare function tryItem<T>(index: int32, array: T[]): Option<T>;
|
|
93
94
|
export declare function foldBackIndexed<T, State>(folder: ((arg0: int32, arg1: T, arg2: State) => State), array: T[], state: State): State;
|
|
94
95
|
export declare function foldBack<T, State>(folder: ((arg0: T, arg1: State) => State), array: T[], state: State): State;
|
package/Array.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Helpers_allocateArrayFromCons } from "./Native.js";
|
|
2
|
+
import { setItem as setItem_1, item as item_2 } from "./Array.js";
|
|
2
3
|
import { value as value_2, map as map_1, defaultArg, some } from "./Option.js";
|
|
3
4
|
import { min as min_1, max as max_1 } from "./Double.js";
|
|
4
5
|
import { equals as equals_1, disposeSafe, getEnumerator, copyToArray, defaultOf } from "./Util.js";
|
|
@@ -14,10 +15,10 @@ export function append(array1, array2, cons) {
|
|
|
14
15
|
const len2 = array2.length | 0;
|
|
15
16
|
const newArray = Helpers_allocateArrayFromCons(cons, len1 + len2);
|
|
16
17
|
for (let i = 0; i <= (len1 - 1); i++) {
|
|
17
|
-
newArray
|
|
18
|
+
setItem_1(newArray, i, item_2(i, array1));
|
|
18
19
|
}
|
|
19
20
|
for (let i_1 = 0; i_1 <= (len2 - 1); i_1++) {
|
|
20
|
-
newArray
|
|
21
|
+
setItem_1(newArray, i_1 + len1, item_2(i_1, array2));
|
|
21
22
|
}
|
|
22
23
|
return newArray;
|
|
23
24
|
}
|
|
@@ -36,21 +37,21 @@ export function last(array) {
|
|
|
36
37
|
if (array.length === 0) {
|
|
37
38
|
throw new Error("The input array was empty\\nParameter name: array");
|
|
38
39
|
}
|
|
39
|
-
return array
|
|
40
|
+
return item_2(array.length - 1, array);
|
|
40
41
|
}
|
|
41
42
|
export function tryLast(array) {
|
|
42
43
|
if (array.length === 0) {
|
|
43
44
|
return void 0;
|
|
44
45
|
}
|
|
45
46
|
else {
|
|
46
|
-
return some(array
|
|
47
|
+
return some(item_2(array.length - 1, array));
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
export function mapIndexed(f, source, cons) {
|
|
50
51
|
const len = source.length | 0;
|
|
51
52
|
const target = Helpers_allocateArrayFromCons(cons, len);
|
|
52
53
|
for (let i = 0; i <= (len - 1); i++) {
|
|
53
|
-
target
|
|
54
|
+
setItem_1(target, i, f(i, item_2(i, source)));
|
|
54
55
|
}
|
|
55
56
|
return target;
|
|
56
57
|
}
|
|
@@ -58,7 +59,7 @@ export function map(f, source, cons) {
|
|
|
58
59
|
const len = source.length | 0;
|
|
59
60
|
const target = Helpers_allocateArrayFromCons(cons, len);
|
|
60
61
|
for (let i = 0; i <= (len - 1); i++) {
|
|
61
|
-
target
|
|
62
|
+
setItem_1(target, i, f(item_2(i, source)));
|
|
62
63
|
}
|
|
63
64
|
return target;
|
|
64
65
|
}
|
|
@@ -68,7 +69,7 @@ export function mapIndexed2(f, source1, source2, cons) {
|
|
|
68
69
|
}
|
|
69
70
|
const result = Helpers_allocateArrayFromCons(cons, source1.length);
|
|
70
71
|
for (let i = 0; i <= (source1.length - 1); i++) {
|
|
71
|
-
result
|
|
72
|
+
setItem_1(result, i, f(i, item_2(i, source1), item_2(i, source2)));
|
|
72
73
|
}
|
|
73
74
|
return result;
|
|
74
75
|
}
|
|
@@ -78,7 +79,7 @@ export function map2(f, source1, source2, cons) {
|
|
|
78
79
|
}
|
|
79
80
|
const result = Helpers_allocateArrayFromCons(cons, source1.length);
|
|
80
81
|
for (let i = 0; i <= (source1.length - 1); i++) {
|
|
81
|
-
result
|
|
82
|
+
setItem_1(result, i, f(item_2(i, source1), item_2(i, source2)));
|
|
82
83
|
}
|
|
83
84
|
return result;
|
|
84
85
|
}
|
|
@@ -88,7 +89,7 @@ export function mapIndexed3(f, source1, source2, source3, cons) {
|
|
|
88
89
|
}
|
|
89
90
|
const result = Helpers_allocateArrayFromCons(cons, source1.length);
|
|
90
91
|
for (let i = 0; i <= (source1.length - 1); i++) {
|
|
91
|
-
result
|
|
92
|
+
setItem_1(result, i, f(i, item_2(i, source1), item_2(i, source2), item_2(i, source3)));
|
|
92
93
|
}
|
|
93
94
|
return result;
|
|
94
95
|
}
|
|
@@ -98,7 +99,7 @@ export function map3(f, source1, source2, source3, cons) {
|
|
|
98
99
|
}
|
|
99
100
|
const result = Helpers_allocateArrayFromCons(cons, source1.length);
|
|
100
101
|
for (let i = 0; i <= (source1.length - 1); i++) {
|
|
101
|
-
result
|
|
102
|
+
setItem_1(result, i, f(item_2(i, source1), item_2(i, source2), item_2(i, source3)));
|
|
102
103
|
}
|
|
103
104
|
return result;
|
|
104
105
|
}
|
|
@@ -111,8 +112,8 @@ export function mapFold(mapping, state, array, cons) {
|
|
|
111
112
|
let acc = state;
|
|
112
113
|
const res = Helpers_allocateArrayFromCons(cons, matchValue);
|
|
113
114
|
for (let i = 0; i <= (array.length - 1); i++) {
|
|
114
|
-
const patternInput = mapping(acc, array
|
|
115
|
-
res
|
|
115
|
+
const patternInput = mapping(acc, item_2(i, array));
|
|
116
|
+
setItem_1(res, i, patternInput[0]);
|
|
116
117
|
acc = patternInput[1];
|
|
117
118
|
}
|
|
118
119
|
return [res, acc];
|
|
@@ -127,8 +128,8 @@ export function mapFoldBack(mapping, array, state, cons) {
|
|
|
127
128
|
let acc = state;
|
|
128
129
|
const res = Helpers_allocateArrayFromCons(cons, matchValue);
|
|
129
130
|
for (let i = array.length - 1; i >= 0; i--) {
|
|
130
|
-
const patternInput = mapping(
|
|
131
|
-
res
|
|
131
|
+
const patternInput = mapping(item_2(i, array), acc);
|
|
132
|
+
setItem_1(res, i, patternInput[0]);
|
|
132
133
|
acc = patternInput[1];
|
|
133
134
|
}
|
|
134
135
|
return [res, acc];
|
|
@@ -138,7 +139,7 @@ export function indexed(source) {
|
|
|
138
139
|
const len = source.length | 0;
|
|
139
140
|
const target = new Array(len);
|
|
140
141
|
for (let i = 0; i <= (len - 1); i++) {
|
|
141
|
-
target
|
|
142
|
+
setItem_1(target, i, [i, item_2(i, source)]);
|
|
142
143
|
}
|
|
143
144
|
return target;
|
|
144
145
|
}
|
|
@@ -153,19 +154,19 @@ export function concat(arrays, cons) {
|
|
|
153
154
|
case 0:
|
|
154
155
|
return Helpers_allocateArrayFromCons(cons, 0);
|
|
155
156
|
case 1:
|
|
156
|
-
return arrays_1
|
|
157
|
+
return item_2(0, arrays_1);
|
|
157
158
|
default: {
|
|
158
159
|
let totalIdx = 0;
|
|
159
160
|
let totalLength = 0;
|
|
160
161
|
for (let idx = 0; idx <= (arrays_1.length - 1); idx++) {
|
|
161
|
-
const arr_1 = arrays_1
|
|
162
|
+
const arr_1 = item_2(idx, arrays_1);
|
|
162
163
|
totalLength = ((totalLength + arr_1.length) | 0);
|
|
163
164
|
}
|
|
164
165
|
const result = Helpers_allocateArrayFromCons(cons, totalLength);
|
|
165
166
|
for (let idx_1 = 0; idx_1 <= (arrays_1.length - 1); idx_1++) {
|
|
166
|
-
const arr_2 = arrays_1
|
|
167
|
+
const arr_2 = item_2(idx_1, arrays_1);
|
|
167
168
|
for (let j = 0; j <= (arr_2.length - 1); j++) {
|
|
168
|
-
result
|
|
169
|
+
setItem_1(result, totalIdx, item_2(j, arr_2));
|
|
169
170
|
totalIdx = ((totalIdx + 1) | 0);
|
|
170
171
|
}
|
|
171
172
|
}
|
|
@@ -188,7 +189,7 @@ export function indexOf(array, item_1, start, count, eq) {
|
|
|
188
189
|
if (i >= end$0027) {
|
|
189
190
|
return -1;
|
|
190
191
|
}
|
|
191
|
-
else if (eq.Equals(item_1, array
|
|
192
|
+
else if (eq.Equals(item_1, item_2(i, array))) {
|
|
192
193
|
return i | 0;
|
|
193
194
|
}
|
|
194
195
|
else {
|
|
@@ -208,7 +209,7 @@ export function empty(cons) {
|
|
|
208
209
|
}
|
|
209
210
|
export function singleton(value, cons) {
|
|
210
211
|
const ar = Helpers_allocateArrayFromCons(cons, 1);
|
|
211
|
-
ar
|
|
212
|
+
setItem_1(ar, 0, value);
|
|
212
213
|
return ar;
|
|
213
214
|
}
|
|
214
215
|
export function initialize(count, initializer, cons) {
|
|
@@ -217,7 +218,7 @@ export function initialize(count, initializer, cons) {
|
|
|
217
218
|
}
|
|
218
219
|
const result = Helpers_allocateArrayFromCons(cons, count);
|
|
219
220
|
for (let i = 0; i <= (count - 1); i++) {
|
|
220
|
-
result
|
|
221
|
+
setItem_1(result, i, initializer(i));
|
|
221
222
|
}
|
|
222
223
|
return result;
|
|
223
224
|
}
|
|
@@ -229,7 +230,7 @@ export function pairwise(array) {
|
|
|
229
230
|
const count = (array.length - 1) | 0;
|
|
230
231
|
const result = new Array(count);
|
|
231
232
|
for (let i = 0; i <= (count - 1); i++) {
|
|
232
|
-
result
|
|
233
|
+
setItem_1(result, i, [item_2(i, array), item_2(i + 1, array)]);
|
|
233
234
|
}
|
|
234
235
|
return result;
|
|
235
236
|
}
|
|
@@ -240,7 +241,7 @@ export function replicate(count, initial, cons) {
|
|
|
240
241
|
}
|
|
241
242
|
const result = Helpers_allocateArrayFromCons(cons, count);
|
|
242
243
|
for (let i = 0; i <= (result.length - 1); i++) {
|
|
243
|
-
result
|
|
244
|
+
setItem_1(result, i, initial);
|
|
244
245
|
}
|
|
245
246
|
return result;
|
|
246
247
|
}
|
|
@@ -256,17 +257,17 @@ export function reverse(array) {
|
|
|
256
257
|
}
|
|
257
258
|
export function scan(folder, state, array, cons) {
|
|
258
259
|
const res = Helpers_allocateArrayFromCons(cons, array.length + 1);
|
|
259
|
-
res
|
|
260
|
+
setItem_1(res, 0, state);
|
|
260
261
|
for (let i = 0; i <= (array.length - 1); i++) {
|
|
261
|
-
res
|
|
262
|
+
setItem_1(res, i + 1, folder(item_2(i, res), item_2(i, array)));
|
|
262
263
|
}
|
|
263
264
|
return res;
|
|
264
265
|
}
|
|
265
266
|
export function scanBack(folder, array, state, cons) {
|
|
266
267
|
const res = Helpers_allocateArrayFromCons(cons, array.length + 1);
|
|
267
|
-
res
|
|
268
|
+
setItem_1(res, array.length, state);
|
|
268
269
|
for (let i = array.length - 1; i >= 0; i--) {
|
|
269
|
-
res
|
|
270
|
+
setItem_1(res, i, folder(item_2(i, array), item_2(i + 1, res)));
|
|
270
271
|
}
|
|
271
272
|
return res;
|
|
272
273
|
}
|
|
@@ -284,7 +285,7 @@ export function skip(count, array, cons) {
|
|
|
284
285
|
}
|
|
285
286
|
export function skipWhile(predicate, array, cons) {
|
|
286
287
|
let count = 0;
|
|
287
|
-
while ((count < array.length) && predicate(array
|
|
288
|
+
while ((count < array.length) && predicate(item_2(count, array))) {
|
|
288
289
|
count = ((count + 1) | 0);
|
|
289
290
|
}
|
|
290
291
|
if (count === array.length) {
|
|
@@ -311,7 +312,7 @@ export function take(count, array, cons) {
|
|
|
311
312
|
}
|
|
312
313
|
export function takeWhile(predicate, array, cons) {
|
|
313
314
|
let count = 0;
|
|
314
|
-
while ((count < array.length) && predicate(array
|
|
315
|
+
while ((count < array.length) && predicate(item_2(count, array))) {
|
|
315
316
|
count = ((count + 1) | 0);
|
|
316
317
|
}
|
|
317
318
|
if (count === 0) {
|
|
@@ -381,12 +382,12 @@ export function partition(f, source, cons) {
|
|
|
381
382
|
let iTrue = 0;
|
|
382
383
|
let iFalse = 0;
|
|
383
384
|
for (let i = 0; i <= (len - 1); i++) {
|
|
384
|
-
if (f(source
|
|
385
|
-
res1
|
|
385
|
+
if (f(item_2(i, source))) {
|
|
386
|
+
setItem_1(res1, iTrue, item_2(i, source));
|
|
386
387
|
iTrue = ((iTrue + 1) | 0);
|
|
387
388
|
}
|
|
388
389
|
else {
|
|
389
|
-
res2
|
|
390
|
+
setItem_1(res2, iFalse, item_2(i, source));
|
|
390
391
|
iFalse = ((iFalse + 1) | 0);
|
|
391
392
|
}
|
|
392
393
|
}
|
|
@@ -431,7 +432,7 @@ export function pick(chooser, array) {
|
|
|
431
432
|
return indexNotFound();
|
|
432
433
|
}
|
|
433
434
|
else {
|
|
434
|
-
const matchValue = chooser(array
|
|
435
|
+
const matchValue = chooser(item_2(i, array));
|
|
435
436
|
if (matchValue != null) {
|
|
436
437
|
return value_2(matchValue);
|
|
437
438
|
}
|
|
@@ -453,7 +454,7 @@ export function tryPick(chooser, array) {
|
|
|
453
454
|
return void 0;
|
|
454
455
|
}
|
|
455
456
|
else {
|
|
456
|
-
const matchValue = chooser(array
|
|
457
|
+
const matchValue = chooser(item_2(i, array));
|
|
457
458
|
if (matchValue == null) {
|
|
458
459
|
i_mut = (i + 1);
|
|
459
460
|
continue loop;
|
|
@@ -474,8 +475,8 @@ export function findBack(predicate, array) {
|
|
|
474
475
|
if (i < 0) {
|
|
475
476
|
return indexNotFound();
|
|
476
477
|
}
|
|
477
|
-
else if (predicate(array
|
|
478
|
-
return array
|
|
478
|
+
else if (predicate(item_2(i, array))) {
|
|
479
|
+
return item_2(i, array);
|
|
479
480
|
}
|
|
480
481
|
else {
|
|
481
482
|
i_mut = (i - 1);
|
|
@@ -493,8 +494,8 @@ export function tryFindBack(predicate, array) {
|
|
|
493
494
|
if (i < 0) {
|
|
494
495
|
return void 0;
|
|
495
496
|
}
|
|
496
|
-
else if (predicate(array
|
|
497
|
-
return some(array
|
|
497
|
+
else if (predicate(item_2(i, array))) {
|
|
498
|
+
return some(item_2(i, array));
|
|
498
499
|
}
|
|
499
500
|
else {
|
|
500
501
|
i_mut = (i - 1);
|
|
@@ -512,7 +513,7 @@ export function findLastIndex(predicate, array) {
|
|
|
512
513
|
if (i < 0) {
|
|
513
514
|
return -1;
|
|
514
515
|
}
|
|
515
|
-
else if (predicate(array
|
|
516
|
+
else if (predicate(item_2(i, array))) {
|
|
516
517
|
return i | 0;
|
|
517
518
|
}
|
|
518
519
|
else {
|
|
@@ -532,7 +533,7 @@ export function findIndexBack(predicate, array) {
|
|
|
532
533
|
indexNotFound();
|
|
533
534
|
return -1;
|
|
534
535
|
}
|
|
535
|
-
else if (predicate(array
|
|
536
|
+
else if (predicate(item_2(i, array))) {
|
|
536
537
|
return i | 0;
|
|
537
538
|
}
|
|
538
539
|
else {
|
|
@@ -551,7 +552,7 @@ export function tryFindIndexBack(predicate, array) {
|
|
|
551
552
|
if (i < 0) {
|
|
552
553
|
return void 0;
|
|
553
554
|
}
|
|
554
|
-
else if (predicate(array
|
|
555
|
+
else if (predicate(item_2(i, array))) {
|
|
555
556
|
return i;
|
|
556
557
|
}
|
|
557
558
|
else {
|
|
@@ -566,7 +567,7 @@ export function tryFindIndexBack(predicate, array) {
|
|
|
566
567
|
export function choose(chooser, array, cons) {
|
|
567
568
|
const res = [];
|
|
568
569
|
for (let i = 0; i <= (array.length - 1); i++) {
|
|
569
|
-
const matchValue = chooser(array
|
|
570
|
+
const matchValue = chooser(item_2(i, array));
|
|
570
571
|
if (matchValue != null) {
|
|
571
572
|
const y = value_2(matchValue);
|
|
572
573
|
res.push(y);
|
|
@@ -588,12 +589,12 @@ export function fold(folder, state, array) {
|
|
|
588
589
|
}
|
|
589
590
|
export function iterate(action, array) {
|
|
590
591
|
for (let i = 0; i <= (array.length - 1); i++) {
|
|
591
|
-
action(array
|
|
592
|
+
action(item_2(i, array));
|
|
592
593
|
}
|
|
593
594
|
}
|
|
594
595
|
export function iterateIndexed(action, array) {
|
|
595
596
|
for (let i = 0; i <= (array.length - 1); i++) {
|
|
596
|
-
action(i, array
|
|
597
|
+
action(i, item_2(i, array));
|
|
597
598
|
}
|
|
598
599
|
}
|
|
599
600
|
export function iterate2(action, array1, array2) {
|
|
@@ -601,7 +602,7 @@ export function iterate2(action, array1, array2) {
|
|
|
601
602
|
differentLengths();
|
|
602
603
|
}
|
|
603
604
|
for (let i = 0; i <= (array1.length - 1); i++) {
|
|
604
|
-
action(array1
|
|
605
|
+
action(item_2(i, array1), item_2(i, array2));
|
|
605
606
|
}
|
|
606
607
|
}
|
|
607
608
|
export function iterateIndexed2(action, array1, array2) {
|
|
@@ -609,7 +610,7 @@ export function iterateIndexed2(action, array1, array2) {
|
|
|
609
610
|
differentLengths();
|
|
610
611
|
}
|
|
611
612
|
for (let i = 0; i <= (array1.length - 1); i++) {
|
|
612
|
-
action(i, array1
|
|
613
|
+
action(i, item_2(i, array1), item_2(i, array2));
|
|
613
614
|
}
|
|
614
615
|
}
|
|
615
616
|
export function isEmpty(array) {
|
|
@@ -627,8 +628,8 @@ export function permute(f, array) {
|
|
|
627
628
|
if ((j < 0) ? true : (j >= size)) {
|
|
628
629
|
throw new Error("Not a valid permutation");
|
|
629
630
|
}
|
|
630
|
-
res
|
|
631
|
-
checkFlags
|
|
631
|
+
setItem_1(res, j, x);
|
|
632
|
+
setItem_1(checkFlags, j, 1);
|
|
632
633
|
}, array);
|
|
633
634
|
if (!(checkFlags.every((y) => (1 === y)))) {
|
|
634
635
|
throw new Error("Not a valid permutation");
|
|
@@ -640,7 +641,7 @@ export function setSlice(target, lower, upper, source) {
|
|
|
640
641
|
const upper_1 = defaultArg(upper, -1) | 0;
|
|
641
642
|
const length = (((upper_1 >= 0) ? upper_1 : (target.length - 1)) - lower_1) | 0;
|
|
642
643
|
for (let i = 0; i <= length; i++) {
|
|
643
|
-
target
|
|
644
|
+
setItem_1(target, i + lower_1, item_2(i, source));
|
|
644
645
|
}
|
|
645
646
|
}
|
|
646
647
|
export function sortInPlaceBy(projection, xs, comparer) {
|
|
@@ -681,7 +682,7 @@ export function allPairs(xs, ys) {
|
|
|
681
682
|
const res = new Array(len1 * len2);
|
|
682
683
|
for (let i = 0; i <= (xs.length - 1); i++) {
|
|
683
684
|
for (let j = 0; j <= (ys.length - 1); j++) {
|
|
684
|
-
res
|
|
685
|
+
setItem_1(res, (i * len2) + j, [item_2(i, xs), item_2(j, ys)]);
|
|
685
686
|
}
|
|
686
687
|
}
|
|
687
688
|
return res;
|
|
@@ -710,8 +711,8 @@ export function unzip(array) {
|
|
|
710
711
|
const res1 = new Array(len);
|
|
711
712
|
const res2 = new Array(len);
|
|
712
713
|
iterateIndexed((i, tupledArg) => {
|
|
713
|
-
res1
|
|
714
|
-
res2
|
|
714
|
+
setItem_1(res1, i, tupledArg[0]);
|
|
715
|
+
setItem_1(res2, i, tupledArg[1]);
|
|
715
716
|
}, array);
|
|
716
717
|
return [res1, res2];
|
|
717
718
|
}
|
|
@@ -721,9 +722,9 @@ export function unzip3(array) {
|
|
|
721
722
|
const res2 = new Array(len);
|
|
722
723
|
const res3 = new Array(len);
|
|
723
724
|
iterateIndexed((i, tupledArg) => {
|
|
724
|
-
res1
|
|
725
|
-
res2
|
|
726
|
-
res3
|
|
725
|
+
setItem_1(res1, i, tupledArg[0]);
|
|
726
|
+
setItem_1(res2, i, tupledArg[1]);
|
|
727
|
+
setItem_1(res3, i, tupledArg[2]);
|
|
727
728
|
}, array);
|
|
728
729
|
return [res1, res2, res3];
|
|
729
730
|
}
|
|
@@ -733,7 +734,7 @@ export function zip(array1, array2) {
|
|
|
733
734
|
}
|
|
734
735
|
const result = new Array(array1.length);
|
|
735
736
|
for (let i = 0; i <= (array1.length - 1); i++) {
|
|
736
|
-
result[i
|
|
737
|
+
setItem_1(result, i, [item_2(i, array1), item_2(i, array2)]);
|
|
737
738
|
}
|
|
738
739
|
return result;
|
|
739
740
|
}
|
|
@@ -743,7 +744,7 @@ export function zip3(array1, array2, array3) {
|
|
|
743
744
|
}
|
|
744
745
|
const result = new Array(array1.length);
|
|
745
746
|
for (let i = 0; i <= (array1.length - 1); i++) {
|
|
746
|
-
result[i
|
|
747
|
+
setItem_1(result, i, [item_2(i, array1), item_2(i, array2), item_2(i, array3)]);
|
|
747
748
|
}
|
|
748
749
|
return result;
|
|
749
750
|
}
|
|
@@ -790,7 +791,7 @@ export function compareWith(comparer, source1, source2) {
|
|
|
790
791
|
let i = 0;
|
|
791
792
|
let res = 0;
|
|
792
793
|
while ((res === 0) && (i < len)) {
|
|
793
|
-
res = (comparer(source1
|
|
794
|
+
res = (comparer(item_2(i, source1), item_2(i, source2)) | 0);
|
|
794
795
|
i = ((i + 1) | 0);
|
|
795
796
|
}
|
|
796
797
|
if (res !== 0) {
|
|
@@ -832,7 +833,7 @@ export function compareTo(comparer, source1, source2) {
|
|
|
832
833
|
let i = 0;
|
|
833
834
|
let res = 0;
|
|
834
835
|
while ((res === 0) && (i < len1)) {
|
|
835
|
-
res = (comparer(source1
|
|
836
|
+
res = (comparer(item_2(i, source1), item_2(i, source2)) | 0);
|
|
836
837
|
i = ((i + 1) | 0);
|
|
837
838
|
}
|
|
838
839
|
return res | 0;
|
|
@@ -864,7 +865,7 @@ export function equalsWith(equals, array1, array2) {
|
|
|
864
865
|
}
|
|
865
866
|
else {
|
|
866
867
|
while ((i < length1) && result) {
|
|
867
|
-
result = equals(array1
|
|
868
|
+
result = equals(item_2(i, array1), item_2(i, array2));
|
|
868
869
|
i = ((i + 1) | 0);
|
|
869
870
|
}
|
|
870
871
|
return result;
|
|
@@ -874,7 +875,7 @@ export function equalsWith(equals, array1, array2) {
|
|
|
874
875
|
export function exactlyOne(array) {
|
|
875
876
|
switch (array.length) {
|
|
876
877
|
case 1:
|
|
877
|
-
return array
|
|
878
|
+
return item_2(0, array);
|
|
878
879
|
case 0:
|
|
879
880
|
throw new Error("The input sequence was empty\\nParameter name: array");
|
|
880
881
|
default:
|
|
@@ -883,7 +884,7 @@ export function exactlyOne(array) {
|
|
|
883
884
|
}
|
|
884
885
|
export function tryExactlyOne(array) {
|
|
885
886
|
if (array.length === 1) {
|
|
886
|
-
return some(array
|
|
887
|
+
return some(item_2(0, array));
|
|
887
888
|
}
|
|
888
889
|
else {
|
|
889
890
|
return void 0;
|
|
@@ -894,7 +895,7 @@ export function head(array) {
|
|
|
894
895
|
throw new Error("The input array was empty\\nParameter name: array");
|
|
895
896
|
}
|
|
896
897
|
else {
|
|
897
|
-
return array
|
|
898
|
+
return item_2(0, array);
|
|
898
899
|
}
|
|
899
900
|
}
|
|
900
901
|
export function tryHead(array) {
|
|
@@ -902,7 +903,7 @@ export function tryHead(array) {
|
|
|
902
903
|
return void 0;
|
|
903
904
|
}
|
|
904
905
|
else {
|
|
905
|
-
return some(array
|
|
906
|
+
return some(item_2(0, array));
|
|
906
907
|
}
|
|
907
908
|
}
|
|
908
909
|
export function tail(array) {
|
|
@@ -912,7 +913,20 @@ export function tail(array) {
|
|
|
912
913
|
return array.slice(1);
|
|
913
914
|
}
|
|
914
915
|
export function item(index, array) {
|
|
915
|
-
|
|
916
|
+
if ((index < 0) ? true : (index >= array.length)) {
|
|
917
|
+
throw new Error("Index was outside the bounds of the array.\\nParameter name: index");
|
|
918
|
+
}
|
|
919
|
+
else {
|
|
920
|
+
return array[index];
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
export function setItem(array, index, value) {
|
|
924
|
+
if ((index < 0) ? true : (index >= array.length)) {
|
|
925
|
+
throw new Error("Index was outside the bounds of the array.\\nParameter name: index");
|
|
926
|
+
}
|
|
927
|
+
else {
|
|
928
|
+
array[index] = value;
|
|
929
|
+
}
|
|
916
930
|
}
|
|
917
931
|
export function tryItem(index, array) {
|
|
918
932
|
if ((index < 0) ? true : (index >= array.length)) {
|
|
@@ -934,7 +948,7 @@ export function foldIndexed2(folder, state, array1, array2) {
|
|
|
934
948
|
throw new Error("Arrays have different lengths");
|
|
935
949
|
}
|
|
936
950
|
for (let i = 0; i <= (array1.length - 1); i++) {
|
|
937
|
-
acc = folder(i, acc, array1
|
|
951
|
+
acc = folder(i, acc, item_2(i, array1), item_2(i, array2));
|
|
938
952
|
}
|
|
939
953
|
return acc;
|
|
940
954
|
}
|
|
@@ -948,7 +962,7 @@ export function foldBackIndexed2(folder, array1, array2, state) {
|
|
|
948
962
|
}
|
|
949
963
|
const size = array1.length | 0;
|
|
950
964
|
for (let i = 1; i <= size; i++) {
|
|
951
|
-
acc = folder(i - 1,
|
|
965
|
+
acc = folder(i - 1, item_2(size - i, array1), item_2(size - i, array2), acc);
|
|
952
966
|
}
|
|
953
967
|
return acc;
|
|
954
968
|
}
|
|
@@ -978,7 +992,7 @@ export function existsOffset(predicate_mut, array_mut, index_mut) {
|
|
|
978
992
|
if (index === array.length) {
|
|
979
993
|
return false;
|
|
980
994
|
}
|
|
981
|
-
else if (predicate(array
|
|
995
|
+
else if (predicate(item_2(index, array))) {
|
|
982
996
|
return true;
|
|
983
997
|
}
|
|
984
998
|
else {
|
|
@@ -999,7 +1013,7 @@ export function existsOffset2(predicate_mut, array1_mut, array2_mut, index_mut)
|
|
|
999
1013
|
if (index === array1.length) {
|
|
1000
1014
|
return false;
|
|
1001
1015
|
}
|
|
1002
|
-
else if (predicate(array1
|
|
1016
|
+
else if (predicate(item_2(index, array1), item_2(index, array2))) {
|
|
1003
1017
|
return true;
|
|
1004
1018
|
}
|
|
1005
1019
|
else {
|
|
@@ -1021,14 +1035,14 @@ export function exists2(predicate, array1, array2) {
|
|
|
1021
1035
|
export function sum(array, adder) {
|
|
1022
1036
|
let acc = adder.GetZero();
|
|
1023
1037
|
for (let i = 0; i <= (array.length - 1); i++) {
|
|
1024
|
-
acc = adder.Add(acc, array
|
|
1038
|
+
acc = adder.Add(acc, item_2(i, array));
|
|
1025
1039
|
}
|
|
1026
1040
|
return acc;
|
|
1027
1041
|
}
|
|
1028
1042
|
export function sumBy(projection, array, adder) {
|
|
1029
1043
|
let acc = adder.GetZero();
|
|
1030
1044
|
for (let i = 0; i <= (array.length - 1); i++) {
|
|
1031
|
-
acc = adder.Add(acc, projection(array
|
|
1045
|
+
acc = adder.Add(acc, projection(item_2(i, array)));
|
|
1032
1046
|
}
|
|
1033
1047
|
return acc;
|
|
1034
1048
|
}
|
|
@@ -1050,7 +1064,7 @@ export function average(array, averager) {
|
|
|
1050
1064
|
}
|
|
1051
1065
|
let total = averager.GetZero();
|
|
1052
1066
|
for (let i = 0; i <= (array.length - 1); i++) {
|
|
1053
|
-
total = averager.Add(total, array
|
|
1067
|
+
total = averager.Add(total, item_2(i, array));
|
|
1054
1068
|
}
|
|
1055
1069
|
return averager.DivideByInt(total, array.length);
|
|
1056
1070
|
}
|
|
@@ -1060,7 +1074,7 @@ export function averageBy(projection, array, averager) {
|
|
|
1060
1074
|
}
|
|
1061
1075
|
let total = averager.GetZero();
|
|
1062
1076
|
for (let i = 0; i <= (array.length - 1); i++) {
|
|
1063
|
-
total = averager.Add(total, projection(array
|
|
1077
|
+
total = averager.Add(total, projection(item_2(i, array)));
|
|
1064
1078
|
}
|
|
1065
1079
|
return averager.DivideByInt(total, array.length);
|
|
1066
1080
|
}
|
|
@@ -1072,7 +1086,7 @@ export function windowed(windowSize, source) {
|
|
|
1072
1086
|
const len = max_1(0, (source.length - windowSize) + 1) | 0;
|
|
1073
1087
|
res = (new Array(len));
|
|
1074
1088
|
for (let i = windowSize; i <= source.length; i++) {
|
|
1075
|
-
res
|
|
1089
|
+
setItem_1(res, i - windowSize, source.slice(i - windowSize, (i - 1) + 1));
|
|
1076
1090
|
}
|
|
1077
1091
|
return res;
|
|
1078
1092
|
}
|
|
@@ -1105,16 +1119,16 @@ export function transpose(arrays, cons) {
|
|
|
1105
1119
|
return new Array(0);
|
|
1106
1120
|
}
|
|
1107
1121
|
else {
|
|
1108
|
-
const firstArray = arrays_1
|
|
1122
|
+
const firstArray = item_2(0, arrays_1);
|
|
1109
1123
|
const lenInner = firstArray.length | 0;
|
|
1110
1124
|
if (!forAll((a) => (a.length === lenInner), arrays_1)) {
|
|
1111
1125
|
differentLengths();
|
|
1112
1126
|
}
|
|
1113
1127
|
const result = new Array(lenInner);
|
|
1114
1128
|
for (let i = 0; i <= (lenInner - 1); i++) {
|
|
1115
|
-
result
|
|
1129
|
+
setItem_1(result, i, Helpers_allocateArrayFromCons(cons, len));
|
|
1116
1130
|
for (let j = 0; j <= (len - 1); j++) {
|
|
1117
|
-
result[
|
|
1131
|
+
item_2(i, result)[j] = item_2(i, item_2(j, arrays_1));
|
|
1118
1132
|
}
|
|
1119
1133
|
}
|
|
1120
1134
|
return result;
|
|
@@ -1127,11 +1141,11 @@ export function insertAt(index, y, xs, cons) {
|
|
|
1127
1141
|
}
|
|
1128
1142
|
const target = Helpers_allocateArrayFromCons(cons, len + 1);
|
|
1129
1143
|
for (let i = 0; i <= (index - 1); i++) {
|
|
1130
|
-
target
|
|
1144
|
+
setItem_1(target, i, item_2(i, xs));
|
|
1131
1145
|
}
|
|
1132
|
-
target
|
|
1146
|
+
setItem_1(target, index, y);
|
|
1133
1147
|
for (let i_1 = index; i_1 <= (len - 1); i_1++) {
|
|
1134
|
-
target
|
|
1148
|
+
setItem_1(target, i_1 + 1, item_2(i_1, xs));
|
|
1135
1149
|
}
|
|
1136
1150
|
return target;
|
|
1137
1151
|
}
|
|
@@ -1144,13 +1158,13 @@ export function insertManyAt(index, ys, xs, cons) {
|
|
|
1144
1158
|
const len2 = ys_1.length | 0;
|
|
1145
1159
|
const target = Helpers_allocateArrayFromCons(cons, len + len2);
|
|
1146
1160
|
for (let i = 0; i <= (index - 1); i++) {
|
|
1147
|
-
target
|
|
1161
|
+
setItem_1(target, i, item_2(i, xs));
|
|
1148
1162
|
}
|
|
1149
1163
|
for (let i_1 = 0; i_1 <= (len2 - 1); i_1++) {
|
|
1150
|
-
target
|
|
1164
|
+
setItem_1(target, index + i_1, item_2(i_1, ys_1));
|
|
1151
1165
|
}
|
|
1152
1166
|
for (let i_2 = index; i_2 <= (len - 1); i_2++) {
|
|
1153
|
-
target
|
|
1167
|
+
setItem_1(target, i_2 + len2, item_2(i_2, xs));
|
|
1154
1168
|
}
|
|
1155
1169
|
return target;
|
|
1156
1170
|
}
|
|
@@ -1199,7 +1213,7 @@ export function updateAt(index, y, xs, cons) {
|
|
|
1199
1213
|
}
|
|
1200
1214
|
const target = Helpers_allocateArrayFromCons(cons, len);
|
|
1201
1215
|
for (let i = 0; i <= (len - 1); i++) {
|
|
1202
|
-
target
|
|
1216
|
+
setItem_1(target, i, (i === index) ? y : item_2(i, xs));
|
|
1203
1217
|
}
|
|
1204
1218
|
return target;
|
|
1205
1219
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## Unreleased
|
|
9
9
|
|
|
10
|
+
## 1.1.0 - 2024-02-20
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
#### JavaScript
|
|
15
|
+
|
|
16
|
+
* [GH-3759](https://github.com/fable-compiler/Fable/issues/3759) Add `StringBuilder.Chars` (by @MangelMaxime)
|
|
17
|
+
* Add `StringBuilder.AppendFormat` (by @ncave)
|
|
18
|
+
* [GH-3748](https://github.com/fable-compiler/Fable/pull/3748) Add `Array.getItem` and `Array.setItem` (by @MangelMaxime)
|
|
19
|
+
|
|
10
20
|
## 1.0.0 - 2024-02-13
|
|
11
21
|
|
|
12
22
|
* Release stable version
|
package/List.js
CHANGED
|
@@ -4,7 +4,7 @@ import { disposeSafe, isArrayLike, defaultOf, toIterator, getEnumerator, compare
|
|
|
4
4
|
import { Record } from "./Types.js";
|
|
5
5
|
import { class_type, record_type, option_type } from "./Reflection.js";
|
|
6
6
|
import { SR_inputSequenceTooLong, SR_inputSequenceEmpty, SR_inputMustBeNonNegative, SR_notEnoughElements, SR_differentLengths, SR_keyNotFoundAlt, SR_indexOutOfBounds, SR_inputWasEmpty } from "./Global.js";
|
|
7
|
-
import { transpose as transpose_1, splitInto as splitInto_1, windowed as windowed_1, pairwise as pairwise_1, chunkBySize as chunkBySize_1, map as map_1, permute as permute_1, tryFindIndexBack as tryFindIndexBack_1, tryFindBack as tryFindBack_1, scanBack as scanBack_1, foldBack2 as foldBack2_1, foldBack as foldBack_1, fill } from "./Array.js";
|
|
7
|
+
import { transpose as transpose_1, splitInto as splitInto_1, windowed as windowed_1, pairwise as pairwise_1, chunkBySize as chunkBySize_1, map as map_1, permute as permute_1, tryFindIndexBack as tryFindIndexBack_1, tryFindBack as tryFindBack_1, scanBack as scanBack_1, item as item_1, foldBack2 as foldBack2_1, foldBack as foldBack_1, setItem, fill } from "./Array.js";
|
|
8
8
|
export class FSharpList extends Record {
|
|
9
9
|
constructor(head, tail) {
|
|
10
10
|
super();
|
|
@@ -345,7 +345,7 @@ export function toArray(xs) {
|
|
|
345
345
|
loop: while (true) {
|
|
346
346
|
const i = i_mut, xs_1 = xs_1_mut;
|
|
347
347
|
if (!FSharpList__get_IsEmpty(xs_1)) {
|
|
348
|
-
res
|
|
348
|
+
setItem(res, i, FSharpList__get_Head(xs_1));
|
|
349
349
|
i_mut = (i + 1);
|
|
350
350
|
xs_1_mut = FSharpList__get_Tail(xs_1);
|
|
351
351
|
continue loop;
|
|
@@ -454,7 +454,7 @@ export function toSeq(xs) {
|
|
|
454
454
|
export function ofArrayWithTail(xs, tail_1) {
|
|
455
455
|
let res = tail_1;
|
|
456
456
|
for (let i = xs.length - 1; i >= 0; i--) {
|
|
457
|
-
res = FSharpList_Cons_305B8EAC(
|
|
457
|
+
res = FSharpList_Cons_305B8EAC(item_1(i, xs), res);
|
|
458
458
|
}
|
|
459
459
|
return res;
|
|
460
460
|
}
|
package/Map.js
CHANGED
|
@@ -2,7 +2,7 @@ import { record_type, bool_type, list_type, option_type, class_type } from "./Re
|
|
|
2
2
|
import { some, value as value_1 } from "./Option.js";
|
|
3
3
|
import { structuralHash, compare, toIterator, equals, disposeSafe, getEnumerator, isArrayLike } from "./Util.js";
|
|
4
4
|
import { singleton, ofArrayWithTail, head, tail, isEmpty as isEmpty_1, fold as fold_1, empty as empty_1, FSharpList, cons } from "./List.js";
|
|
5
|
-
import { map as map_2, fill } from "./Array.js";
|
|
5
|
+
import { map as map_2, item, fill, setItem } from "./Array.js";
|
|
6
6
|
import { Record } from "./Types.js";
|
|
7
7
|
import { tryPick as tryPick_1, pick as pick_1, iterate as iterate_1, compareWith, map as map_1, unfold } from "./Seq.js";
|
|
8
8
|
import { format, join } from "./String.js";
|
|
@@ -750,7 +750,7 @@ export function MapTreeModule_toList(m) {
|
|
|
750
750
|
export function MapTreeModule_copyToArray(m, arr, i) {
|
|
751
751
|
let j = i;
|
|
752
752
|
MapTreeModule_iter((x, y) => {
|
|
753
|
-
arr
|
|
753
|
+
setItem(arr, j, [x, y]);
|
|
754
754
|
j = ((j + 1) | 0);
|
|
755
755
|
}, m);
|
|
756
756
|
}
|
|
@@ -782,7 +782,7 @@ export function MapTreeModule_mkFromEnumerator(comparer_mut, acc_mut, e_mut) {
|
|
|
782
782
|
export function MapTreeModule_ofArray(comparer, arr) {
|
|
783
783
|
let res = MapTreeModule_empty();
|
|
784
784
|
for (let idx = 0; idx <= (arr.length - 1); idx++) {
|
|
785
|
-
const forLoopVar = arr
|
|
785
|
+
const forLoopVar = item(idx, arr);
|
|
786
786
|
res = MapTreeModule_add(comparer, forLoopVar[0], forLoopVar[1], res);
|
|
787
787
|
}
|
|
788
788
|
return res;
|
package/MutableMap.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { disposeSafe, defaultOf, equals, toIterator, getEnumerator } from "./Util.js";
|
|
2
2
|
import { iterate, map, delay, toArray, iterateIndexed, concat } from "./Seq.js";
|
|
3
3
|
import { value as value_1 } from "./Option.js";
|
|
4
|
+
import { setItem } from "./Array.js";
|
|
4
5
|
import { FSharpRef } from "./Types.js";
|
|
5
6
|
import { class_type } from "./Reflection.js";
|
|
6
7
|
import { getItemFromDict, tryGetValue } from "./MapUtil.js";
|
|
@@ -75,7 +76,7 @@ export class Dictionary {
|
|
|
75
76
|
"System.Collections.Generic.ICollection`1.CopyToZ3B4C077E"(array, arrayIndex) {
|
|
76
77
|
const this$ = this;
|
|
77
78
|
iterateIndexed((i, e) => {
|
|
78
|
-
array
|
|
79
|
+
setItem(array, arrayIndex + i, e);
|
|
79
80
|
}, this$);
|
|
80
81
|
}
|
|
81
82
|
"System.Collections.Generic.ICollection`1.get_Count"() {
|
package/MutableSet.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { disposeSafe, defaultOf, toIterator, getEnumerator } from "./Util.js";
|
|
2
2
|
import { iterate, map, iterateIndexed, concat } from "./Seq.js";
|
|
3
|
+
import { setItem } from "./Array.js";
|
|
3
4
|
import { some } from "./Option.js";
|
|
4
5
|
import { FSharpRef } from "./Types.js";
|
|
5
6
|
import { class_type } from "./Reflection.js";
|
|
@@ -55,7 +56,7 @@ export class HashSet {
|
|
|
55
56
|
"System.Collections.Generic.ICollection`1.CopyToZ3B4C077E"(array, arrayIndex) {
|
|
56
57
|
const this$ = this;
|
|
57
58
|
iterateIndexed((i, e) => {
|
|
58
|
-
array
|
|
59
|
+
setItem(array, arrayIndex + i, e);
|
|
59
60
|
}, this$);
|
|
60
61
|
}
|
|
61
62
|
"System.Collections.Generic.ICollection`1.get_Count"() {
|
package/Random.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { class_type } from "./Reflection.js";
|
|
2
2
|
import { fromFloat64, op_Addition, toInt32, toFloat64, compare, fromInt32, toInt64 } from "./BigInt.js";
|
|
3
|
-
import { fill } from "./Array.js";
|
|
3
|
+
import { item, fill, setItem } from "./Array.js";
|
|
4
4
|
function Native_random() {
|
|
5
5
|
return Math.random();
|
|
6
6
|
}
|
|
@@ -73,13 +73,13 @@ export class Seeded {
|
|
|
73
73
|
if (mk < 0) {
|
|
74
74
|
mk = ((mk + this.MBIG) | 0);
|
|
75
75
|
}
|
|
76
|
-
mj = (this.seedArray
|
|
76
|
+
mj = (item(ii, this.seedArray) | 0);
|
|
77
77
|
}
|
|
78
78
|
for (let k = 1; k <= 4; k++) {
|
|
79
79
|
for (let i_1 = 1; i_1 <= 55; i_1++) {
|
|
80
|
-
this.seedArray[i_1] = ((this.seedArray
|
|
81
|
-
if (this.seedArray
|
|
82
|
-
this.seedArray[i_1] = ((this.seedArray
|
|
80
|
+
this.seedArray[i_1] = ((item(i_1, this.seedArray) - item(1 + ((i_1 + 30) % 55), this.seedArray)) | 0);
|
|
81
|
+
if (item(i_1, this.seedArray) < 0) {
|
|
82
|
+
this.seedArray[i_1] = ((item(i_1, this.seedArray) + this.MBIG) | 0);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -115,7 +115,7 @@ export class Seeded {
|
|
|
115
115
|
throw new Error("buffer");
|
|
116
116
|
}
|
|
117
117
|
for (let i = 0; i <= (buffer.length - 1); i++) {
|
|
118
|
-
buffer
|
|
118
|
+
setItem(buffer, i, (Seeded__InternalSample(this$) % (~~255 + 1)) & 0xFF);
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
}
|
|
@@ -137,7 +137,7 @@ function Seeded__InternalSample(_) {
|
|
|
137
137
|
if (locINextp >= 56) {
|
|
138
138
|
locINextp = 1;
|
|
139
139
|
}
|
|
140
|
-
retVal = ((_.seedArray
|
|
140
|
+
retVal = ((item(locINext, _.seedArray) - item(locINextp, _.seedArray)) | 0);
|
|
141
141
|
if (retVal === _.MBIG) {
|
|
142
142
|
retVal = ((retVal - 1) | 0);
|
|
143
143
|
}
|
package/Set.js
CHANGED
|
@@ -3,7 +3,7 @@ import { some, value as value_3 } from "./Option.js";
|
|
|
3
3
|
import { structuralHash, toIterator, disposeSafe, getEnumerator, isArrayLike } from "./Util.js";
|
|
4
4
|
import { toString, 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
|
-
import { fold as fold_1, fill } from "./Array.js";
|
|
6
|
+
import { fold as fold_1, fill, setItem } from "./Array.js";
|
|
7
7
|
import { join } from "./String.js";
|
|
8
8
|
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
9
|
import { HashSet__get_Comparer, HashSet_$ctor_Z6150332D, HashSet } from "./MutableSet.js";
|
|
@@ -1337,7 +1337,7 @@ export function SetTreeModule_toList(t) {
|
|
|
1337
1337
|
export function SetTreeModule_copyToArray(s, arr, i) {
|
|
1338
1338
|
let j = i;
|
|
1339
1339
|
SetTreeModule_iter((x) => {
|
|
1340
|
-
arr
|
|
1340
|
+
setItem(arr, j, x);
|
|
1341
1341
|
j = ((j + 1) | 0);
|
|
1342
1342
|
}, s);
|
|
1343
1343
|
}
|
package/String.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export declare function trimStart(str: string, ...chars: string[]): any;
|
|
|
38
38
|
export declare function trimEnd(str: string, ...chars: string[]): any;
|
|
39
39
|
export declare function filter(pred: (char: string) => boolean, x: string): string;
|
|
40
40
|
export declare function substring(str: string, startIndex: number, length?: number): string;
|
|
41
|
+
export declare function toCharArray2(str: string, startIndex: number, length: number): string[];
|
|
41
42
|
interface FormattableString {
|
|
42
43
|
strs: TemplateStringsArray;
|
|
43
44
|
args: any[];
|
package/String.js
CHANGED
|
@@ -527,6 +527,9 @@ export function substring(str, startIndex, length) {
|
|
|
527
527
|
}
|
|
528
528
|
return length != null ? str.substr(startIndex, length) : str.substr(startIndex);
|
|
529
529
|
}
|
|
530
|
+
export function toCharArray2(str, startIndex, length) {
|
|
531
|
+
return substring(str, startIndex, length).split("");
|
|
532
|
+
}
|
|
530
533
|
export function fmt(strs, ...args) {
|
|
531
534
|
return ({ strs, args });
|
|
532
535
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { disposeSafe, defaultOf, toIterator, getEnumerator, structuralHash, equals as equals_1, compare } from "./Util.js";
|
|
2
2
|
import { class_type } from "./Reflection.js";
|
|
3
3
|
import { toArray, empty, singleton, append, enumerateWhile, delay } from "./Seq.js";
|
|
4
|
-
import { initialize, copyTo, fill } from "./Array.js";
|
|
4
|
+
import { setItem, initialize, copyTo, fill, item as item_1 } from "./Array.js";
|
|
5
5
|
import { max } from "./Double.js";
|
|
6
6
|
export class Comparer$1 {
|
|
7
7
|
constructor(comparison) {
|
|
@@ -68,7 +68,7 @@ export class Stack$1 {
|
|
|
68
68
|
const _ = this;
|
|
69
69
|
return getEnumerator(delay(() => {
|
|
70
70
|
let index = _.count - 1;
|
|
71
|
-
return enumerateWhile(() => (index >= 0), delay(() => append(singleton(_.contents
|
|
71
|
+
return enumerateWhile(() => (index >= 0), delay(() => append(singleton(item_1(index, _.contents)), delay(() => {
|
|
72
72
|
index = ((index - 1) | 0);
|
|
73
73
|
return empty();
|
|
74
74
|
}))));
|
|
@@ -111,16 +111,16 @@ export function Stack$1__get_Count(_) {
|
|
|
111
111
|
}
|
|
112
112
|
export function Stack$1__Pop(_) {
|
|
113
113
|
_.count = ((_.count - 1) | 0);
|
|
114
|
-
return _.
|
|
114
|
+
return item_1(_.count, _.contents);
|
|
115
115
|
}
|
|
116
116
|
export function Stack$1__Peek(_) {
|
|
117
|
-
return _.
|
|
117
|
+
return item_1(_.count - 1, _.contents);
|
|
118
118
|
}
|
|
119
119
|
export function Stack$1__Contains_2B595(_, x) {
|
|
120
120
|
let found = false;
|
|
121
121
|
let i = 0;
|
|
122
122
|
while ((i < _.count) && !found) {
|
|
123
|
-
if (equals_1(x, _.contents
|
|
123
|
+
if (equals_1(x, item_1(i, _.contents))) {
|
|
124
124
|
found = true;
|
|
125
125
|
}
|
|
126
126
|
else {
|
|
@@ -162,7 +162,7 @@ export function Stack$1__TrimExcess(this$) {
|
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
export function Stack$1__ToArray(_) {
|
|
165
|
-
return initialize(_.count, (i) =>
|
|
165
|
+
return initialize(_.count, (i) => item_1((_.count - 1) - i, _.contents));
|
|
166
166
|
}
|
|
167
167
|
export class Queue$1 {
|
|
168
168
|
constructor(initialContents, initialCount) {
|
|
@@ -217,7 +217,7 @@ export function Queue$1__Dequeue(_) {
|
|
|
217
217
|
if (_.count === 0) {
|
|
218
218
|
throw new Error("Queue is empty");
|
|
219
219
|
}
|
|
220
|
-
const value = _.
|
|
220
|
+
const value = item_1(_.head, _.contents);
|
|
221
221
|
_.head = (((_.head + 1) % Queue$1__size(_)) | 0);
|
|
222
222
|
_.count = ((_.count - 1) | 0);
|
|
223
223
|
return value;
|
|
@@ -226,7 +226,7 @@ export function Queue$1__Peek(_) {
|
|
|
226
226
|
if (_.count === 0) {
|
|
227
227
|
throw new Error("Queue is empty");
|
|
228
228
|
}
|
|
229
|
-
return _.
|
|
229
|
+
return item_1(_.head, _.contents);
|
|
230
230
|
}
|
|
231
231
|
export function Queue$1__TryDequeue_1F3DB691(this$, result) {
|
|
232
232
|
if (this$.count === 0) {
|
|
@@ -250,7 +250,7 @@ export function Queue$1__Contains_2B595(_, x) {
|
|
|
250
250
|
let found = false;
|
|
251
251
|
let i = 0;
|
|
252
252
|
while ((i < _.count) && !found) {
|
|
253
|
-
if (equals_1(x,
|
|
253
|
+
if (equals_1(x, item_1(Queue$1__toIndex_Z524259A4(_, i), _.contents))) {
|
|
254
254
|
found = true;
|
|
255
255
|
}
|
|
256
256
|
else {
|
|
@@ -279,7 +279,7 @@ export function Queue$1__CopyTo_Z3B4C077E(_, target, start) {
|
|
|
279
279
|
try {
|
|
280
280
|
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
281
281
|
const item = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
282
|
-
target
|
|
282
|
+
setItem(target, i, item);
|
|
283
283
|
i = ((i + 1) | 0);
|
|
284
284
|
}
|
|
285
285
|
}
|
|
@@ -309,7 +309,7 @@ export function Queue$1__ensure_Z524259A4(this$, requiredSize) {
|
|
|
309
309
|
export function Queue$1__toSeq(this$) {
|
|
310
310
|
return delay(() => {
|
|
311
311
|
let i = 0;
|
|
312
|
-
return enumerateWhile(() => (i < this$.count), delay(() => append(singleton(
|
|
312
|
+
return enumerateWhile(() => (i < this$.count), delay(() => append(singleton(item_1(Queue$1__toIndex_Z524259A4(this$, i), this$.contents)), delay(() => {
|
|
313
313
|
i = ((i + 1) | 0);
|
|
314
314
|
return empty();
|
|
315
315
|
}))));
|
package/System.Text.d.ts
CHANGED
|
@@ -20,11 +20,19 @@ export declare function StringBuilder__Append_4E60E31B(x: StringBuilder, o: any)
|
|
|
20
20
|
export declare function StringBuilder__Append_Z372E4D23(x: StringBuilder, cs: string[]): StringBuilder;
|
|
21
21
|
export declare function StringBuilder__Append_43A65C09(x: StringBuilder, s: StringBuilder): StringBuilder;
|
|
22
22
|
export declare function StringBuilder__AppendFormat_433E080(x: StringBuilder, fmt: string, o: any): StringBuilder;
|
|
23
|
+
export declare function StringBuilder__AppendFormat_Z3B30EC65(x: StringBuilder, fmt: string, o1: any, o2: any): StringBuilder;
|
|
24
|
+
export declare function StringBuilder__AppendFormat_10D165E0(x: StringBuilder, fmt: string, o1: any, o2: any, o3: any): StringBuilder;
|
|
25
|
+
export declare function StringBuilder__AppendFormat_Z17053F5(x: StringBuilder, fmt: string, arr: any[]): StringBuilder;
|
|
23
26
|
export declare function StringBuilder__AppendFormat_Z696D8D1B(x: StringBuilder, provider: any, fmt: string, o: any): StringBuilder;
|
|
27
|
+
export declare function StringBuilder__AppendFormat_26802C9E(x: StringBuilder, provider: any, fmt: string, o1: any, o2: any): StringBuilder;
|
|
28
|
+
export declare function StringBuilder__AppendFormat_Z471ADCBB(x: StringBuilder, provider: any, fmt: string, o1: any, o2: any, o3: any): StringBuilder;
|
|
29
|
+
export declare function StringBuilder__AppendFormat_6C2E3E6E(x: StringBuilder, provider: any, fmt: string, arr: any[]): StringBuilder;
|
|
24
30
|
export declare function StringBuilder__AppendLine(x: StringBuilder): StringBuilder;
|
|
25
31
|
export declare function StringBuilder__AppendLine_Z721C83C5(x: StringBuilder, s: string): StringBuilder;
|
|
32
|
+
export declare function StringBuilder__Clear(x: StringBuilder): StringBuilder;
|
|
33
|
+
export declare function StringBuilder__get_Chars_Z524259A4(x: StringBuilder, index: int32): string;
|
|
34
|
+
export declare function StringBuilder__set_Chars_413E0D0A(x: StringBuilder, index: int32, value: string): void;
|
|
26
35
|
export declare function StringBuilder__Replace_Z766F94C0(x: StringBuilder, oldValue: string, newValue: string): StringBuilder;
|
|
27
36
|
export declare function StringBuilder__Replace_Z384F8060(x: StringBuilder, oldValue: string, newValue: string): StringBuilder;
|
|
28
37
|
export declare function StringBuilder__get_Length(x: StringBuilder): int32;
|
|
29
38
|
export declare function StringBuilder__ToString_Z37302880(x: StringBuilder, firstIndex: int32, length: int32): string;
|
|
30
|
-
export declare function StringBuilder__Clear(x: StringBuilder): StringBuilder;
|
package/System.Text.js
CHANGED
|
@@ -69,10 +69,34 @@ export function StringBuilder__AppendFormat_433E080(x, fmt, o) {
|
|
|
69
69
|
void (x.buf.push(format(fmt, o)));
|
|
70
70
|
return x;
|
|
71
71
|
}
|
|
72
|
+
export function StringBuilder__AppendFormat_Z3B30EC65(x, fmt, o1, o2) {
|
|
73
|
+
void (x.buf.push(format(fmt, o1, o2)));
|
|
74
|
+
return x;
|
|
75
|
+
}
|
|
76
|
+
export function StringBuilder__AppendFormat_10D165E0(x, fmt, o1, o2, o3) {
|
|
77
|
+
void (x.buf.push(format(fmt, o1, o2, o3)));
|
|
78
|
+
return x;
|
|
79
|
+
}
|
|
80
|
+
export function StringBuilder__AppendFormat_Z17053F5(x, fmt, arr) {
|
|
81
|
+
void (x.buf.push(format(fmt, ...arr)));
|
|
82
|
+
return x;
|
|
83
|
+
}
|
|
72
84
|
export function StringBuilder__AppendFormat_Z696D8D1B(x, provider, fmt, o) {
|
|
73
85
|
void (x.buf.push(format(provider, fmt, o)));
|
|
74
86
|
return x;
|
|
75
87
|
}
|
|
88
|
+
export function StringBuilder__AppendFormat_26802C9E(x, provider, fmt, o1, o2) {
|
|
89
|
+
void (x.buf.push(format(provider, fmt, o1, o2)));
|
|
90
|
+
return x;
|
|
91
|
+
}
|
|
92
|
+
export function StringBuilder__AppendFormat_Z471ADCBB(x, provider, fmt, o1, o2, o3) {
|
|
93
|
+
void (x.buf.push(format(provider, fmt, o1, o2, o3)));
|
|
94
|
+
return x;
|
|
95
|
+
}
|
|
96
|
+
export function StringBuilder__AppendFormat_6C2E3E6E(x, provider, fmt, arr) {
|
|
97
|
+
void (x.buf.push(format(provider, fmt, ...arr)));
|
|
98
|
+
return x;
|
|
99
|
+
}
|
|
76
100
|
export function StringBuilder__AppendLine(x) {
|
|
77
101
|
void (x.buf.push("\n"));
|
|
78
102
|
return x;
|
|
@@ -82,6 +106,40 @@ export function StringBuilder__AppendLine_Z721C83C5(x, s) {
|
|
|
82
106
|
void (x.buf.push("\n"));
|
|
83
107
|
return x;
|
|
84
108
|
}
|
|
109
|
+
export function StringBuilder__Clear(x) {
|
|
110
|
+
clear(x.buf);
|
|
111
|
+
return x;
|
|
112
|
+
}
|
|
113
|
+
export function StringBuilder__get_Chars_Z524259A4(x, index) {
|
|
114
|
+
let len = 0;
|
|
115
|
+
let i = -1;
|
|
116
|
+
while (((i + 1) < x.buf.length) && (len < index)) {
|
|
117
|
+
i = ((i + 1) | 0);
|
|
118
|
+
len = ((len + x.buf[i].length) | 0);
|
|
119
|
+
}
|
|
120
|
+
if (((index < 0) ? true : (i < 0)) ? true : (i >= x.buf.length)) {
|
|
121
|
+
throw new Error("Index was outside the bounds of the array");
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
const pos = ((len - index) - 1) | 0;
|
|
125
|
+
return x.buf[i][pos];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
export function StringBuilder__set_Chars_413E0D0A(x, index, value) {
|
|
129
|
+
let len = 0;
|
|
130
|
+
let i = -1;
|
|
131
|
+
while (((i + 1) < x.buf.length) && (len < index)) {
|
|
132
|
+
i = ((i + 1) | 0);
|
|
133
|
+
len = ((len + x.buf[i].length) | 0);
|
|
134
|
+
}
|
|
135
|
+
if (((index < 0) ? true : (i < 0)) ? true : (i >= x.buf.length)) {
|
|
136
|
+
throw new Error("Index was outside the bounds of the array");
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
const pos = ((len - index) - 1) | 0;
|
|
140
|
+
x.buf[i] = ((x.buf[i].slice(0, (pos - 1) + 1) + value) + x.buf[i].slice(pos + 1, x.buf[i].length));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
85
143
|
export function StringBuilder__Replace_Z766F94C0(x, oldValue, newValue) {
|
|
86
144
|
for (let i = x.buf.length - 1; i >= 0; i--) {
|
|
87
145
|
x.buf[i] = replace(x.buf[i], oldValue, newValue);
|
|
@@ -89,10 +147,8 @@ export function StringBuilder__Replace_Z766F94C0(x, oldValue, newValue) {
|
|
|
89
147
|
return x;
|
|
90
148
|
}
|
|
91
149
|
export function StringBuilder__Replace_Z384F8060(x, oldValue, newValue) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
return x;
|
|
150
|
+
const str = replace(toString(x), oldValue, newValue);
|
|
151
|
+
return StringBuilder__Append_Z721C83C5(StringBuilder__Clear(x), str);
|
|
96
152
|
}
|
|
97
153
|
export function StringBuilder__get_Length(x) {
|
|
98
154
|
let len = 0;
|
|
@@ -104,7 +160,3 @@ export function StringBuilder__get_Length(x) {
|
|
|
104
160
|
export function StringBuilder__ToString_Z37302880(x, firstIndex, length) {
|
|
105
161
|
return substring(toString(x), firstIndex, length);
|
|
106
162
|
}
|
|
107
|
-
export function StringBuilder__Clear(x) {
|
|
108
|
-
clear(x.buf);
|
|
109
|
-
return x;
|
|
110
|
-
}
|
package/package.json
CHANGED