@fable-org/fable-library-js 2.10.0 → 2.12.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/Set.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { record_type, bool_type, list_type, option_type, class_type } from "./Reflection.js";
2
2
  import { some, value as value_2 } from "./Option.js";
3
- import { structuralHash, toIterator, disposeSafe, getEnumerator, isArrayLike, Exception } from "./Util.js";
3
+ import { structuralHash, toIterator, disposeSafe, getEnumerator, isArrayLike, physicalHash, Exception } from "./Util.js";
4
+ import { Operators_InvalidOp, Operators_InvalidArg } from "./FSharp.Core.js";
4
5
  import { toString, Record } from "./Types.js";
5
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";
6
7
  import { fold as fold_1, fill, setItem } from "./Array.js";
@@ -51,7 +52,7 @@ export function SetTreeModule_countAux(t_mut, acc_mut) {
51
52
  SetTreeModule_countAux: while (true) {
52
53
  const t = t_mut, acc = acc_mut;
53
54
  if (t != null) {
54
- const t2 = value_2(t);
55
+ const t2 = t;
55
56
  if (t2 instanceof SetTreeNode$1) {
56
57
  const tn = t2;
57
58
  t_mut = SetTreeNode$1__get_Left(tn);
@@ -76,7 +77,7 @@ export function SetTreeModule_mk(l, k, r) {
76
77
  let hl;
77
78
  const t = l;
78
79
  if (t != null) {
79
- const t2 = value_2(t);
80
+ const t2 = t;
80
81
  hl = ((t2 instanceof SetTreeNode$1) ? ((tn = t2, SetTreeNode$1__get_Height(tn))) : 1);
81
82
  }
82
83
  else {
@@ -85,7 +86,7 @@ export function SetTreeModule_mk(l, k, r) {
85
86
  let hr;
86
87
  const t_1 = r;
87
88
  if (t_1 != null) {
88
- const t2_1 = value_2(t_1);
89
+ const t2_1 = t_1;
89
90
  hr = ((t2_1 instanceof SetTreeNode$1) ? ((tn_1 = t2_1, SetTreeNode$1__get_Height(tn_1))) : 1);
90
91
  }
91
92
  else {
@@ -104,7 +105,7 @@ export function SetTreeModule_rebalance(t1, v, t2) {
104
105
  let t1h;
105
106
  const t = t1;
106
107
  if (t != null) {
107
- const t2_1 = value_2(t);
108
+ const t2_1 = t;
108
109
  t1h = ((t2_1 instanceof SetTreeNode$1) ? ((tn = t2_1, SetTreeNode$1__get_Height(tn))) : 1);
109
110
  }
110
111
  else {
@@ -113,7 +114,7 @@ export function SetTreeModule_rebalance(t1, v, t2) {
113
114
  let t2h;
114
115
  const t_1 = t2;
115
116
  if (t_1 != null) {
116
- const t2_2 = value_2(t_1);
117
+ const t2_2 = t_1;
117
118
  t2h = ((t2_2 instanceof SetTreeNode$1) ? ((tn_1 = t2_2, SetTreeNode$1__get_Height(tn_1))) : 1);
118
119
  }
119
120
  else {
@@ -123,7 +124,7 @@ export function SetTreeModule_rebalance(t1, v, t2) {
123
124
  const matchValue = value_2(t2);
124
125
  if (matchValue instanceof SetTreeNode$1) {
125
126
  const t2$0027 = matchValue;
126
- if (((t_2 = SetTreeNode$1__get_Left(t2$0027), (t_2 != null) ? ((t2_3 = value_2(t_2), (t2_3 instanceof SetTreeNode$1) ? ((tn_2 = t2_3, SetTreeNode$1__get_Height(tn_2))) : 1)) : 0)) > (t1h + 1)) {
127
+ if (((t_2 = SetTreeNode$1__get_Left(t2$0027), (t_2 != null) ? ((t2_3 = t_2, (t2_3 instanceof SetTreeNode$1) ? ((tn_2 = t2_3, SetTreeNode$1__get_Height(tn_2))) : 1)) : 0)) > (t1h + 1)) {
127
128
  const matchValue_1 = value_2(SetTreeNode$1__get_Left(t2$0027));
128
129
  if (matchValue_1 instanceof SetTreeNode$1) {
129
130
  const t2l = matchValue_1;
@@ -145,7 +146,7 @@ export function SetTreeModule_rebalance(t1, v, t2) {
145
146
  const matchValue_2 = value_2(t1);
146
147
  if (matchValue_2 instanceof SetTreeNode$1) {
147
148
  const t1$0027 = matchValue_2;
148
- if (((t_3 = SetTreeNode$1__get_Right(t1$0027), (t_3 != null) ? ((t2_4 = value_2(t_3), (t2_4 instanceof SetTreeNode$1) ? ((tn_3 = t2_4, SetTreeNode$1__get_Height(tn_3))) : 1)) : 0)) > (t2h + 1)) {
149
+ if (((t_3 = SetTreeNode$1__get_Right(t1$0027), (t_3 != null) ? ((t2_4 = t_3, (t2_4 instanceof SetTreeNode$1) ? ((tn_3 = t2_4, SetTreeNode$1__get_Height(tn_3))) : 1)) : 0)) > (t2h + 1)) {
149
150
  const matchValue_3 = value_2(SetTreeNode$1__get_Right(t1$0027));
150
151
  if (matchValue_3 instanceof SetTreeNode$1) {
151
152
  const t1r = matchValue_3;
@@ -169,7 +170,7 @@ export function SetTreeModule_rebalance(t1, v, t2) {
169
170
  }
170
171
  export function SetTreeModule_add(comparer, k, t) {
171
172
  if (t != null) {
172
- const t2 = value_2(t);
173
+ const t2 = t;
173
174
  const c = comparer.Compare(k, SetTreeLeaf$1__get_Key(t2)) | 0;
174
175
  if (t2 instanceof SetTreeNode$1) {
175
176
  const tn = t2;
@@ -202,9 +203,9 @@ export function SetTreeModule_add(comparer, k, t) {
202
203
  }
203
204
  export function SetTreeModule_balance(comparer, t1, k, t2) {
204
205
  if (t1 != null) {
205
- const t1$0027 = value_2(t1);
206
+ const t1$0027 = t1;
206
207
  if (t2 != null) {
207
- const t2$0027 = value_2(t2);
208
+ const t2$0027 = t2;
208
209
  if (t1$0027 instanceof SetTreeNode$1) {
209
210
  const t1n = t1$0027;
210
211
  if (t2$0027 instanceof SetTreeNode$1) {
@@ -237,7 +238,7 @@ export function SetTreeModule_balance(comparer, t1, k, t2) {
237
238
  }
238
239
  export function SetTreeModule_split(comparer, pivot, t) {
239
240
  if (t != null) {
240
- const t2 = value_2(t);
241
+ const t2 = t;
241
242
  if (t2 instanceof SetTreeNode$1) {
242
243
  const tn = t2;
243
244
  const c = comparer.Compare(pivot, SetTreeLeaf$1__get_Key(tn)) | 0;
@@ -272,7 +273,7 @@ export function SetTreeModule_split(comparer, pivot, t) {
272
273
  }
273
274
  export function SetTreeModule_spliceOutSuccessor(t) {
274
275
  if (t != null) {
275
- const t2 = value_2(t);
276
+ const t2 = t;
276
277
  if (t2 instanceof SetTreeNode$1) {
277
278
  const tn = t2;
278
279
  if (SetTreeNode$1__get_Left(tn) == null) {
@@ -293,7 +294,7 @@ export function SetTreeModule_spliceOutSuccessor(t) {
293
294
  }
294
295
  export function SetTreeModule_remove(comparer, k, t) {
295
296
  if (t != null) {
296
- const t2 = value_2(t);
297
+ const t2 = t;
297
298
  const c = comparer.Compare(k, SetTreeLeaf$1__get_Key(t2)) | 0;
298
299
  if (t2 instanceof SetTreeNode$1) {
299
300
  const tn = t2;
@@ -331,7 +332,7 @@ export function SetTreeModule_mem(comparer_mut, k_mut, t_mut) {
331
332
  SetTreeModule_mem: while (true) {
332
333
  const comparer = comparer_mut, k = k_mut, t = t_mut;
333
334
  if (t != null) {
334
- const t2 = value_2(t);
335
+ const t2 = t;
335
336
  const c = comparer.Compare(k, SetTreeLeaf$1__get_Key(t2)) | 0;
336
337
  if (t2 instanceof SetTreeNode$1) {
337
338
  const tn = t2;
@@ -365,7 +366,7 @@ export function SetTreeModule_iter(f_mut, t_mut) {
365
366
  SetTreeModule_iter: while (true) {
366
367
  const f = f_mut, t = t_mut;
367
368
  if (t != null) {
368
- const t2 = value_2(t);
369
+ const t2 = t;
369
370
  if (t2 instanceof SetTreeNode$1) {
370
371
  const tn = t2;
371
372
  SetTreeModule_iter(f, SetTreeNode$1__get_Left(tn));
@@ -385,7 +386,7 @@ export function SetTreeModule_foldBackOpt(f_mut, t_mut, x_mut) {
385
386
  SetTreeModule_foldBackOpt: while (true) {
386
387
  const f = f_mut, t = t_mut, x = x_mut;
387
388
  if (t != null) {
388
- const t2 = value_2(t);
389
+ const t2 = t;
389
390
  if (t2 instanceof SetTreeNode$1) {
390
391
  const tn = t2;
391
392
  f_mut = f;
@@ -410,7 +411,7 @@ export function SetTreeModule_foldOpt(f_mut, x_mut, t_mut) {
410
411
  SetTreeModule_foldOpt: while (true) {
411
412
  const f = f_mut, x = x_mut, t = t_mut;
412
413
  if (t != null) {
413
- const t2 = value_2(t);
414
+ const t2 = t;
414
415
  if (t2 instanceof SetTreeNode$1) {
415
416
  const tn = t2;
416
417
  f_mut = f;
@@ -435,7 +436,7 @@ export function SetTreeModule_forall(f_mut, t_mut) {
435
436
  SetTreeModule_forall: while (true) {
436
437
  const f = f_mut, t = t_mut;
437
438
  if (t != null) {
438
- const t2 = value_2(t);
439
+ const t2 = t;
439
440
  if (t2 instanceof SetTreeNode$1) {
440
441
  const tn = t2;
441
442
  if (f(SetTreeLeaf$1__get_Key(tn)) && SetTreeModule_forall(f, SetTreeNode$1__get_Left(tn))) {
@@ -461,7 +462,7 @@ export function SetTreeModule_exists(f_mut, t_mut) {
461
462
  SetTreeModule_exists: while (true) {
462
463
  const f = f_mut, t = t_mut;
463
464
  if (t != null) {
464
- const t2 = value_2(t);
465
+ const t2 = t;
465
466
  if (t2 instanceof SetTreeNode$1) {
466
467
  const tn = t2;
467
468
  if (f(SetTreeLeaf$1__get_Key(tn)) ? true : SetTreeModule_exists(f, SetTreeNode$1__get_Left(tn))) {
@@ -498,7 +499,7 @@ export function SetTreeModule_filterAux(comparer_mut, f_mut, t_mut, acc_mut) {
498
499
  SetTreeModule_filterAux: while (true) {
499
500
  const comparer = comparer_mut, f = f_mut, t = t_mut, acc = acc_mut;
500
501
  if (t != null) {
501
- const t2 = value_2(t);
502
+ const t2 = t;
502
503
  if (t2 instanceof SetTreeNode$1) {
503
504
  const tn = t2;
504
505
  const acc_1 = f(SetTreeLeaf$1__get_Key(tn)) ? SetTreeModule_add(comparer, SetTreeLeaf$1__get_Key(tn), acc) : acc;
@@ -531,7 +532,7 @@ export function SetTreeModule_diffAux(comparer_mut, t_mut, acc_mut) {
531
532
  return acc;
532
533
  }
533
534
  else if (t != null) {
534
- const t2 = value_2(t);
535
+ const t2 = t;
535
536
  if (t2 instanceof SetTreeNode$1) {
536
537
  const tn = t2;
537
538
  comparer_mut = comparer;
@@ -554,9 +555,9 @@ export function SetTreeModule_diff(comparer, a, b) {
554
555
  }
555
556
  export function SetTreeModule_union(comparer, t1, t2) {
556
557
  if (t1 != null) {
557
- const t1$0027 = value_2(t1);
558
+ const t1$0027 = t1;
558
559
  if (t2 != null) {
559
- const t2$0027 = value_2(t2);
560
+ const t2$0027 = t2;
560
561
  if (t1$0027 instanceof SetTreeNode$1) {
561
562
  const t1n = t1$0027;
562
563
  if (t2$0027 instanceof SetTreeNode$1) {
@@ -590,7 +591,7 @@ export function SetTreeModule_intersectionAux(comparer_mut, b_mut, t_mut, acc_mu
590
591
  SetTreeModule_intersectionAux: while (true) {
591
592
  const comparer = comparer_mut, b = b_mut, t = t_mut, acc = acc_mut;
592
593
  if (t != null) {
593
- const t2 = value_2(t);
594
+ const t2 = t;
594
595
  if (t2 instanceof SetTreeNode$1) {
595
596
  const tn = t2;
596
597
  const acc_1 = SetTreeModule_intersectionAux(comparer, b, SetTreeNode$1__get_Right(tn), acc);
@@ -630,7 +631,7 @@ export function SetTreeModule_partitionAux(comparer_mut, f_mut, t_mut, acc__mut,
630
631
  const comparer = comparer_mut, f = f_mut, t = t_mut, acc_ = acc__mut, acc__1 = acc__1_mut;
631
632
  const acc = [acc_, acc__1];
632
633
  if (t != null) {
633
- const t2 = value_2(t);
634
+ const t2 = t;
634
635
  if (t2 instanceof SetTreeNode$1) {
635
636
  const tn = t2;
636
637
  const acc_1 = SetTreeModule_partitionAux(comparer, f, SetTreeNode$1__get_Right(tn), acc[0], acc[1]);
@@ -659,7 +660,7 @@ export function SetTreeModule_minimumElementAux(t_mut, n_mut) {
659
660
  SetTreeModule_minimumElementAux: while (true) {
660
661
  const t = t_mut, n = n_mut;
661
662
  if (t != null) {
662
- const t2 = value_2(t);
663
+ const t2 = t;
663
664
  if (t2 instanceof SetTreeNode$1) {
664
665
  const tn = t2;
665
666
  t_mut = SetTreeNode$1__get_Left(tn);
@@ -678,7 +679,7 @@ export function SetTreeModule_minimumElementAux(t_mut, n_mut) {
678
679
  }
679
680
  export function SetTreeModule_minimumElementOpt(t) {
680
681
  if (t != null) {
681
- const t2 = value_2(t);
682
+ const t2 = t;
682
683
  if (t2 instanceof SetTreeNode$1) {
683
684
  const tn = t2;
684
685
  return some(SetTreeModule_minimumElementAux(SetTreeNode$1__get_Left(tn), SetTreeLeaf$1__get_Key(tn)));
@@ -695,7 +696,7 @@ export function SetTreeModule_maximumElementAux(t_mut, n_mut) {
695
696
  SetTreeModule_maximumElementAux: while (true) {
696
697
  const t = t_mut, n = n_mut;
697
698
  if (t != null) {
698
- const t2 = value_2(t);
699
+ const t2 = t;
699
700
  if (t2 instanceof SetTreeNode$1) {
700
701
  const tn = t2;
701
702
  t_mut = SetTreeNode$1__get_Right(tn);
@@ -714,7 +715,7 @@ export function SetTreeModule_maximumElementAux(t_mut, n_mut) {
714
715
  }
715
716
  export function SetTreeModule_maximumElementOpt(t) {
716
717
  if (t != null) {
717
- const t2 = value_2(t);
718
+ const t2 = t;
718
719
  if (t2 instanceof SetTreeNode$1) {
719
720
  const tn = t2;
720
721
  return some(SetTreeModule_maximumElementAux(SetTreeNode$1__get_Right(tn), SetTreeLeaf$1__get_Key(tn)));
@@ -730,7 +731,7 @@ export function SetTreeModule_maximumElementOpt(t) {
730
731
  export function SetTreeModule_minimumElement(s) {
731
732
  const matchValue = SetTreeModule_minimumElementOpt(s);
732
733
  if (matchValue == null) {
733
- throw new Exception("Set contains no elements");
734
+ throw Operators_InvalidArg("s", "Set contains no elements.");
734
735
  }
735
736
  else {
736
737
  return value_2(matchValue);
@@ -739,7 +740,7 @@ export function SetTreeModule_minimumElement(s) {
739
740
  export function SetTreeModule_maximumElement(s) {
740
741
  const matchValue = SetTreeModule_maximumElementOpt(s);
741
742
  if (matchValue == null) {
742
- throw new Exception("Set contains no elements");
743
+ throw Operators_InvalidArg("s", "Set contains no elements.");
743
744
  }
744
745
  else {
745
746
  return value_2(matchValue);
@@ -751,6 +752,12 @@ export class SetTreeModule_SetIterator$1 extends Record {
751
752
  this.stack = stack;
752
753
  this.started = started;
753
754
  }
755
+ Equals(other) {
756
+ return this === other;
757
+ }
758
+ GetHashCode() {
759
+ return physicalHash(this);
760
+ }
754
761
  }
755
762
  export function SetTreeModule_SetIterator$1_$reflection(gen0) {
756
763
  return record_type("Set.SetTreeModule.SetIterator`1", [gen0], SetTreeModule_SetIterator$1, () => [["stack", list_type(option_type(SetTreeLeaf$1_$reflection(gen0)))], ["started", bool_type]]);
@@ -762,7 +769,7 @@ export function SetTreeModule_collapseLHS(stack_mut) {
762
769
  const x = head(stack);
763
770
  const rest = tail(stack);
764
771
  if (x != null) {
765
- const x2 = value_2(x);
772
+ const x2 = x;
766
773
  if (x2 instanceof SetTreeNode$1) {
767
774
  const xn = x2;
768
775
  stack_mut = ofArrayWithTail([SetTreeNode$1__get_Left(xn), SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(xn)), SetTreeNode$1__get_Right(xn)], rest);
@@ -787,10 +794,10 @@ export function SetTreeModule_mkIterator(s) {
787
794
  return new SetTreeModule_SetIterator$1(SetTreeModule_collapseLHS(singleton_1(s)), false);
788
795
  }
789
796
  export function SetTreeModule_notStarted() {
790
- throw new Exception("Enumeration not started");
797
+ throw Operators_InvalidOp("Enumeration has not started. Call MoveNext.");
791
798
  }
792
799
  export function SetTreeModule_alreadyFinished() {
793
- throw new Exception("Enumeration already started");
800
+ throw Operators_InvalidOp("Enumeration already finished.");
794
801
  }
795
802
  export function SetTreeModule_current(i) {
796
803
  if (i.started) {
@@ -799,7 +806,7 @@ export function SetTreeModule_current(i) {
799
806
  return SetTreeModule_alreadyFinished();
800
807
  }
801
808
  else if (head(matchValue) != null) {
802
- const t = value_2(head(matchValue));
809
+ const t = head(matchValue);
803
810
  return SetTreeLeaf$1__get_Key(t);
804
811
  }
805
812
  else {
@@ -815,7 +822,7 @@ export function SetTreeModule_moveNext(i) {
815
822
  const matchValue = i.stack;
816
823
  if (!isEmpty_1(matchValue)) {
817
824
  if (head(matchValue) != null) {
818
- const t = value_2(head(matchValue));
825
+ const t = head(matchValue);
819
826
  if (t instanceof SetTreeNode$1) {
820
827
  throw new Exception("Please report error: Set iterator, unexpected stack for moveNext");
821
828
  }
@@ -866,8 +873,8 @@ export function SetTreeModule_compareStacks(comparer_mut, l1_mut, l2_mut) {
866
873
  if (!isEmpty_1(l2)) {
867
874
  if (head(l2) != null) {
868
875
  if (head(l1) != null) {
869
- const x1_3 = value_2(head(l1));
870
- const x2_3 = value_2(head(l2));
876
+ const x1_3 = head(l1);
877
+ const x2_3 = head(l2);
871
878
  if (x1_3 instanceof SetTreeNode$1) {
872
879
  const x1n_2 = x1_3;
873
880
  if (SetTreeNode$1__get_Left(x1n_2) == null) {
@@ -891,13 +898,13 @@ export function SetTreeModule_compareStacks(comparer_mut, l1_mut, l2_mut) {
891
898
  if (head(l1) != null) {
892
899
  matchResult = 0;
893
900
  t1_6 = tail(l1);
894
- x1_4 = value_2(head(l1));
901
+ x1_4 = head(l1);
895
902
  }
896
903
  else if (!isEmpty_1(l2)) {
897
904
  if (head(l2) != null) {
898
905
  matchResult = 1;
899
906
  t2_6 = tail(l2);
900
- x2_4 = value_2(head(l2));
907
+ x2_4 = head(l2);
901
908
  }
902
909
  else {
903
910
  matchResult = 2;
@@ -911,7 +918,7 @@ export function SetTreeModule_compareStacks(comparer_mut, l1_mut, l2_mut) {
911
918
  if (head(l2) != null) {
912
919
  matchResult = 1;
913
920
  t2_6 = tail(l2);
914
- x2_4 = value_2(head(l2));
921
+ x2_4 = head(l2);
915
922
  }
916
923
  else {
917
924
  matchResult = 2;
@@ -973,13 +980,13 @@ export function SetTreeModule_compareStacks(comparer_mut, l1_mut, l2_mut) {
973
980
  if (head(l1) != null) {
974
981
  matchResult_1 = 0;
975
982
  t1_7 = tail(l1);
976
- x1_5 = value_2(head(l1));
983
+ x1_5 = head(l1);
977
984
  }
978
985
  else if (!isEmpty_1(l2)) {
979
986
  if (head(l2) != null) {
980
987
  matchResult_1 = 1;
981
988
  t2_7 = tail(l2);
982
- x2_5 = value_2(head(l2));
989
+ x2_5 = head(l2);
983
990
  }
984
991
  else {
985
992
  matchResult_1 = 2;
@@ -993,7 +1000,7 @@ export function SetTreeModule_compareStacks(comparer_mut, l1_mut, l2_mut) {
993
1000
  if (head(l2) != null) {
994
1001
  matchResult_1 = 1;
995
1002
  t2_7 = tail(l2);
996
- x2_5 = value_2(head(l2));
1003
+ x2_5 = head(l2);
997
1004
  }
998
1005
  else {
999
1006
  matchResult_1 = 2;
@@ -1056,13 +1063,13 @@ export function SetTreeModule_compareStacks(comparer_mut, l1_mut, l2_mut) {
1056
1063
  if (head(l1) != null) {
1057
1064
  matchResult_2 = 0;
1058
1065
  t1_8 = tail(l1);
1059
- x1_6 = value_2(head(l1));
1066
+ x1_6 = head(l1);
1060
1067
  }
1061
1068
  else if (!isEmpty_1(l2)) {
1062
1069
  if (head(l2) != null) {
1063
1070
  matchResult_2 = 1;
1064
1071
  t2_8 = tail(l2);
1065
- x2_6 = value_2(head(l2));
1072
+ x2_6 = head(l2);
1066
1073
  }
1067
1074
  else {
1068
1075
  matchResult_2 = 2;
@@ -1076,7 +1083,7 @@ export function SetTreeModule_compareStacks(comparer_mut, l1_mut, l2_mut) {
1076
1083
  if (head(l2) != null) {
1077
1084
  matchResult_2 = 1;
1078
1085
  t2_8 = tail(l2);
1079
- x2_6 = value_2(head(l2));
1086
+ x2_6 = head(l2);
1080
1087
  }
1081
1088
  else {
1082
1089
  matchResult_2 = 2;
@@ -1133,19 +1140,19 @@ export function SetTreeModule_compareStacks(comparer_mut, l1_mut, l2_mut) {
1133
1140
  }
1134
1141
  }
1135
1142
  else {
1136
- const x2 = value_2(head(l2));
1143
+ const x2 = head(l2);
1137
1144
  let matchResult_3 = undefined, t1_2 = undefined, x1 = undefined, t2_2 = undefined, x2_1 = undefined;
1138
1145
  if (!isEmpty_1(l1)) {
1139
1146
  if (head(l1) != null) {
1140
1147
  matchResult_3 = 0;
1141
1148
  t1_2 = tail(l1);
1142
- x1 = value_2(head(l1));
1149
+ x1 = head(l1);
1143
1150
  }
1144
1151
  else if (!isEmpty_1(l2)) {
1145
1152
  if (head(l2) != null) {
1146
1153
  matchResult_3 = 1;
1147
1154
  t2_2 = tail(l2);
1148
- x2_1 = value_2(head(l2));
1155
+ x2_1 = head(l2);
1149
1156
  }
1150
1157
  else {
1151
1158
  matchResult_3 = 2;
@@ -1159,7 +1166,7 @@ export function SetTreeModule_compareStacks(comparer_mut, l1_mut, l2_mut) {
1159
1166
  if (head(l2) != null) {
1160
1167
  matchResult_3 = 1;
1161
1168
  t2_2 = tail(l2);
1162
- x2_1 = value_2(head(l2));
1169
+ x2_1 = head(l2);
1163
1170
  }
1164
1171
  else {
1165
1172
  matchResult_3 = 2;
@@ -1203,19 +1210,19 @@ export function SetTreeModule_compareStacks(comparer_mut, l1_mut, l2_mut) {
1203
1210
  }
1204
1211
  }
1205
1212
  else if (head(l1) != null) {
1206
- const x1_1 = value_2(head(l1));
1213
+ const x1_1 = head(l1);
1207
1214
  let matchResult_4 = undefined, t1_4 = undefined, x1_2 = undefined, t2_4 = undefined, x2_2 = undefined;
1208
1215
  if (!isEmpty_1(l1)) {
1209
1216
  if (head(l1) != null) {
1210
1217
  matchResult_4 = 0;
1211
1218
  t1_4 = tail(l1);
1212
- x1_2 = value_2(head(l1));
1219
+ x1_2 = head(l1);
1213
1220
  }
1214
1221
  else if (!isEmpty_1(l2)) {
1215
1222
  if (head(l2) != null) {
1216
1223
  matchResult_4 = 1;
1217
1224
  t2_4 = tail(l2);
1218
- x2_2 = value_2(head(l2));
1225
+ x2_2 = head(l2);
1219
1226
  }
1220
1227
  else {
1221
1228
  matchResult_4 = 2;
@@ -1229,7 +1236,7 @@ export function SetTreeModule_compareStacks(comparer_mut, l1_mut, l2_mut) {
1229
1236
  if (head(l2) != null) {
1230
1237
  matchResult_4 = 1;
1231
1238
  t2_4 = tail(l2);
1232
- x2_2 = value_2(head(l2));
1239
+ x2_2 = head(l2);
1233
1240
  }
1234
1241
  else {
1235
1242
  matchResult_4 = 2;
@@ -1315,7 +1322,7 @@ export function SetTreeModule_toList(t) {
1315
1322
  loop: while (true) {
1316
1323
  const t$0027 = t$0027_mut, acc = acc_mut;
1317
1324
  if (t$0027 != null) {
1318
- const t2 = value_2(t$0027);
1325
+ const t2 = t$0027;
1319
1326
  if (t2 instanceof SetTreeNode$1) {
1320
1327
  const tn = t2;
1321
1328
  t$0027_mut = SetTreeNode$1__get_Left(tn);
package/String.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { toString as dateToString } from "./Date.js";
2
- import { compare as numericCompare, divide, isNumeric, isIntegral, multiply, toExponential, toFixed, toHex, toPrecision } from "./Numeric.js";
2
+ import { compare as numericCompare, divide, isNumeric, isIntegral, multiply, toExponential, toFixed, toHex, toPrecision, toRadix } from "./Numeric.js";
3
3
  import { escape } from "./RegExp.js";
4
4
  import { toString } from "./Types.js";
5
5
  import { Exception } from "./Util.js";
@@ -207,19 +207,16 @@ function formatReplacement(rep, flags, padLength, precision, format) {
207
207
  flags = flags || "";
208
208
  format = format || "";
209
209
  if (isNumeric(rep)) {
210
- if (format.toLowerCase() !== "x") {
211
- if (isLessThan(rep, 0)) {
212
- rep = multiply(rep, -1);
213
- sign = "-";
214
- }
215
- else {
216
- if (flags.indexOf(" ") >= 0) {
217
- sign = " ";
218
- }
219
- else if (flags.indexOf("+") >= 0) {
220
- sign = "+";
221
- }
222
- }
210
+ const radix = format === "x" || format === "X" ? 16 : format === "o" ? 8 : 10;
211
+ if (radix === 10 && isLessThan(rep, 0)) {
212
+ rep = multiply(rep, -1);
213
+ sign = "-";
214
+ }
215
+ else if (flags.indexOf(" ") >= 0) {
216
+ sign = " ";
217
+ }
218
+ else if (flags.indexOf("+") >= 0) {
219
+ sign = "+";
223
220
  }
224
221
  precision = precision == null ? null : parseInt(precision, 10);
225
222
  switch (format) {
@@ -237,10 +234,11 @@ function formatReplacement(rep, flags, padLength, precision, format) {
237
234
  rep = precision != null ? toExponential(rep, precision) : toExponential(rep);
238
235
  break;
239
236
  case "x":
240
- rep = toHex(rep);
237
+ case "o":
238
+ rep = toRadix(rep, radix);
241
239
  break;
242
240
  case "X":
243
- rep = toHex(rep).toUpperCase();
241
+ rep = toRadix(rep, radix).toUpperCase();
244
242
  break;
245
243
  default: // AOid
246
244
  rep = String(rep);
@@ -346,6 +344,53 @@ function splitIntAndDecimalPart(value) {
346
344
  function thousandSeparate(value) {
347
345
  return value.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
348
346
  }
347
+ function splitExponential(s) {
348
+ const eIdx = s.indexOf("e");
349
+ return [s.slice(0, eIdx).replace(".", ""), Number(s.slice(eIdx + 1))];
350
+ }
351
+ function shortestSingle(x) {
352
+ // 100 digits tell where a float32 lies between two candidates, and 9 digits always round-trip
353
+ const [digits, exponent] = splitExponential(x.toExponential(99));
354
+ for (let p = 1;; p++) {
355
+ const down = Number(digits.slice(0, p));
356
+ const rest = digits.slice(p);
357
+ const half = "5".padEnd(rest.length, "0");
358
+ const roundUp = rest > half || rest === half && down % 2 === 1;
359
+ for (const n of roundUp ? [down + 1, down] : [down, down + 1]) {
360
+ if (Math.fround(Number(n + "e" + (exponent - p + 1))) === x) {
361
+ return [String(n), exponent + String(n).length - p];
362
+ }
363
+ }
364
+ }
365
+ }
366
+ // .NET "G" and "R": fixed notation unless the exponent is below -4 or reaches the precision (17 for the shortest digits, 9 for a float32)
367
+ function formatGeneral(x, format, precision, isSingle = false) {
368
+ if (!Number.isFinite(x)) {
369
+ return String(x);
370
+ }
371
+ const sign = x < 0 || Object.is(x, -0) ? "-" : "";
372
+ x = Math.abs(x);
373
+ // R ignores the precision and G0 is G
374
+ const p = format === "r" || format === "R" ? 0 : precision ?? 0;
375
+ const [significand, exponent] = p > 0 ? splitExponential(x.toExponential(p - 1)) : isSingle ? shortestSingle(x) : splitExponential(x.toExponential());
376
+ const digits = trimEnd(significand, "0") || "0";
377
+ if (exponent < -4 || exponent >= (p > 0 ? p : isSingle ? 9 : 17)) {
378
+ const mantissa = digits.length > 1 ? digits[0] + "." + digits.slice(1) : digits;
379
+ const eChar = format === "G" || format === "R" ? "E" : "e";
380
+ return sign + mantissa + eChar + (exponent < 0 ? "-" : "+") + padLeft(String(Math.abs(exponent)), 2, "0");
381
+ }
382
+ else if (exponent < 0) {
383
+ return sign + "0." + "0".repeat(-exponent - 1) + digits;
384
+ }
385
+ else {
386
+ const decimals = digits.slice(exponent + 1);
387
+ return sign + digits.slice(0, exponent + 1).padEnd(exponent + 1, "0") + (decimals ? "." + decimals : "");
388
+ }
389
+ }
390
+ export function formatSingle(str, x) {
391
+ const m = /^\{0:([GgRr])(\d{0,2})\}$/.exec(str);
392
+ return m != null ? formatGeneral(Math.fround(x), m[1], m[2] ? parseInt(m[2], 10) : null, true) : format(str, x);
393
+ }
349
394
  export function format(str, ...args) {
350
395
  let str2;
351
396
  if (typeof str === "object") {
@@ -425,12 +470,18 @@ export function format(str, ...args) {
425
470
  }
426
471
  break;
427
472
  case "g":
428
- case "G": {
429
- if (precision == null && typeof rep !== "number" && typeof rep !== "bigint") {
473
+ case "G":
474
+ case "r":
475
+ case "R": {
476
+ if (typeof rep === "number") {
477
+ rep = formatGeneral(rep, format, precision);
478
+ break;
479
+ }
480
+ if (precision == null) {
430
481
  rep = String(rep);
431
482
  break;
432
483
  }
433
- rep = precision != null ? toPrecision(rep, precision) : toPrecision(rep);
484
+ rep = toPrecision(rep, precision);
434
485
  // Handle exponential notation: only trim trailing zeros from mantissa, not from exponent.
435
486
  // .NET G format guarantees an exponent of at least 2 digits with an explicit sign (e.g. "E-07").
436
487
  const eIdx = rep.indexOf("e");
@@ -439,7 +490,7 @@ export function format(str, ...args) {
439
490
  const expSign = rep[eIdx + 1]; // toPrecision always emits "+" or "-"
440
491
  const expDigits = rep.slice(eIdx + 2);
441
492
  const paddedExpDigits = expDigits.length < 2 ? "0" + expDigits : expDigits;
442
- const eChar = format === "G" ? "E" : "e";
493
+ const eChar = format === "G" || format === "R" ? "E" : "e";
443
494
  rep = mantissa + eChar + expSign + paddedExpDigits;
444
495
  }
445
496
  else if (rep.indexOf(".") >= 0) {
@@ -471,9 +522,6 @@ export function format(str, ...args) {
471
522
  rep = thousandSeparate(parts.integral) + " %";
472
523
  }
473
524
  break;
474
- case "r":
475
- case "R":
476
- throw new Exception("The round-trip format is not supported by Fable");
477
525
  case "x":
478
526
  case "X":
479
527
  if (!isIntegral(rep)) {
@@ -5,6 +5,7 @@ import { toArray, empty, singleton, append, enumerateWhile, delay } from "./Seq.
5
5
  import { setItem, initialize, copyTo, fill, item as item_1 } from "./Array.js";
6
6
  import { max } from "./Double.js";
7
7
  import { ArgumentOutOfRangeException_$ctor_Z721C83C5 } from "./System.js";
8
+ import { Operators_InvalidOp } from "./FSharp.Core.js";
8
9
  export class KeyNotFoundException extends Exception {
9
10
  constructor(message) {
10
11
  super(message);
@@ -231,7 +232,7 @@ export function Queue$1__Enqueue_2B595(_, value) {
231
232
  }
232
233
  export function Queue$1__Dequeue(_) {
233
234
  if (_.count === 0) {
234
- throw new Exception("Queue is empty");
235
+ throw Operators_InvalidOp("Queue is empty");
235
236
  }
236
237
  const value = item_1(_.head, _.contents);
237
238
  _.head = (((_.head + 1) % Queue$1__size(_)) | 0);
@@ -240,7 +241,7 @@ export function Queue$1__Dequeue(_) {
240
241
  }
241
242
  export function Queue$1__Peek(_) {
242
243
  if (_.count === 0) {
243
- throw new Exception("Queue is empty");
244
+ throw Operators_InvalidOp("Queue is empty");
244
245
  }
245
246
  return item_1(_.head, _.contents);
246
247
  }
package/System.Text.js CHANGED
@@ -1,4 +1,4 @@
1
- import { replace, format, replicate, substring, isNullOrEmpty, join } from "./String.js";
1
+ import { replace, getCharAtIndex, format, replicate, substring, isNullOrEmpty, join } from "./String.js";
2
2
  import { class_type } from "./Reflection.js";
3
3
  import { toString } from "./Types.js";
4
4
  import { Exception, clear, int64ToString, int32ToString, int16ToString } from "./Util.js";
@@ -160,7 +160,7 @@ export function StringBuilder__get_Chars_Z524259A4(x, index) {
160
160
  }
161
161
  else {
162
162
  const pos = (index - len) | 0;
163
- return item(i, x.buf)[pos];
163
+ return getCharAtIndex(item(i, x.buf), pos);
164
164
  }
165
165
  }
166
166
  export function StringBuilder__set_Chars_413E0D0A(x, index, value) {