@fable-org/fable-library-ts 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.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[i] = array1[i];
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[i_1 + len1] = array2[i_1];
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[array.length - 1];
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[array.length - 1]);
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[i] = f(i, source[i]);
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[i] = f(source[i]);
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[i] = f(i, source1[i], source2[i]);
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[i] = f(source1[i], source2[i]);
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[i] = f(i, source1[i], source2[i], source3[i]);
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[i] = f(source1[i], source2[i], source3[i]);
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[i]);
132
- res[i] = patternInput[0];
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(array[i], acc);
149
- res[i] = patternInput[0];
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] = ([i, source[i]] as [int32, T]);
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[0];
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[idx];
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[idx_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[totalIdx] = arr_2[j];
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[i])) {
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[0] = value;
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[i] = initializer(i);
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[i] = ([array[i], array[i + 1]] as [T, T]);
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[i] = initial;
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[0] = state;
295
+ setItem_1(res, 0, state);
295
296
  for (let i = 0; i <= (array.length - 1); i++) {
296
- res[i + 1] = folder(res[i], array[i]);
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[array.length] = state;
304
+ setItem_1(res, array.length, state);
304
305
  for (let i: int32 = array.length - 1; i >= 0; i--) {
305
- res[i] = folder(array[i], res[i + 1]);
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[count])) {
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[count])) {
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[i])) {
431
- res1[iTrue] = source[i];
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[iFalse] = source[i];
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[i]);
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[i]);
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[i])) {
534
- return array[i];
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[i])) {
555
- return some(array[i]);
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[i])) {
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[i])) {
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[i])) {
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[i]);
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[i]);
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[i]);
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[i], array2[i]);
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[i], array2[i]);
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[j] = x;
705
- checkFlags[j] = 1;
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[i + lower_1] = source[i];
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[(i * len2) + j] = ([xs[i], ys[j]] as [T1, T2]);
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[i] = tupledArg[0];
800
- res2[i] = tupledArg[1];
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[i] = tupledArg[0];
812
- res2[i] = tupledArg[1];
813
- res3[i] = tupledArg[2];
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] = ([array1[i], array2[i]] as [T, U]);
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] = ([array1[i], array2[i], array3[i]] as [T, U, V]);
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[i], source2[i]) | 0);
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[i], source2[i]) | 0);
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[i], array2[i]);
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[0];
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[0]);
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[0];
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[0]);
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<$a>(index: int32, array: $a[]): $a {
1015
- return array[index];
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[i], array2[i]);
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, array1[size - i], array2[size - i], acc);
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[index])) {
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[index], array2[index])) {
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[i]);
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[i]));
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[i]);
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[i]));
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[i - windowSize] = source.slice(i - windowSize, (i - 1) + 1);
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[0];
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[i] = Helpers_allocateArrayFromCons<T>(cons, len);
1257
+ setItem_1(result, i, Helpers_allocateArrayFromCons<T>(cons, len));
1243
1258
  for (let j = 0; j <= (len - 1); j++) {
1244
- result[i][j] = arrays_1[j][i];
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[i] = xs[i];
1273
+ setItem_1(target, i, item_2(i, xs));
1259
1274
  }
1260
- target[index] = y;
1275
+ setItem_1(target, index, y);
1261
1276
  for (let i_1: int32 = index; i_1 <= (len - 1); i_1++) {
1262
- target[i_1 + 1] = xs[i_1];
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[i] = xs[i];
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[index + i_1] = ys_1[i_1];
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[i_2 + len2] = xs[i_2];
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[i] = ((i === index) ? y : xs[i]);
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,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