@fable-org/fable-library-js 1.0.0 → 1.2.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 +18 -0
- package/Date.js +336 -39
- 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/Util.js +2 -13
- 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,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## Unreleased
|
|
9
9
|
|
|
10
|
+
## 1.2.0 - 2024-03-01
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
* [GH-3772](https://github.com/fable-compiler/Fable/pull/3772) [JS/TS] Re-implement `DateTime.ToString` custom format handling (by @MangelMaxime)
|
|
15
|
+
|
|
16
|
+
It now supports all custom format specifiers, and behave as if `CultureInfo.InvariantCulture` was used (Fable does not support Globalization).
|
|
17
|
+
|
|
18
|
+
## 1.1.0 - 2024-02-20
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
#### JavaScript
|
|
23
|
+
|
|
24
|
+
* [GH-3759](https://github.com/fable-compiler/Fable/issues/3759) Add `StringBuilder.Chars` (by @MangelMaxime)
|
|
25
|
+
* Add `StringBuilder.AppendFormat` (by @ncave)
|
|
26
|
+
* [GH-3748](https://github.com/fable-compiler/Fable/pull/3748) Add `Array.getItem` and `Array.setItem` (by @MangelMaxime)
|
|
27
|
+
|
|
10
28
|
## 1.0.0 - 2024-02-13
|
|
11
29
|
|
|
12
30
|
* Release stable version
|