@fable-org/fable-library-ts 1.0.0-beta-001 → 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.ts +101 -86
- package/CHANGELOG.md +14 -0
- package/List.ts +3 -3
- package/Map.ts +3 -3
- package/MutableMap.ts +2 -1
- package/MutableSet.ts +2 -1
- package/Random.ts +7 -7
- package/Set.ts +2 -2
- package/String.ts +4 -0
- package/System.Collections.Generic.ts +11 -11
- package/System.Text.ts +69 -9
- package/package.json +1 -1
package/Array.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { int32 } from "./Int32.js";
|
|
2
2
|
import { Helpers_allocateArrayFromCons } from "./Native.js";
|
|
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, Option, some } from "./Option.js";
|
|
4
5
|
import { min as min_1, max as max_1 } from "./Double.js";
|
|
5
6
|
import { IComparer, equals as equals_1, IDisposable, disposeSafe, IEnumerator, getEnumerator, copyToArray, IEqualityComparer, defaultOf } from "./Util.js";
|
|
@@ -19,10 +20,10 @@ export function append<T>(array1: T[], array2: T[], cons?: any): T[] {
|
|
|
19
20
|
const len2: int32 = array2.length | 0;
|
|
20
21
|
const newArray: T[] = Helpers_allocateArrayFromCons<T>(cons, len1 + len2);
|
|
21
22
|
for (let i = 0; i <= (len1 - 1); i++) {
|
|
22
|
-
newArray
|
|
23
|
+
setItem_1(newArray, i, item_2(i, array1));
|
|
23
24
|
}
|
|
24
25
|
for (let i_1 = 0; i_1 <= (len2 - 1); i_1++) {
|
|
25
|
-
newArray
|
|
26
|
+
setItem_1(newArray, i_1 + len1, item_2(i_1, array2));
|
|
26
27
|
}
|
|
27
28
|
return newArray;
|
|
28
29
|
}
|
|
@@ -45,7 +46,7 @@ export function last<T>(array: T[]): T {
|
|
|
45
46
|
if (array.length === 0) {
|
|
46
47
|
throw new Error("The input array was empty\\nParameter name: array");
|
|
47
48
|
}
|
|
48
|
-
return array
|
|
49
|
+
return item_2(array.length - 1, array);
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
export function tryLast<T>(array: T[]): Option<T> {
|
|
@@ -53,7 +54,7 @@ export function tryLast<T>(array: T[]): Option<T> {
|
|
|
53
54
|
return void 0;
|
|
54
55
|
}
|
|
55
56
|
else {
|
|
56
|
-
return some(array
|
|
57
|
+
return some(item_2(array.length - 1, array));
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
|
|
@@ -61,7 +62,7 @@ export function mapIndexed<T, U>(f: ((arg0: int32, arg1: T) => U), source: T[],
|
|
|
61
62
|
const len: int32 = source.length | 0;
|
|
62
63
|
const target: U[] = Helpers_allocateArrayFromCons<U>(cons, len);
|
|
63
64
|
for (let i = 0; i <= (len - 1); i++) {
|
|
64
|
-
target
|
|
65
|
+
setItem_1(target, i, f(i, item_2(i, source)));
|
|
65
66
|
}
|
|
66
67
|
return target;
|
|
67
68
|
}
|
|
@@ -70,7 +71,7 @@ export function map<T, U>(f: ((arg0: T) => U), source: T[], cons?: any): U[] {
|
|
|
70
71
|
const len: int32 = source.length | 0;
|
|
71
72
|
const target: U[] = Helpers_allocateArrayFromCons<U>(cons, len);
|
|
72
73
|
for (let i = 0; i <= (len - 1); i++) {
|
|
73
|
-
target
|
|
74
|
+
setItem_1(target, i, f(item_2(i, source)));
|
|
74
75
|
}
|
|
75
76
|
return target;
|
|
76
77
|
}
|
|
@@ -81,7 +82,7 @@ export function mapIndexed2<T1, T2, U>(f: ((arg0: int32, arg1: T1, arg2: T2) =>
|
|
|
81
82
|
}
|
|
82
83
|
const result: U[] = Helpers_allocateArrayFromCons<U>(cons, source1.length);
|
|
83
84
|
for (let i = 0; i <= (source1.length - 1); i++) {
|
|
84
|
-
result
|
|
85
|
+
setItem_1(result, i, f(i, item_2(i, source1), item_2(i, source2)));
|
|
85
86
|
}
|
|
86
87
|
return result;
|
|
87
88
|
}
|
|
@@ -92,7 +93,7 @@ export function map2<T1, T2, U>(f: ((arg0: T1, arg1: T2) => U), source1: T1[], s
|
|
|
92
93
|
}
|
|
93
94
|
const result: U[] = Helpers_allocateArrayFromCons<U>(cons, source1.length);
|
|
94
95
|
for (let i = 0; i <= (source1.length - 1); i++) {
|
|
95
|
-
result
|
|
96
|
+
setItem_1(result, i, f(item_2(i, source1), item_2(i, source2)));
|
|
96
97
|
}
|
|
97
98
|
return result;
|
|
98
99
|
}
|
|
@@ -103,7 +104,7 @@ export function mapIndexed3<T1, T2, T3, U>(f: ((arg0: int32, arg1: T1, arg2: T2,
|
|
|
103
104
|
}
|
|
104
105
|
const result: U[] = Helpers_allocateArrayFromCons<U>(cons, source1.length);
|
|
105
106
|
for (let i = 0; i <= (source1.length - 1); i++) {
|
|
106
|
-
result
|
|
107
|
+
setItem_1(result, i, f(i, item_2(i, source1), item_2(i, source2), item_2(i, source3)));
|
|
107
108
|
}
|
|
108
109
|
return result;
|
|
109
110
|
}
|
|
@@ -114,7 +115,7 @@ export function map3<T1, T2, T3, U>(f: ((arg0: T1, arg1: T2, arg2: T3) => U), so
|
|
|
114
115
|
}
|
|
115
116
|
const result: U[] = Helpers_allocateArrayFromCons<U>(cons, source1.length);
|
|
116
117
|
for (let i = 0; i <= (source1.length - 1); i++) {
|
|
117
|
-
result
|
|
118
|
+
setItem_1(result, i, f(item_2(i, source1), item_2(i, source2), item_2(i, source3)));
|
|
118
119
|
}
|
|
119
120
|
return result;
|
|
120
121
|
}
|
|
@@ -128,8 +129,8 @@ export function mapFold<T, State, Result>(mapping: ((arg0: State, arg1: T) => [R
|
|
|
128
129
|
let acc: State = state;
|
|
129
130
|
const res: Result[] = Helpers_allocateArrayFromCons<Result>(cons, matchValue);
|
|
130
131
|
for (let i = 0; i <= (array.length - 1); i++) {
|
|
131
|
-
const patternInput: [Result, State] = mapping(acc, array
|
|
132
|
-
res
|
|
132
|
+
const patternInput: [Result, State] = mapping(acc, item_2(i, array));
|
|
133
|
+
setItem_1(res, i, patternInput[0]);
|
|
133
134
|
acc = patternInput[1];
|
|
134
135
|
}
|
|
135
136
|
return [res, acc] as [Result[], State];
|
|
@@ -145,8 +146,8 @@ export function mapFoldBack<T, State, Result>(mapping: ((arg0: T, arg1: State) =
|
|
|
145
146
|
let acc: State = state;
|
|
146
147
|
const res: Result[] = Helpers_allocateArrayFromCons<Result>(cons, matchValue);
|
|
147
148
|
for (let i: int32 = array.length - 1; i >= 0; i--) {
|
|
148
|
-
const patternInput: [Result, State] = mapping(
|
|
149
|
-
res
|
|
149
|
+
const patternInput: [Result, State] = mapping(item_2(i, array), acc);
|
|
150
|
+
setItem_1(res, i, patternInput[0]);
|
|
150
151
|
acc = patternInput[1];
|
|
151
152
|
}
|
|
152
153
|
return [res, acc] as [Result[], State];
|
|
@@ -157,7 +158,7 @@ export function indexed<T>(source: T[]): [int32, T][] {
|
|
|
157
158
|
const len: int32 = source.length | 0;
|
|
158
159
|
const target: [int32, T][] = new Array(len);
|
|
159
160
|
for (let i = 0; i <= (len - 1); i++) {
|
|
160
|
-
target[i
|
|
161
|
+
setItem_1(target, i, [i, item_2(i, source)] as [int32, T]);
|
|
161
162
|
}
|
|
162
163
|
return target;
|
|
163
164
|
}
|
|
@@ -174,19 +175,19 @@ export function concat<T>(arrays: Iterable<T[]>, cons?: any): T[] {
|
|
|
174
175
|
case 0:
|
|
175
176
|
return Helpers_allocateArrayFromCons<T>(cons, 0);
|
|
176
177
|
case 1:
|
|
177
|
-
return arrays_1
|
|
178
|
+
return item_2(0, arrays_1);
|
|
178
179
|
default: {
|
|
179
180
|
let totalIdx = 0;
|
|
180
181
|
let totalLength = 0;
|
|
181
182
|
for (let idx = 0; idx <= (arrays_1.length - 1); idx++) {
|
|
182
|
-
const arr_1: T[] = arrays_1
|
|
183
|
+
const arr_1: T[] = item_2(idx, arrays_1);
|
|
183
184
|
totalLength = ((totalLength + arr_1.length) | 0);
|
|
184
185
|
}
|
|
185
186
|
const result: T[] = Helpers_allocateArrayFromCons<T>(cons, totalLength);
|
|
186
187
|
for (let idx_1 = 0; idx_1 <= (arrays_1.length - 1); idx_1++) {
|
|
187
|
-
const arr_2: T[] = arrays_1
|
|
188
|
+
const arr_2: T[] = item_2(idx_1, arrays_1);
|
|
188
189
|
for (let j = 0; j <= (arr_2.length - 1); j++) {
|
|
189
|
-
result
|
|
190
|
+
setItem_1(result, totalIdx, item_2(j, arr_2));
|
|
190
191
|
totalIdx = ((totalIdx + 1) | 0);
|
|
191
192
|
}
|
|
192
193
|
}
|
|
@@ -213,7 +214,7 @@ export function indexOf<T>(array: T[], item_1: T, start: Option<int32>, count: O
|
|
|
213
214
|
if (i >= end$0027) {
|
|
214
215
|
return -1;
|
|
215
216
|
}
|
|
216
|
-
else if (eq.Equals(item_1, array
|
|
217
|
+
else if (eq.Equals(item_1, item_2(i, array))) {
|
|
217
218
|
return i | 0;
|
|
218
219
|
}
|
|
219
220
|
else {
|
|
@@ -236,7 +237,7 @@ export function empty<$a>(cons: any): $a[] {
|
|
|
236
237
|
|
|
237
238
|
export function singleton<T>(value: T, cons?: any): T[] {
|
|
238
239
|
const ar: T[] = Helpers_allocateArrayFromCons<T>(cons, 1);
|
|
239
|
-
ar
|
|
240
|
+
setItem_1(ar, 0, value);
|
|
240
241
|
return ar;
|
|
241
242
|
}
|
|
242
243
|
|
|
@@ -246,7 +247,7 @@ export function initialize<T>(count: int32, initializer: ((arg0: int32) => T), c
|
|
|
246
247
|
}
|
|
247
248
|
const result: T[] = Helpers_allocateArrayFromCons<T>(cons, count);
|
|
248
249
|
for (let i = 0; i <= (count - 1); i++) {
|
|
249
|
-
result
|
|
250
|
+
setItem_1(result, i, initializer(i));
|
|
250
251
|
}
|
|
251
252
|
return result;
|
|
252
253
|
}
|
|
@@ -259,7 +260,7 @@ export function pairwise<T>(array: T[]): [T, T][] {
|
|
|
259
260
|
const count: int32 = (array.length - 1) | 0;
|
|
260
261
|
const result: [T, T][] = new Array(count);
|
|
261
262
|
for (let i = 0; i <= (count - 1); i++) {
|
|
262
|
-
result
|
|
263
|
+
setItem_1(result, i, [item_2(i, array), item_2(i + 1, array)] as [T, T]);
|
|
263
264
|
}
|
|
264
265
|
return result;
|
|
265
266
|
}
|
|
@@ -271,7 +272,7 @@ export function replicate<T>(count: int32, initial: T, cons?: any): T[] {
|
|
|
271
272
|
}
|
|
272
273
|
const result: T[] = Helpers_allocateArrayFromCons<T>(cons, count);
|
|
273
274
|
for (let i = 0; i <= (result.length - 1); i++) {
|
|
274
|
-
result
|
|
275
|
+
setItem_1(result, i, initial);
|
|
275
276
|
}
|
|
276
277
|
return result;
|
|
277
278
|
}
|
|
@@ -291,18 +292,18 @@ export function reverse<T>(array: T[]): T[] {
|
|
|
291
292
|
|
|
292
293
|
export function scan<T, State>(folder: ((arg0: State, arg1: T) => State), state: State, array: T[], cons?: any): State[] {
|
|
293
294
|
const res: State[] = Helpers_allocateArrayFromCons<State>(cons, array.length + 1);
|
|
294
|
-
res
|
|
295
|
+
setItem_1(res, 0, state);
|
|
295
296
|
for (let i = 0; i <= (array.length - 1); i++) {
|
|
296
|
-
res
|
|
297
|
+
setItem_1(res, i + 1, folder(item_2(i, res), item_2(i, array)));
|
|
297
298
|
}
|
|
298
299
|
return res;
|
|
299
300
|
}
|
|
300
301
|
|
|
301
302
|
export function scanBack<T, State>(folder: ((arg0: T, arg1: State) => State), array: T[], state: State, cons?: any): State[] {
|
|
302
303
|
const res: State[] = Helpers_allocateArrayFromCons<State>(cons, array.length + 1);
|
|
303
|
-
res
|
|
304
|
+
setItem_1(res, array.length, state);
|
|
304
305
|
for (let i: int32 = array.length - 1; i >= 0; i--) {
|
|
305
|
-
res
|
|
306
|
+
setItem_1(res, i, folder(item_2(i, array), item_2(i + 1, res)));
|
|
306
307
|
}
|
|
307
308
|
return res;
|
|
308
309
|
}
|
|
@@ -322,7 +323,7 @@ export function skip<T>(count: int32, array: T[], cons?: any): T[] {
|
|
|
322
323
|
|
|
323
324
|
export function skipWhile<T>(predicate: ((arg0: T) => boolean), array: T[], cons?: any): T[] {
|
|
324
325
|
let count = 0;
|
|
325
|
-
while ((count < array.length) && predicate(array
|
|
326
|
+
while ((count < array.length) && predicate(item_2(count, array))) {
|
|
326
327
|
count = ((count + 1) | 0);
|
|
327
328
|
}
|
|
328
329
|
if (count === array.length) {
|
|
@@ -351,7 +352,7 @@ export function take<T>(count: int32, array: T[], cons?: any): T[] {
|
|
|
351
352
|
|
|
352
353
|
export function takeWhile<T>(predicate: ((arg0: T) => boolean), array: T[], cons?: any): T[] {
|
|
353
354
|
let count = 0;
|
|
354
|
-
while ((count < array.length) && predicate(array
|
|
355
|
+
while ((count < array.length) && predicate(item_2(count, array))) {
|
|
355
356
|
count = ((count + 1) | 0);
|
|
356
357
|
}
|
|
357
358
|
if (count === 0) {
|
|
@@ -427,12 +428,12 @@ export function partition<T>(f: ((arg0: T) => boolean), source: T[], cons?: any)
|
|
|
427
428
|
let iTrue = 0;
|
|
428
429
|
let iFalse = 0;
|
|
429
430
|
for (let i = 0; i <= (len - 1); i++) {
|
|
430
|
-
if (f(source
|
|
431
|
-
res1
|
|
431
|
+
if (f(item_2(i, source))) {
|
|
432
|
+
setItem_1(res1, iTrue, item_2(i, source));
|
|
432
433
|
iTrue = ((iTrue + 1) | 0);
|
|
433
434
|
}
|
|
434
435
|
else {
|
|
435
|
-
res2
|
|
436
|
+
setItem_1(res2, iFalse, item_2(i, source));
|
|
436
437
|
iFalse = ((iFalse + 1) | 0);
|
|
437
438
|
}
|
|
438
439
|
}
|
|
@@ -483,7 +484,7 @@ export function pick<$a, $b>(chooser: ((arg0: $a) => Option<$b>), array: $a[]):
|
|
|
483
484
|
return indexNotFound<$b>();
|
|
484
485
|
}
|
|
485
486
|
else {
|
|
486
|
-
const matchValue: Option<$b> = chooser(array
|
|
487
|
+
const matchValue: Option<$b> = chooser(item_2(i, array));
|
|
487
488
|
if (matchValue != null) {
|
|
488
489
|
return value_2(matchValue);
|
|
489
490
|
}
|
|
@@ -507,7 +508,7 @@ export function tryPick<$a, $b>(chooser: ((arg0: $a) => Option<$b>), array: $a[]
|
|
|
507
508
|
return void 0;
|
|
508
509
|
}
|
|
509
510
|
else {
|
|
510
|
-
const matchValue: Option<$b> = chooser(array
|
|
511
|
+
const matchValue: Option<$b> = chooser(item_2(i, array));
|
|
511
512
|
if (matchValue == null) {
|
|
512
513
|
i_mut = (i + 1);
|
|
513
514
|
continue loop;
|
|
@@ -530,8 +531,8 @@ export function findBack<$a>(predicate: ((arg0: $a) => boolean), array: $a[]): $
|
|
|
530
531
|
if (i < 0) {
|
|
531
532
|
return indexNotFound<$a>();
|
|
532
533
|
}
|
|
533
|
-
else if (predicate(array
|
|
534
|
-
return array
|
|
534
|
+
else if (predicate(item_2(i, array))) {
|
|
535
|
+
return item_2(i, array);
|
|
535
536
|
}
|
|
536
537
|
else {
|
|
537
538
|
i_mut = (i - 1);
|
|
@@ -551,8 +552,8 @@ export function tryFindBack<$a>(predicate: ((arg0: $a) => boolean), array: $a[])
|
|
|
551
552
|
if (i < 0) {
|
|
552
553
|
return void 0;
|
|
553
554
|
}
|
|
554
|
-
else if (predicate(array
|
|
555
|
-
return some(array
|
|
555
|
+
else if (predicate(item_2(i, array))) {
|
|
556
|
+
return some(item_2(i, array));
|
|
556
557
|
}
|
|
557
558
|
else {
|
|
558
559
|
i_mut = (i - 1);
|
|
@@ -572,7 +573,7 @@ export function findLastIndex<$a>(predicate: ((arg0: $a) => boolean), array: $a[
|
|
|
572
573
|
if (i < 0) {
|
|
573
574
|
return -1;
|
|
574
575
|
}
|
|
575
|
-
else if (predicate(array
|
|
576
|
+
else if (predicate(item_2(i, array))) {
|
|
576
577
|
return i | 0;
|
|
577
578
|
}
|
|
578
579
|
else {
|
|
@@ -594,7 +595,7 @@ export function findIndexBack<$a>(predicate: ((arg0: $a) => boolean), array: $a[
|
|
|
594
595
|
indexNotFound<void>();
|
|
595
596
|
return -1;
|
|
596
597
|
}
|
|
597
|
-
else if (predicate(array
|
|
598
|
+
else if (predicate(item_2(i, array))) {
|
|
598
599
|
return i | 0;
|
|
599
600
|
}
|
|
600
601
|
else {
|
|
@@ -615,7 +616,7 @@ export function tryFindIndexBack<$a>(predicate: ((arg0: $a) => boolean), array:
|
|
|
615
616
|
if (i < 0) {
|
|
616
617
|
return void 0;
|
|
617
618
|
}
|
|
618
|
-
else if (predicate(array
|
|
619
|
+
else if (predicate(item_2(i, array))) {
|
|
619
620
|
return i;
|
|
620
621
|
}
|
|
621
622
|
else {
|
|
@@ -631,7 +632,7 @@ export function tryFindIndexBack<$a>(predicate: ((arg0: $a) => boolean), array:
|
|
|
631
632
|
export function choose<T, U>(chooser: ((arg0: T) => Option<U>), array: T[], cons?: any): U[] {
|
|
632
633
|
const res: U[] = [];
|
|
633
634
|
for (let i = 0; i <= (array.length - 1); i++) {
|
|
634
|
-
const matchValue: Option<U> = chooser(array
|
|
635
|
+
const matchValue: Option<U> = chooser(item_2(i, array));
|
|
635
636
|
if (matchValue != null) {
|
|
636
637
|
const y: U = value_2(matchValue);
|
|
637
638
|
res.push(y);
|
|
@@ -656,13 +657,13 @@ export function fold<T, State>(folder: ((arg0: State, arg1: T) => State), state:
|
|
|
656
657
|
|
|
657
658
|
export function iterate<T>(action: ((arg0: T) => void), array: T[]): void {
|
|
658
659
|
for (let i = 0; i <= (array.length - 1); i++) {
|
|
659
|
-
action(array
|
|
660
|
+
action(item_2(i, array));
|
|
660
661
|
}
|
|
661
662
|
}
|
|
662
663
|
|
|
663
664
|
export function iterateIndexed<T>(action: ((arg0: int32, arg1: T) => void), array: T[]): void {
|
|
664
665
|
for (let i = 0; i <= (array.length - 1); i++) {
|
|
665
|
-
action(i, array
|
|
666
|
+
action(i, item_2(i, array));
|
|
666
667
|
}
|
|
667
668
|
}
|
|
668
669
|
|
|
@@ -671,7 +672,7 @@ export function iterate2<T1, T2>(action: ((arg0: T1, arg1: T2) => void), array1:
|
|
|
671
672
|
differentLengths<void>();
|
|
672
673
|
}
|
|
673
674
|
for (let i = 0; i <= (array1.length - 1); i++) {
|
|
674
|
-
action(array1
|
|
675
|
+
action(item_2(i, array1), item_2(i, array2));
|
|
675
676
|
}
|
|
676
677
|
}
|
|
677
678
|
|
|
@@ -680,7 +681,7 @@ export function iterateIndexed2<T1, T2>(action: ((arg0: int32, arg1: T1, arg2: T
|
|
|
680
681
|
differentLengths<void>();
|
|
681
682
|
}
|
|
682
683
|
for (let i = 0; i <= (array1.length - 1); i++) {
|
|
683
|
-
action(i, array1
|
|
684
|
+
action(i, item_2(i, array1), item_2(i, array2));
|
|
684
685
|
}
|
|
685
686
|
}
|
|
686
687
|
|
|
@@ -701,8 +702,8 @@ export function permute<T>(f: ((arg0: int32) => int32), array: T[]): T[] {
|
|
|
701
702
|
if ((j < 0) ? true : (j >= size)) {
|
|
702
703
|
throw new Error("Not a valid permutation");
|
|
703
704
|
}
|
|
704
|
-
res
|
|
705
|
-
checkFlags
|
|
705
|
+
setItem_1(res, j, x);
|
|
706
|
+
setItem_1(checkFlags, j, 1);
|
|
706
707
|
}, array);
|
|
707
708
|
if (!(checkFlags.every((y: int32): boolean => (1 === y)))) {
|
|
708
709
|
throw new Error("Not a valid permutation");
|
|
@@ -715,7 +716,7 @@ export function setSlice<T>(target: T[], lower: Option<int32>, upper: Option<int
|
|
|
715
716
|
const upper_1: int32 = defaultArg<int32>(upper, -1) | 0;
|
|
716
717
|
const length: int32 = (((upper_1 >= 0) ? upper_1 : (target.length - 1)) - lower_1) | 0;
|
|
717
718
|
for (let i = 0; i <= length; i++) {
|
|
718
|
-
target
|
|
719
|
+
setItem_1(target, i + lower_1, item_2(i, source));
|
|
719
720
|
}
|
|
720
721
|
}
|
|
721
722
|
|
|
@@ -764,7 +765,7 @@ export function allPairs<T1, T2>(xs: T1[], ys: T2[]): [T1, T2][] {
|
|
|
764
765
|
const res: [T1, T2][] = new Array(len1 * len2);
|
|
765
766
|
for (let i = 0; i <= (xs.length - 1); i++) {
|
|
766
767
|
for (let j = 0; j <= (ys.length - 1); j++) {
|
|
767
|
-
res
|
|
768
|
+
setItem_1(res, (i * len2) + j, [item_2(i, xs), item_2(j, ys)] as [T1, T2]);
|
|
768
769
|
}
|
|
769
770
|
}
|
|
770
771
|
return res;
|
|
@@ -796,8 +797,8 @@ export function unzip<$a, $b>(array: [$a, $b][]): [$a[], $b[]] {
|
|
|
796
797
|
const res1: $a[] = new Array(len);
|
|
797
798
|
const res2: $b[] = new Array(len);
|
|
798
799
|
iterateIndexed<[$a, $b]>((i: int32, tupledArg: [$a, $b]): void => {
|
|
799
|
-
res1
|
|
800
|
-
res2
|
|
800
|
+
setItem_1(res1, i, tupledArg[0]);
|
|
801
|
+
setItem_1(res2, i, tupledArg[1]);
|
|
801
802
|
}, array);
|
|
802
803
|
return [res1, res2] as [$a[], $b[]];
|
|
803
804
|
}
|
|
@@ -808,9 +809,9 @@ export function unzip3<$a, $b, $c>(array: [$a, $b, $c][]): [$a[], $b[], $c[]] {
|
|
|
808
809
|
const res2: $b[] = new Array(len);
|
|
809
810
|
const res3: $c[] = new Array(len);
|
|
810
811
|
iterateIndexed<[$a, $b, $c]>((i: int32, tupledArg: [$a, $b, $c]): void => {
|
|
811
|
-
res1
|
|
812
|
-
res2
|
|
813
|
-
res3
|
|
812
|
+
setItem_1(res1, i, tupledArg[0]);
|
|
813
|
+
setItem_1(res2, i, tupledArg[1]);
|
|
814
|
+
setItem_1(res3, i, tupledArg[2]);
|
|
814
815
|
}, array);
|
|
815
816
|
return [res1, res2, res3] as [$a[], $b[], $c[]];
|
|
816
817
|
}
|
|
@@ -821,7 +822,7 @@ export function zip<T, U>(array1: T[], array2: U[]): [T, U][] {
|
|
|
821
822
|
}
|
|
822
823
|
const result: [T, U][] = new Array(array1.length);
|
|
823
824
|
for (let i = 0; i <= (array1.length - 1); i++) {
|
|
824
|
-
result[i
|
|
825
|
+
setItem_1(result, i, [item_2(i, array1), item_2(i, array2)] as [T, U]);
|
|
825
826
|
}
|
|
826
827
|
return result;
|
|
827
828
|
}
|
|
@@ -832,7 +833,7 @@ export function zip3<T, U, V>(array1: T[], array2: U[], array3: V[]): [T, U, V][
|
|
|
832
833
|
}
|
|
833
834
|
const result: [T, U, V][] = new Array(array1.length);
|
|
834
835
|
for (let i = 0; i <= (array1.length - 1); i++) {
|
|
835
|
-
result[i
|
|
836
|
+
setItem_1(result, i, [item_2(i, array1), item_2(i, array2), item_2(i, array3)] as [T, U, V]);
|
|
836
837
|
}
|
|
837
838
|
return result;
|
|
838
839
|
}
|
|
@@ -882,7 +883,7 @@ export function compareWith<T>(comparer: ((arg0: T, arg1: T) => int32), source1:
|
|
|
882
883
|
let i = 0;
|
|
883
884
|
let res = 0;
|
|
884
885
|
while ((res === 0) && (i < len)) {
|
|
885
|
-
res = (comparer(source1
|
|
886
|
+
res = (comparer(item_2(i, source1), item_2(i, source2)) | 0);
|
|
886
887
|
i = ((i + 1) | 0);
|
|
887
888
|
}
|
|
888
889
|
if (res !== 0) {
|
|
@@ -925,7 +926,7 @@ export function compareTo<T>(comparer: ((arg0: T, arg1: T) => int32), source1: T
|
|
|
925
926
|
let i = 0;
|
|
926
927
|
let res = 0;
|
|
927
928
|
while ((res === 0) && (i < len1)) {
|
|
928
|
-
res = (comparer(source1
|
|
929
|
+
res = (comparer(item_2(i, source1), item_2(i, source2)) | 0);
|
|
929
930
|
i = ((i + 1) | 0);
|
|
930
931
|
}
|
|
931
932
|
return res | 0;
|
|
@@ -958,7 +959,7 @@ export function equalsWith<T>(equals: ((arg0: T, arg1: T) => boolean), array1: T
|
|
|
958
959
|
}
|
|
959
960
|
else {
|
|
960
961
|
while ((i < length1) && result) {
|
|
961
|
-
result = equals(array1
|
|
962
|
+
result = equals(item_2(i, array1), item_2(i, array2));
|
|
962
963
|
i = ((i + 1) | 0);
|
|
963
964
|
}
|
|
964
965
|
return result;
|
|
@@ -969,7 +970,7 @@ export function equalsWith<T>(equals: ((arg0: T, arg1: T) => boolean), array1: T
|
|
|
969
970
|
export function exactlyOne<T>(array: T[]): T {
|
|
970
971
|
switch (array.length) {
|
|
971
972
|
case 1:
|
|
972
|
-
return array
|
|
973
|
+
return item_2(0, array);
|
|
973
974
|
case 0:
|
|
974
975
|
throw new Error("The input sequence was empty\\nParameter name: array");
|
|
975
976
|
default:
|
|
@@ -979,7 +980,7 @@ export function exactlyOne<T>(array: T[]): T {
|
|
|
979
980
|
|
|
980
981
|
export function tryExactlyOne<T>(array: T[]): Option<T> {
|
|
981
982
|
if (array.length === 1) {
|
|
982
|
-
return some(array
|
|
983
|
+
return some(item_2(0, array));
|
|
983
984
|
}
|
|
984
985
|
else {
|
|
985
986
|
return void 0;
|
|
@@ -991,7 +992,7 @@ export function head<T>(array: T[]): T {
|
|
|
991
992
|
throw new Error("The input array was empty\\nParameter name: array");
|
|
992
993
|
}
|
|
993
994
|
else {
|
|
994
|
-
return array
|
|
995
|
+
return item_2(0, array);
|
|
995
996
|
}
|
|
996
997
|
}
|
|
997
998
|
|
|
@@ -1000,7 +1001,7 @@ export function tryHead<T>(array: T[]): Option<T> {
|
|
|
1000
1001
|
return void 0;
|
|
1001
1002
|
}
|
|
1002
1003
|
else {
|
|
1003
|
-
return some(array
|
|
1004
|
+
return some(item_2(0, array));
|
|
1004
1005
|
}
|
|
1005
1006
|
}
|
|
1006
1007
|
|
|
@@ -1011,8 +1012,22 @@ export function tail<T>(array: T[]): T[] {
|
|
|
1011
1012
|
return array.slice(1);
|
|
1012
1013
|
}
|
|
1013
1014
|
|
|
1014
|
-
export function item
|
|
1015
|
-
|
|
1015
|
+
export function item<T>(index: int32, array: T[]): T {
|
|
1016
|
+
if ((index < 0) ? true : (index >= array.length)) {
|
|
1017
|
+
throw new Error("Index was outside the bounds of the array.\\nParameter name: index");
|
|
1018
|
+
}
|
|
1019
|
+
else {
|
|
1020
|
+
return array[index];
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
export function setItem<T>(array: T[], index: int32, value: T): void {
|
|
1025
|
+
if ((index < 0) ? true : (index >= array.length)) {
|
|
1026
|
+
throw new Error("Index was outside the bounds of the array.\\nParameter name: index");
|
|
1027
|
+
}
|
|
1028
|
+
else {
|
|
1029
|
+
array[index] = value;
|
|
1030
|
+
}
|
|
1016
1031
|
}
|
|
1017
1032
|
|
|
1018
1033
|
export function tryItem<T>(index: int32, array: T[]): Option<T> {
|
|
@@ -1038,7 +1053,7 @@ export function foldIndexed2<$a, $b, $c>(folder: ((arg0: int32, arg1: $a, arg2:
|
|
|
1038
1053
|
throw new Error("Arrays have different lengths");
|
|
1039
1054
|
}
|
|
1040
1055
|
for (let i = 0; i <= (array1.length - 1); i++) {
|
|
1041
|
-
acc = folder(i, acc, array1
|
|
1056
|
+
acc = folder(i, acc, item_2(i, array1), item_2(i, array2));
|
|
1042
1057
|
}
|
|
1043
1058
|
return acc;
|
|
1044
1059
|
}
|
|
@@ -1054,7 +1069,7 @@ export function foldBackIndexed2<T1, T2, State>(folder: ((arg0: int32, arg1: T1,
|
|
|
1054
1069
|
}
|
|
1055
1070
|
const size: int32 = array1.length | 0;
|
|
1056
1071
|
for (let i = 1; i <= size; i++) {
|
|
1057
|
-
acc = folder(i - 1,
|
|
1072
|
+
acc = folder(i - 1, item_2(size - i, array1), item_2(size - i, array2), acc);
|
|
1058
1073
|
}
|
|
1059
1074
|
return acc;
|
|
1060
1075
|
}
|
|
@@ -1090,7 +1105,7 @@ export function existsOffset<T>(predicate_mut: ((arg0: T) => boolean), array_mut
|
|
|
1090
1105
|
if (index === array.length) {
|
|
1091
1106
|
return false;
|
|
1092
1107
|
}
|
|
1093
|
-
else if (predicate(array
|
|
1108
|
+
else if (predicate(item_2(index, array))) {
|
|
1094
1109
|
return true;
|
|
1095
1110
|
}
|
|
1096
1111
|
else {
|
|
@@ -1114,7 +1129,7 @@ export function existsOffset2<$a, $b>(predicate_mut: ((arg0: $a, arg1: $b) => bo
|
|
|
1114
1129
|
if (index === array1.length) {
|
|
1115
1130
|
return false;
|
|
1116
1131
|
}
|
|
1117
|
-
else if (predicate(array1
|
|
1132
|
+
else if (predicate(item_2(index, array1), item_2(index, array2))) {
|
|
1118
1133
|
return true;
|
|
1119
1134
|
}
|
|
1120
1135
|
else {
|
|
@@ -1138,7 +1153,7 @@ export function exists2<$a, $b>(predicate: ((arg0: $a, arg1: $b) => boolean), ar
|
|
|
1138
1153
|
export function sum<T>(array: T[], adder: any): T {
|
|
1139
1154
|
let acc: T = adder.GetZero();
|
|
1140
1155
|
for (let i = 0; i <= (array.length - 1); i++) {
|
|
1141
|
-
acc = adder.Add(acc, array
|
|
1156
|
+
acc = adder.Add(acc, item_2(i, array));
|
|
1142
1157
|
}
|
|
1143
1158
|
return acc;
|
|
1144
1159
|
}
|
|
@@ -1146,7 +1161,7 @@ export function sum<T>(array: T[], adder: any): T {
|
|
|
1146
1161
|
export function sumBy<T, T2>(projection: ((arg0: T) => T2), array: T[], adder: any): T2 {
|
|
1147
1162
|
let acc: T2 = adder.GetZero();
|
|
1148
1163
|
for (let i = 0; i <= (array.length - 1); i++) {
|
|
1149
|
-
acc = adder.Add(acc, projection(array
|
|
1164
|
+
acc = adder.Add(acc, projection(item_2(i, array)));
|
|
1150
1165
|
}
|
|
1151
1166
|
return acc;
|
|
1152
1167
|
}
|
|
@@ -1173,7 +1188,7 @@ export function average<T>(array: T[], averager: any): T {
|
|
|
1173
1188
|
}
|
|
1174
1189
|
let total: T = averager.GetZero();
|
|
1175
1190
|
for (let i = 0; i <= (array.length - 1); i++) {
|
|
1176
|
-
total = averager.Add(total, array
|
|
1191
|
+
total = averager.Add(total, item_2(i, array));
|
|
1177
1192
|
}
|
|
1178
1193
|
return averager.DivideByInt(total, array.length);
|
|
1179
1194
|
}
|
|
@@ -1184,7 +1199,7 @@ export function averageBy<T, T2>(projection: ((arg0: T) => T2), array: T[], aver
|
|
|
1184
1199
|
}
|
|
1185
1200
|
let total: T2 = averager.GetZero();
|
|
1186
1201
|
for (let i = 0; i <= (array.length - 1); i++) {
|
|
1187
|
-
total = averager.Add(total, projection(array
|
|
1202
|
+
total = averager.Add(total, projection(item_2(i, array)));
|
|
1188
1203
|
}
|
|
1189
1204
|
return averager.DivideByInt(total, array.length);
|
|
1190
1205
|
}
|
|
@@ -1197,7 +1212,7 @@ export function windowed<T>(windowSize: int32, source: T[]): T[][] {
|
|
|
1197
1212
|
const len: int32 = max_1(0, (source.length - windowSize) + 1) | 0;
|
|
1198
1213
|
res = (new Array(len));
|
|
1199
1214
|
for (let i: int32 = windowSize; i <= source.length; i++) {
|
|
1200
|
-
res
|
|
1215
|
+
setItem_1(res, i - windowSize, source.slice(i - windowSize, (i - 1) + 1));
|
|
1201
1216
|
}
|
|
1202
1217
|
return res;
|
|
1203
1218
|
}
|
|
@@ -1232,16 +1247,16 @@ export function transpose<T>(arrays: Iterable<T[]>, cons?: any): T[][] {
|
|
|
1232
1247
|
return new Array(0);
|
|
1233
1248
|
}
|
|
1234
1249
|
else {
|
|
1235
|
-
const firstArray: T[] = arrays_1
|
|
1250
|
+
const firstArray: T[] = item_2(0, arrays_1);
|
|
1236
1251
|
const lenInner: int32 = firstArray.length | 0;
|
|
1237
1252
|
if (!forAll<T[]>((a: T[]): boolean => (a.length === lenInner), arrays_1)) {
|
|
1238
1253
|
differentLengths<void>();
|
|
1239
1254
|
}
|
|
1240
1255
|
const result: T[][] = new Array(lenInner);
|
|
1241
1256
|
for (let i = 0; i <= (lenInner - 1); i++) {
|
|
1242
|
-
result
|
|
1257
|
+
setItem_1(result, i, Helpers_allocateArrayFromCons<T>(cons, len));
|
|
1243
1258
|
for (let j = 0; j <= (len - 1); j++) {
|
|
1244
|
-
result[
|
|
1259
|
+
item_2(i, result)[j] = item_2(i, item_2(j, arrays_1));
|
|
1245
1260
|
}
|
|
1246
1261
|
}
|
|
1247
1262
|
return result;
|
|
@@ -1255,11 +1270,11 @@ export function insertAt<T>(index: int32, y: T, xs: T[], cons?: any): T[] {
|
|
|
1255
1270
|
}
|
|
1256
1271
|
const target: T[] = Helpers_allocateArrayFromCons<T>(cons, len + 1);
|
|
1257
1272
|
for (let i = 0; i <= (index - 1); i++) {
|
|
1258
|
-
target
|
|
1273
|
+
setItem_1(target, i, item_2(i, xs));
|
|
1259
1274
|
}
|
|
1260
|
-
target
|
|
1275
|
+
setItem_1(target, index, y);
|
|
1261
1276
|
for (let i_1: int32 = index; i_1 <= (len - 1); i_1++) {
|
|
1262
|
-
target
|
|
1277
|
+
setItem_1(target, i_1 + 1, item_2(i_1, xs));
|
|
1263
1278
|
}
|
|
1264
1279
|
return target;
|
|
1265
1280
|
}
|
|
@@ -1273,13 +1288,13 @@ export function insertManyAt<T>(index: int32, ys: Iterable<T>, xs: T[], cons?: a
|
|
|
1273
1288
|
const len2: int32 = ys_1.length | 0;
|
|
1274
1289
|
const target: T[] = Helpers_allocateArrayFromCons<T>(cons, len + len2);
|
|
1275
1290
|
for (let i = 0; i <= (index - 1); i++) {
|
|
1276
|
-
target
|
|
1291
|
+
setItem_1(target, i, item_2(i, xs));
|
|
1277
1292
|
}
|
|
1278
1293
|
for (let i_1 = 0; i_1 <= (len2 - 1); i_1++) {
|
|
1279
|
-
target
|
|
1294
|
+
setItem_1(target, index + i_1, item_2(i_1, ys_1));
|
|
1280
1295
|
}
|
|
1281
1296
|
for (let i_2: int32 = index; i_2 <= (len - 1); i_2++) {
|
|
1282
|
-
target
|
|
1297
|
+
setItem_1(target, i_2 + len2, item_2(i_2, xs));
|
|
1283
1298
|
}
|
|
1284
1299
|
return target;
|
|
1285
1300
|
}
|
|
@@ -1331,7 +1346,7 @@ export function updateAt<T>(index: int32, y: T, xs: T[], cons?: any): T[] {
|
|
|
1331
1346
|
}
|
|
1332
1347
|
const target: T[] = Helpers_allocateArrayFromCons<T>(cons, len);
|
|
1333
1348
|
for (let i = 0; i <= (len - 1); i++) {
|
|
1334
|
-
target
|
|
1349
|
+
setItem_1(target, i, (i === index) ? y : item_2(i, xs));
|
|
1335
1350
|
}
|
|
1336
1351
|
return target;
|
|
1337
1352
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,20 @@ 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
|
+
|
|
20
|
+
## 1.0.0 - 2024-02-13
|
|
21
|
+
|
|
22
|
+
* Release stable version
|
|
23
|
+
|
|
10
24
|
## 1.0.0-beta-001 - 2024-02-12
|
|
11
25
|
|
|
12
26
|
### Changed
|
package/List.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { int32 } from "./Int32.js";
|
|
|
5
5
|
import { Record } from "./Types.js";
|
|
6
6
|
import { class_type, record_type, option_type, TypeInfo } from "./Reflection.js";
|
|
7
7
|
import { SR_inputSequenceTooLong, SR_inputSequenceEmpty, SR_inputMustBeNonNegative, SR_notEnoughElements, SR_differentLengths, SR_keyNotFoundAlt, SR_indexOutOfBounds, SR_inputWasEmpty } from "./Global.js";
|
|
8
|
-
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";
|
|
8
|
+
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";
|
|
9
9
|
|
|
10
10
|
export class FSharpList<T> extends Record implements Iterable<T> {
|
|
11
11
|
readonly head: T;
|
|
@@ -384,7 +384,7 @@ export function toArray<T>(xs: FSharpList<T>): T[] {
|
|
|
384
384
|
while (true) {
|
|
385
385
|
const i: int32 = i_mut, xs_1: FSharpList<T> = xs_1_mut;
|
|
386
386
|
if (!FSharpList__get_IsEmpty<T>(xs_1)) {
|
|
387
|
-
res
|
|
387
|
+
setItem(res, i, FSharpList__get_Head<T>(xs_1));
|
|
388
388
|
i_mut = (i + 1);
|
|
389
389
|
xs_1_mut = FSharpList__get_Tail<T>(xs_1);
|
|
390
390
|
continue loop;
|
|
@@ -508,7 +508,7 @@ export function toSeq<T>(xs: FSharpList<T>): Iterable<T> {
|
|
|
508
508
|
export function ofArrayWithTail<T>(xs: T[], tail_1: FSharpList<T>): FSharpList<T> {
|
|
509
509
|
let res: FSharpList<T> = tail_1;
|
|
510
510
|
for (let i: int32 = xs.length - 1; i >= 0; i--) {
|
|
511
|
-
res = FSharpList_Cons_305B8EAC<T>(
|
|
511
|
+
res = FSharpList_Cons_305B8EAC<T>(item_1(i, xs), res);
|
|
512
512
|
}
|
|
513
513
|
return res;
|
|
514
514
|
}
|
package/Map.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { some, value as value_1, Option } from "./Option.js";
|
|
|
3
3
|
import { int32 } from "./Int32.js";
|
|
4
4
|
import { structuralHash, IMap, compare, toIterator, equals, IDisposable, disposeSafe, getEnumerator, isArrayLike, IEnumerator, IComparer } from "./Util.js";
|
|
5
5
|
import { singleton, ofArrayWithTail, head, tail, isEmpty as isEmpty_1, fold as fold_1, empty as empty_1, FSharpList, cons } from "./List.js";
|
|
6
|
-
import { map as map_2, fill } from "./Array.js";
|
|
6
|
+
import { map as map_2, item, fill, setItem } from "./Array.js";
|
|
7
7
|
import { FSharpRef, Record } from "./Types.js";
|
|
8
8
|
import { tryPick as tryPick_1, pick as pick_1, iterate as iterate_1, compareWith, map as map_1, unfold } from "./Seq.js";
|
|
9
9
|
import { format, join } from "./String.js";
|
|
@@ -817,7 +817,7 @@ export function MapTreeModule_toList<Key, Value>(m: Option<MapTreeLeaf$2<Key, Va
|
|
|
817
817
|
export function MapTreeModule_copyToArray<$a, $b>(m: Option<MapTreeLeaf$2<$a, $b>>, arr: [$a, $b][], i: int32): void {
|
|
818
818
|
let j: int32 = i;
|
|
819
819
|
MapTreeModule_iter<$a, $b>((x: $a, y: $b): void => {
|
|
820
|
-
arr
|
|
820
|
+
setItem(arr, j, [x, y] as [$a, $b]);
|
|
821
821
|
j = ((j + 1) | 0);
|
|
822
822
|
}, m);
|
|
823
823
|
}
|
|
@@ -854,7 +854,7 @@ export function MapTreeModule_mkFromEnumerator<$a, $b>(comparer_mut: IComparer<$
|
|
|
854
854
|
export function MapTreeModule_ofArray<Key, Value>(comparer: IComparer<Key>, arr: [Key, Value][]): Option<MapTreeLeaf$2<Key, Value>> {
|
|
855
855
|
let res: Option<MapTreeLeaf$2<Key, Value>> = MapTreeModule_empty<Key, Value>();
|
|
856
856
|
for (let idx = 0; idx <= (arr.length - 1); idx++) {
|
|
857
|
-
const forLoopVar: [Key, Value] = arr
|
|
857
|
+
const forLoopVar: [Key, Value] = item(idx, arr);
|
|
858
858
|
res = MapTreeModule_add<Key, Value>(comparer, forLoopVar[0], forLoopVar[1], res);
|
|
859
859
|
}
|
|
860
860
|
return res;
|
package/MutableMap.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { IEqualityComparer, IDisposable, disposeSafe, defaultOf, IMap, equals, t
|
|
|
2
2
|
import { iterate, map, delay, toArray, iterateIndexed, concat } from "./Seq.js";
|
|
3
3
|
import { value as value_1, Option } from "./Option.js";
|
|
4
4
|
import { int32 } from "./Int32.js";
|
|
5
|
+
import { setItem } from "./Array.js";
|
|
5
6
|
import { FSharpRef } from "./Types.js";
|
|
6
7
|
import { class_type, TypeInfo } from "./Reflection.js";
|
|
7
8
|
import { getItemFromDict, tryGetValue } from "./MapUtil.js";
|
|
@@ -80,7 +81,7 @@ export class Dictionary<Key, Value> implements IMap<Key, Value>, Iterable<[Key,
|
|
|
80
81
|
"System.Collections.Generic.ICollection`1.CopyToZ3B4C077E"(array: [Key, Value][], arrayIndex: int32): void {
|
|
81
82
|
const this$: Dictionary<Key, Value> = this;
|
|
82
83
|
iterateIndexed<[Key, Value]>((i: int32, e: [Key, Value]): void => {
|
|
83
|
-
array
|
|
84
|
+
setItem(array, arrayIndex + i, e);
|
|
84
85
|
}, this$);
|
|
85
86
|
}
|
|
86
87
|
"System.Collections.Generic.ICollection`1.get_Count"(): int32 {
|
package/MutableSet.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IMap, IEqualityComparer, IDisposable, disposeSafe, defaultOf, ISet, toIterator, IEnumerator, getEnumerator } from "./Util.js";
|
|
2
2
|
import { iterate, map, iterateIndexed, concat } from "./Seq.js";
|
|
3
|
+
import { setItem } from "./Array.js";
|
|
3
4
|
import { int32 } from "./Int32.js";
|
|
4
5
|
import { some, Option } from "./Option.js";
|
|
5
6
|
import { FSharpRef } from "./Types.js";
|
|
@@ -60,7 +61,7 @@ export class HashSet<T> implements ISet<T>, Iterable<T>, Iterable<T> {
|
|
|
60
61
|
"System.Collections.Generic.ICollection`1.CopyToZ3B4C077E"(array: T[], arrayIndex: int32): void {
|
|
61
62
|
const this$: HashSet<T> = this;
|
|
62
63
|
iterateIndexed<T>((i: int32, e: T): void => {
|
|
63
|
-
array
|
|
64
|
+
setItem(array, arrayIndex + i, e);
|
|
64
65
|
}, this$);
|
|
65
66
|
}
|
|
66
67
|
"System.Collections.Generic.ICollection`1.get_Count"(): int32 {
|
package/Random.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { uint8, int32, float64 } from "./Int32.js";
|
|
2
2
|
import { class_type, TypeInfo } from "./Reflection.js";
|
|
3
3
|
import { fromFloat64, op_Addition, toInt32, toFloat64, compare, int64, fromInt32, toInt64 } from "./BigInt.js";
|
|
4
|
-
import { fill } from "./Array.js";
|
|
4
|
+
import { item, fill, setItem } from "./Array.js";
|
|
5
5
|
|
|
6
6
|
function Native_random(): float64 {
|
|
7
7
|
return Math.random();
|
|
@@ -91,13 +91,13 @@ export class Seeded implements IRandom {
|
|
|
91
91
|
if (mk < 0) {
|
|
92
92
|
mk = ((mk + this.MBIG) | 0);
|
|
93
93
|
}
|
|
94
|
-
mj = (this.seedArray
|
|
94
|
+
mj = (item(ii, this.seedArray) | 0);
|
|
95
95
|
}
|
|
96
96
|
for (let k = 1; k <= 4; k++) {
|
|
97
97
|
for (let i_1 = 1; i_1 <= 55; i_1++) {
|
|
98
|
-
this.seedArray[i_1] = ((this.seedArray
|
|
99
|
-
if (this.seedArray
|
|
100
|
-
this.seedArray[i_1] = ((this.seedArray
|
|
98
|
+
this.seedArray[i_1] = ((item(i_1, this.seedArray) - item(1 + ((i_1 + 30) % 55), this.seedArray)) | 0);
|
|
99
|
+
if (item(i_1, this.seedArray) < 0) {
|
|
100
|
+
this.seedArray[i_1] = ((item(i_1, this.seedArray) + this.MBIG) | 0);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -133,7 +133,7 @@ export class Seeded implements IRandom {
|
|
|
133
133
|
throw new Error("buffer");
|
|
134
134
|
}
|
|
135
135
|
for (let i = 0; i <= (buffer.length - 1); i++) {
|
|
136
|
-
buffer
|
|
136
|
+
setItem(buffer, i, (Seeded__InternalSample(this$) % (~~255 + 1)) & 0xFF);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
}
|
|
@@ -158,7 +158,7 @@ function Seeded__InternalSample(_: Seeded): int32 {
|
|
|
158
158
|
if (locINextp >= 56) {
|
|
159
159
|
locINextp = 1;
|
|
160
160
|
}
|
|
161
|
-
retVal = ((_.seedArray
|
|
161
|
+
retVal = ((item(locINext, _.seedArray) - item(locINextp, _.seedArray)) | 0);
|
|
162
162
|
if (retVal === _.MBIG) {
|
|
163
163
|
retVal = ((retVal - 1) | 0);
|
|
164
164
|
}
|
package/Set.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { int32 } from "./Int32.js";
|
|
|
4
4
|
import { structuralHash, ISet, toIterator, IDisposable, disposeSafe, getEnumerator, isArrayLike, IEnumerator, IComparer } from "./Util.js";
|
|
5
5
|
import { toString, Record } from "./Types.js";
|
|
6
6
|
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";
|
|
7
|
-
import { fold as fold_1, fill } from "./Array.js";
|
|
7
|
+
import { fold as fold_1, fill, setItem } from "./Array.js";
|
|
8
8
|
import { join } from "./String.js";
|
|
9
9
|
import { exists as exists_1, cache, forAll as forAll_1, fold as fold_3, reduce, iterate as iterate_1, map as map_1 } from "./Seq.js";
|
|
10
10
|
import { HashSet__get_Comparer, HashSet_$ctor_Z6150332D, HashSet } from "./MutableSet.js";
|
|
@@ -1420,7 +1420,7 @@ export function SetTreeModule_toList<T>(t: Option<SetTreeLeaf$1<T>>): FSharpList
|
|
|
1420
1420
|
export function SetTreeModule_copyToArray<$a>(s: Option<SetTreeLeaf$1<$a>>, arr: $a[], i: int32): void {
|
|
1421
1421
|
let j: int32 = i;
|
|
1422
1422
|
SetTreeModule_iter<$a>((x: $a): void => {
|
|
1423
|
-
arr
|
|
1423
|
+
setItem(arr, j, x);
|
|
1424
1424
|
j = ((j + 1) | 0);
|
|
1425
1425
|
}, s);
|
|
1426
1426
|
}
|
package/String.ts
CHANGED
|
@@ -568,6 +568,10 @@ export function substring(str: string, startIndex: number, length?: number) {
|
|
|
568
568
|
return length != null ? str.substr(startIndex, length) : str.substr(startIndex);
|
|
569
569
|
}
|
|
570
570
|
|
|
571
|
+
export function toCharArray2(str: string, startIndex: number, length: number) {
|
|
572
|
+
return substring(str, startIndex, length).split("")
|
|
573
|
+
}
|
|
574
|
+
|
|
571
575
|
interface FormattableString {
|
|
572
576
|
strs: TemplateStringsArray,
|
|
573
577
|
args: any[],
|
|
@@ -2,7 +2,7 @@ import { int32 } from "./Int32.js";
|
|
|
2
2
|
import { IDisposable, disposeSafe, defaultOf, toIterator, IEnumerator, getEnumerator, structuralHash, equals as equals_1, IEqualityComparer, compare, IComparer } from "./Util.js";
|
|
3
3
|
import { class_type, TypeInfo } from "./Reflection.js";
|
|
4
4
|
import { toArray, empty, singleton, append, enumerateWhile, delay } from "./Seq.js";
|
|
5
|
-
import { initialize, copyTo, fill } from "./Array.js";
|
|
5
|
+
import { setItem, initialize, copyTo, fill, item as item_1 } from "./Array.js";
|
|
6
6
|
import { max } from "./Double.js";
|
|
7
7
|
import { FSharpRef } from "./Types.js";
|
|
8
8
|
|
|
@@ -89,7 +89,7 @@ export class Stack$1<T> implements Iterable<T> {
|
|
|
89
89
|
const _: Stack$1<T> = this;
|
|
90
90
|
return getEnumerator(delay<T>((): Iterable<T> => {
|
|
91
91
|
let index: int32 = _.count - 1;
|
|
92
|
-
return enumerateWhile<T>((): boolean => (index >= 0), delay<T>((): Iterable<T> => append<T>(singleton<T>(_.contents
|
|
92
|
+
return enumerateWhile<T>((): boolean => (index >= 0), delay<T>((): Iterable<T> => append<T>(singleton<T>(item_1(index, _.contents)), delay<T>((): Iterable<T> => {
|
|
93
93
|
index = ((index - 1) | 0);
|
|
94
94
|
return empty<T>();
|
|
95
95
|
}))));
|
|
@@ -140,18 +140,18 @@ export function Stack$1__get_Count<T>(_: Stack$1<T>): int32 {
|
|
|
140
140
|
|
|
141
141
|
export function Stack$1__Pop<T>(_: Stack$1<T>): T {
|
|
142
142
|
_.count = ((_.count - 1) | 0);
|
|
143
|
-
return _.
|
|
143
|
+
return item_1(_.count, _.contents);
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
export function Stack$1__Peek<T>(_: Stack$1<T>): T {
|
|
147
|
-
return _.
|
|
147
|
+
return item_1(_.count - 1, _.contents);
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
export function Stack$1__Contains_2B595<T>(_: Stack$1<T>, x: T): boolean {
|
|
151
151
|
let found = false;
|
|
152
152
|
let i = 0;
|
|
153
153
|
while ((i < _.count) && !found) {
|
|
154
|
-
if (equals_1(x, _.contents
|
|
154
|
+
if (equals_1(x, item_1(i, _.contents))) {
|
|
155
155
|
found = true;
|
|
156
156
|
}
|
|
157
157
|
else {
|
|
@@ -199,7 +199,7 @@ export function Stack$1__TrimExcess<T>(this$: Stack$1<T>): void {
|
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
export function Stack$1__ToArray<T>(_: Stack$1<T>): T[] {
|
|
202
|
-
return initialize<T>(_.count, (i: int32): T =>
|
|
202
|
+
return initialize<T>(_.count, (i: int32): T => item_1((_.count - 1) - i, _.contents));
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
export class Queue$1<T> implements Iterable<T> {
|
|
@@ -267,7 +267,7 @@ export function Queue$1__Dequeue<T>(_: Queue$1<T>): T {
|
|
|
267
267
|
if (_.count === 0) {
|
|
268
268
|
throw new Error("Queue is empty");
|
|
269
269
|
}
|
|
270
|
-
const value: T = _.
|
|
270
|
+
const value: T = item_1(_.head, _.contents);
|
|
271
271
|
_.head = (((_.head + 1) % Queue$1__size<T>(_)) | 0);
|
|
272
272
|
_.count = ((_.count - 1) | 0);
|
|
273
273
|
return value;
|
|
@@ -277,7 +277,7 @@ export function Queue$1__Peek<T>(_: Queue$1<T>): T {
|
|
|
277
277
|
if (_.count === 0) {
|
|
278
278
|
throw new Error("Queue is empty");
|
|
279
279
|
}
|
|
280
|
-
return _.
|
|
280
|
+
return item_1(_.head, _.contents);
|
|
281
281
|
}
|
|
282
282
|
|
|
283
283
|
export function Queue$1__TryDequeue_1F3DB691<T>(this$: Queue$1<T>, result: FSharpRef<T>): boolean {
|
|
@@ -304,7 +304,7 @@ export function Queue$1__Contains_2B595<T>(_: Queue$1<T>, x: T): boolean {
|
|
|
304
304
|
let found = false;
|
|
305
305
|
let i = 0;
|
|
306
306
|
while ((i < _.count) && !found) {
|
|
307
|
-
if (equals_1(x,
|
|
307
|
+
if (equals_1(x, item_1(Queue$1__toIndex_Z524259A4<T>(_, i), _.contents))) {
|
|
308
308
|
found = true;
|
|
309
309
|
}
|
|
310
310
|
else {
|
|
@@ -337,7 +337,7 @@ export function Queue$1__CopyTo_Z3B4C077E<T>(_: Queue$1<T>, target: T[], start:
|
|
|
337
337
|
try {
|
|
338
338
|
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
339
339
|
const item: T = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
340
|
-
target
|
|
340
|
+
setItem(target, i, item);
|
|
341
341
|
i = ((i + 1) | 0);
|
|
342
342
|
}
|
|
343
343
|
}
|
|
@@ -371,7 +371,7 @@ export function Queue$1__ensure_Z524259A4<T>(this$: Queue$1<T>, requiredSize: in
|
|
|
371
371
|
export function Queue$1__toSeq<T>(this$: Queue$1<T>): Iterable<T> {
|
|
372
372
|
return delay<T>((): Iterable<T> => {
|
|
373
373
|
let i = 0;
|
|
374
|
-
return enumerateWhile<T>((): boolean => (i < this$.count), delay<T>((): Iterable<T> => append<T>(singleton<T>(
|
|
374
|
+
return enumerateWhile<T>((): boolean => (i < this$.count), delay<T>((): Iterable<T> => append<T>(singleton<T>(item_1(Queue$1__toIndex_Z524259A4<T>(this$, i), this$.contents)), delay<T>((): Iterable<T> => {
|
|
375
375
|
i = ((i + 1) | 0);
|
|
376
376
|
return empty<T>();
|
|
377
377
|
}))));
|
package/System.Text.ts
CHANGED
|
@@ -88,11 +88,41 @@ export function StringBuilder__AppendFormat_433E080(x: StringBuilder, fmt: strin
|
|
|
88
88
|
return x;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
export function StringBuilder__AppendFormat_Z3B30EC65(x: StringBuilder, fmt: string, o1: any, o2: any): StringBuilder {
|
|
92
|
+
void (x.buf.push(format(fmt, o1, o2)));
|
|
93
|
+
return x;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function StringBuilder__AppendFormat_10D165E0(x: StringBuilder, fmt: string, o1: any, o2: any, o3: any): StringBuilder {
|
|
97
|
+
void (x.buf.push(format(fmt, o1, o2, o3)));
|
|
98
|
+
return x;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function StringBuilder__AppendFormat_Z17053F5(x: StringBuilder, fmt: string, arr: any[]): StringBuilder {
|
|
102
|
+
void (x.buf.push(format(fmt, ...arr)));
|
|
103
|
+
return x;
|
|
104
|
+
}
|
|
105
|
+
|
|
91
106
|
export function StringBuilder__AppendFormat_Z696D8D1B(x: StringBuilder, provider: any, fmt: string, o: any): StringBuilder {
|
|
92
107
|
void (x.buf.push(format(provider, fmt, o)));
|
|
93
108
|
return x;
|
|
94
109
|
}
|
|
95
110
|
|
|
111
|
+
export function StringBuilder__AppendFormat_26802C9E(x: StringBuilder, provider: any, fmt: string, o1: any, o2: any): StringBuilder {
|
|
112
|
+
void (x.buf.push(format(provider, fmt, o1, o2)));
|
|
113
|
+
return x;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function StringBuilder__AppendFormat_Z471ADCBB(x: StringBuilder, provider: any, fmt: string, o1: any, o2: any, o3: any): StringBuilder {
|
|
117
|
+
void (x.buf.push(format(provider, fmt, o1, o2, o3)));
|
|
118
|
+
return x;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function StringBuilder__AppendFormat_6C2E3E6E(x: StringBuilder, provider: any, fmt: string, arr: any[]): StringBuilder {
|
|
122
|
+
void (x.buf.push(format(provider, fmt, ...arr)));
|
|
123
|
+
return x;
|
|
124
|
+
}
|
|
125
|
+
|
|
96
126
|
export function StringBuilder__AppendLine(x: StringBuilder): StringBuilder {
|
|
97
127
|
void (x.buf.push("\n"));
|
|
98
128
|
return x;
|
|
@@ -104,6 +134,43 @@ export function StringBuilder__AppendLine_Z721C83C5(x: StringBuilder, s: string)
|
|
|
104
134
|
return x;
|
|
105
135
|
}
|
|
106
136
|
|
|
137
|
+
export function StringBuilder__Clear(x: StringBuilder): StringBuilder {
|
|
138
|
+
clear(x.buf);
|
|
139
|
+
return x;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function StringBuilder__get_Chars_Z524259A4(x: StringBuilder, index: int32): string {
|
|
143
|
+
let len = 0;
|
|
144
|
+
let i = -1;
|
|
145
|
+
while (((i + 1) < x.buf.length) && (len < index)) {
|
|
146
|
+
i = ((i + 1) | 0);
|
|
147
|
+
len = ((len + x.buf[i].length) | 0);
|
|
148
|
+
}
|
|
149
|
+
if (((index < 0) ? true : (i < 0)) ? true : (i >= x.buf.length)) {
|
|
150
|
+
throw new Error("Index was outside the bounds of the array");
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
const pos: int32 = ((len - index) - 1) | 0;
|
|
154
|
+
return x.buf[i][pos];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function StringBuilder__set_Chars_413E0D0A(x: StringBuilder, index: int32, value: string): void {
|
|
159
|
+
let len = 0;
|
|
160
|
+
let i = -1;
|
|
161
|
+
while (((i + 1) < x.buf.length) && (len < index)) {
|
|
162
|
+
i = ((i + 1) | 0);
|
|
163
|
+
len = ((len + x.buf[i].length) | 0);
|
|
164
|
+
}
|
|
165
|
+
if (((index < 0) ? true : (i < 0)) ? true : (i >= x.buf.length)) {
|
|
166
|
+
throw new Error("Index was outside the bounds of the array");
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
const pos: int32 = ((len - index) - 1) | 0;
|
|
170
|
+
x.buf[i] = ((x.buf[i].slice(0, (pos - 1) + 1) + value) + x.buf[i].slice(pos + 1, x.buf[i].length));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
107
174
|
export function StringBuilder__Replace_Z766F94C0(x: StringBuilder, oldValue: string, newValue: string): StringBuilder {
|
|
108
175
|
for (let i: int32 = x.buf.length - 1; i >= 0; i--) {
|
|
109
176
|
x.buf[i] = replace(x.buf[i], oldValue, newValue);
|
|
@@ -112,10 +179,8 @@ export function StringBuilder__Replace_Z766F94C0(x: StringBuilder, oldValue: str
|
|
|
112
179
|
}
|
|
113
180
|
|
|
114
181
|
export function StringBuilder__Replace_Z384F8060(x: StringBuilder, oldValue: string, newValue: string): StringBuilder {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
return x;
|
|
182
|
+
const str: string = replace(toString(x), oldValue, newValue);
|
|
183
|
+
return StringBuilder__Append_Z721C83C5(StringBuilder__Clear(x), str);
|
|
119
184
|
}
|
|
120
185
|
|
|
121
186
|
export function StringBuilder__get_Length(x: StringBuilder): int32 {
|
|
@@ -130,8 +195,3 @@ export function StringBuilder__ToString_Z37302880(x: StringBuilder, firstIndex:
|
|
|
130
195
|
return substring(toString(x), firstIndex, length);
|
|
131
196
|
}
|
|
132
197
|
|
|
133
|
-
export function StringBuilder__Clear(x: StringBuilder): StringBuilder {
|
|
134
|
-
clear(x.buf);
|
|
135
|
-
return x;
|
|
136
|
-
}
|
|
137
|
-
|
package/package.json
CHANGED