compostjs 0.0.11 → 0.0.12

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.
Files changed (141) hide show
  1. package/dist/fable_modules/fable-library-js.4.28.0/Array.d.ts +123 -0
  2. package/dist/fable_modules/fable-library-js.4.28.0/Array.js +1242 -0
  3. package/dist/fable_modules/fable-library-js.4.28.0/Async.d.ts +26 -0
  4. package/dist/fable_modules/fable-library-js.4.28.0/Async.js +145 -0
  5. package/dist/fable_modules/fable-library-js.4.28.0/AsyncBuilder.d.ts +59 -0
  6. package/dist/fable_modules/fable-library-js.4.28.0/AsyncBuilder.js +183 -0
  7. package/dist/fable_modules/fable-library-js.4.28.0/BigInt.d.ts +115 -0
  8. package/dist/fable_modules/fable-library-js.4.28.0/BigInt.js +283 -0
  9. package/dist/fable_modules/fable-library-js.4.28.0/BitConverter.d.ts +27 -0
  10. package/dist/fable_modules/fable-library-js.4.28.0/BitConverter.js +138 -0
  11. package/dist/fable_modules/fable-library-js.4.28.0/Boolean.d.ts +3 -0
  12. package/dist/fable_modules/fable-library-js.4.28.0/Boolean.js +21 -0
  13. package/dist/fable_modules/fable-library-js.4.28.0/CHANGELOG.md +100 -0
  14. package/dist/fable_modules/fable-library-js.4.28.0/Char.d.ts +65 -0
  15. package/dist/fable_modules/fable-library-js.4.28.0/Char.js +169 -0
  16. package/dist/fable_modules/fable-library-js.4.28.0/Choice.d.ts +121 -0
  17. package/dist/fable_modules/fable-library-js.4.28.0/Choice.js +184 -0
  18. package/dist/fable_modules/fable-library-js.4.28.0/CollectionUtil.d.ts +7 -0
  19. package/dist/fable_modules/fable-library-js.4.28.0/CollectionUtil.js +182 -0
  20. package/dist/fable_modules/fable-library-js.4.28.0/ConditionalWeakTable.d.ts +9 -0
  21. package/dist/fable_modules/fable-library-js.4.28.0/ConditionalWeakTable.js +21 -0
  22. package/dist/fable_modules/fable-library-js.4.28.0/Date.d.ts +70 -0
  23. package/dist/fable_modules/fable-library-js.4.28.0/Date.js +748 -0
  24. package/dist/fable_modules/fable-library-js.4.28.0/DateOffset.d.ts +63 -0
  25. package/dist/fable_modules/fable-library-js.4.28.0/DateOffset.js +268 -0
  26. package/dist/fable_modules/fable-library-js.4.28.0/DateOnly.d.ts +18 -0
  27. package/dist/fable_modules/fable-library-js.4.28.0/DateOnly.js +124 -0
  28. package/dist/fable_modules/fable-library-js.4.28.0/Decimal.d.ts +45 -0
  29. package/dist/fable_modules/fable-library-js.4.28.0/Decimal.js +212 -0
  30. package/dist/fable_modules/fable-library-js.4.28.0/Double.d.ts +11 -0
  31. package/dist/fable_modules/fable-library-js.4.28.0/Double.js +46 -0
  32. package/dist/fable_modules/fable-library-js.4.28.0/Encoding.d.ts +12 -0
  33. package/dist/fable_modules/fable-library-js.4.28.0/Encoding.js +173 -0
  34. package/dist/fable_modules/fable-library-js.4.28.0/Event.d.ts +31 -0
  35. package/dist/fable_modules/fable-library-js.4.28.0/Event.js +93 -0
  36. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Collections.d.ts +7 -0
  37. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Collections.js +27 -0
  38. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.CompilerServices.d.ts +12 -0
  39. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.CompilerServices.js +27 -0
  40. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.d.ts +17 -0
  41. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.js +69 -0
  42. package/dist/fable_modules/fable-library-js.4.28.0/Global.d.ts +24 -0
  43. package/dist/fable_modules/fable-library-js.4.28.0/Global.js +8 -0
  44. package/dist/fable_modules/fable-library-js.4.28.0/Guid.d.ts +10 -0
  45. package/dist/fable_modules/fable-library-js.4.28.0/Guid.js +142 -0
  46. package/dist/fable_modules/fable-library-js.4.28.0/Int32.d.ts +28 -0
  47. package/dist/fable_modules/fable-library-js.4.28.0/Int32.js +135 -0
  48. package/dist/fable_modules/fable-library-js.4.28.0/List.d.ts +143 -0
  49. package/dist/fable_modules/fable-library-js.4.28.0/List.js +1273 -0
  50. package/dist/fable_modules/fable-library-js.4.28.0/Long.d.ts +3 -0
  51. package/dist/fable_modules/fable-library-js.4.28.0/Long.js +46 -0
  52. package/dist/fable_modules/fable-library-js.4.28.0/MailboxProcessor.d.ts +25 -0
  53. package/dist/fable_modules/fable-library-js.4.28.0/MailboxProcessor.js +93 -0
  54. package/dist/fable_modules/fable-library-js.4.28.0/Map.d.ts +178 -0
  55. package/dist/fable_modules/fable-library-js.4.28.0/Map.js +1396 -0
  56. package/dist/fable_modules/fable-library-js.4.28.0/MapUtil.d.ts +12 -0
  57. package/dist/fable_modules/fable-library-js.4.28.0/MapUtil.js +127 -0
  58. package/dist/fable_modules/fable-library-js.4.28.0/MutableMap.d.ts +52 -0
  59. package/dist/fable_modules/fable-library-js.4.28.0/MutableMap.js +327 -0
  60. package/dist/fable_modules/fable-library-js.4.28.0/MutableSet.d.ts +39 -0
  61. package/dist/fable_modules/fable-library-js.4.28.0/MutableSet.js +233 -0
  62. package/dist/fable_modules/fable-library-js.4.28.0/Native.d.ts +2 -0
  63. package/dist/fable_modules/fable-library-js.4.28.0/Native.js +8 -0
  64. package/dist/fable_modules/fable-library-js.4.28.0/Numeric.d.ts +19 -0
  65. package/dist/fable_modules/fable-library-js.4.28.0/Numeric.js +71 -0
  66. package/dist/fable_modules/fable-library-js.4.28.0/Observable.d.ts +32 -0
  67. package/dist/fable_modules/fable-library-js.4.28.0/Observable.js +113 -0
  68. package/dist/fable_modules/fable-library-js.4.28.0/Option.d.ts +28 -0
  69. package/dist/fable_modules/fable-library-js.4.28.0/Option.js +96 -0
  70. package/dist/fable_modules/fable-library-js.4.28.0/README.md +3 -0
  71. package/dist/fable_modules/fable-library-js.4.28.0/Random.d.ts +37 -0
  72. package/dist/fable_modules/fable-library-js.4.28.0/Random.js +170 -0
  73. package/dist/fable_modules/fable-library-js.4.28.0/Range.d.ts +12 -0
  74. package/dist/fable_modules/fable-library-js.4.28.0/Range.js +45 -0
  75. package/dist/fable_modules/fable-library-js.4.28.0/Reflection.d.ts +119 -0
  76. package/dist/fable_modules/fable-library-js.4.28.0/Reflection.js +461 -0
  77. package/dist/fable_modules/fable-library-js.4.28.0/RegExp.d.ts +10 -0
  78. package/dist/fable_modules/fable-library-js.4.28.0/RegExp.js +131 -0
  79. package/dist/fable_modules/fable-library-js.4.28.0/Result.d.ts +37 -0
  80. package/dist/fable_modules/fable-library-js.4.28.0/Result.js +165 -0
  81. package/dist/fable_modules/fable-library-js.4.28.0/Seq.d.ts +165 -0
  82. package/dist/fable_modules/fable-library-js.4.28.0/Seq.js +1378 -0
  83. package/dist/fable_modules/fable-library-js.4.28.0/Seq2.d.ts +18 -0
  84. package/dist/fable_modules/fable-library-js.4.28.0/Seq2.js +111 -0
  85. package/dist/fable_modules/fable-library-js.4.28.0/Set.d.ts +190 -0
  86. package/dist/fable_modules/fable-library-js.4.28.0/Set.js +1789 -0
  87. package/dist/fable_modules/fable-library-js.4.28.0/String.d.ts +58 -0
  88. package/dist/fable_modules/fable-library-js.4.28.0/String.js +554 -0
  89. package/dist/fable_modules/fable-library-js.4.28.0/System.Collections.Generic.d.ts +79 -0
  90. package/dist/fable_modules/fable-library-js.4.28.0/System.Collections.Generic.js +317 -0
  91. package/dist/fable_modules/fable-library-js.4.28.0/System.Text.d.ts +38 -0
  92. package/dist/fable_modules/fable-library-js.4.28.0/System.Text.js +162 -0
  93. package/dist/fable_modules/fable-library-js.4.28.0/SystemException.d.ts +5 -0
  94. package/dist/fable_modules/fable-library-js.4.28.0/SystemException.js +5 -0
  95. package/dist/fable_modules/fable-library-js.4.28.0/TimeOnly.d.ts +15 -0
  96. package/dist/fable_modules/fable-library-js.4.28.0/TimeOnly.js +122 -0
  97. package/dist/fable_modules/fable-library-js.4.28.0/TimeSpan.d.ts +34 -0
  98. package/dist/fable_modules/fable-library-js.4.28.0/TimeSpan.js +177 -0
  99. package/dist/fable_modules/fable-library-js.4.28.0/Timer.d.ts +19 -0
  100. package/dist/fable_modules/fable-library-js.4.28.0/Timer.js +67 -0
  101. package/dist/fable_modules/fable-library-js.4.28.0/Types.d.ts +58 -0
  102. package/dist/fable_modules/fable-library-js.4.28.0/Types.js +208 -0
  103. package/dist/fable_modules/fable-library-js.4.28.0/Unicode.13.0.0.d.ts +2 -0
  104. package/dist/fable_modules/fable-library-js.4.28.0/Unicode.13.0.0.js +4 -0
  105. package/dist/fable_modules/fable-library-js.4.28.0/Uri.d.ts +31 -0
  106. package/dist/fable_modules/fable-library-js.4.28.0/Uri.js +159 -0
  107. package/dist/fable_modules/fable-library-js.4.28.0/Util.d.ts +210 -0
  108. package/dist/fable_modules/fable-library-js.4.28.0/Util.js +769 -0
  109. package/dist/fable_modules/fable-library-js.4.28.0/big.d.ts +338 -0
  110. package/dist/fable_modules/fable-library-js.4.28.0/lib/big.d.ts +5 -0
  111. package/dist/fable_modules/fable-library-js.4.28.0/lib/big.js +825 -0
  112. package/dist/fable_modules/fable-library-js.4.28.0/package.json +24 -0
  113. package/dist/fable_modules/project_cracked.json +1 -0
  114. package/package.json +4 -3
  115. package/.claude/settings.local.json +0 -11
  116. package/copy-latest.sh +0 -1
  117. package/dist/fable-library.2.10.1/Array.js +0 -1336
  118. package/dist/fable-library.2.10.1/Async.js +0 -121
  119. package/dist/fable-library.2.10.1/AsyncBuilder.js +0 -200
  120. package/dist/fable-library.2.10.1/Date.js +0 -501
  121. package/dist/fable-library.2.10.1/Decimal.js +0 -208
  122. package/dist/fable-library.2.10.1/Event.js +0 -193
  123. package/dist/fable-library.2.10.1/Int32.js +0 -157
  124. package/dist/fable-library.2.10.1/List.js +0 -1234
  125. package/dist/fable-library.2.10.1/Long.js +0 -155
  126. package/dist/fable-library.2.10.1/Map.js +0 -1292
  127. package/dist/fable-library.2.10.1/MutableMap.js +0 -360
  128. package/dist/fable-library.2.10.1/MutableSet.js +0 -279
  129. package/dist/fable-library.2.10.1/Observable.js +0 -131
  130. package/dist/fable-library.2.10.1/Option.js +0 -118
  131. package/dist/fable-library.2.10.1/Reflection.js +0 -345
  132. package/dist/fable-library.2.10.1/RegExp.js +0 -118
  133. package/dist/fable-library.2.10.1/Seq.js +0 -917
  134. package/dist/fable-library.2.10.1/Set.js +0 -1692
  135. package/dist/fable-library.2.10.1/String.js +0 -679
  136. package/dist/fable-library.2.10.1/Types.js +0 -308
  137. package/dist/fable-library.2.10.1/Util.js +0 -761
  138. package/dist/helpers.js +0 -31
  139. package/dist/lib/big.js +0 -905
  140. package/dist/lib/long.js +0 -1375
  141. package/index.html +0 -49
@@ -1,1336 +0,0 @@
1
- import { defaultArg, value as value$$15, some } from "./Option";
2
- import { min as min$$1, compare, addToDict, addToSet, getItemFromDict, tryGetValue, max as max$$1, comparePrimitives } from "./Util";
3
- import { createMutable } from "./Map";
4
- import { createMutable as createMutable$$1 } from "./Set";
5
- import { List } from "./Types";
6
- import { iterate as iterate$$1 } from "./Seq";
7
- const indexNotFoundMsg = "An index satisfying the predicate was not found in the collection.";
8
- export function append(array1, array2, cons) {
9
- if (ArrayBuffer.isView(array1)) {
10
- const len1 = array1.length | 0;
11
- const len2 = array2.length | 0;
12
- const newArray = new cons(len1 + len2);
13
-
14
- for (let i = 0; i <= len1 - 1; i++) {
15
- newArray[i] = array1[i];
16
- }
17
-
18
- for (let i$$1 = 0; i$$1 <= len2 - 1; i$$1++) {
19
- newArray[i$$1 + len1] = array2[i$$1];
20
- }
21
-
22
- return newArray;
23
- } else {
24
- return array1.concat(array2);
25
- }
26
- }
27
- export function filter(predicate, array) {
28
- return array.filter(predicate);
29
- }
30
- export function fill(target, targetIndex, count, value) {
31
- target.fill(value, targetIndex, targetIndex + count);
32
- return target;
33
- }
34
- export function getSubArray(array$$3, start$$1, count$$2) {
35
- return array$$3.slice(start$$1, start$$1 + count$$2);
36
- }
37
- export function last(array$$5) {
38
- if (array$$5.length === 0) {
39
- throw new Error("The input array was empty\\nParameter name: array");
40
- } else {
41
- void null;
42
- }
43
-
44
- return array$$5[array$$5.length - 1];
45
- }
46
- export function tryLast(array$$6) {
47
- if (array$$6.length === 0) {
48
- return undefined;
49
- } else {
50
- return some(array$$6[array$$6.length - 1]);
51
- }
52
- }
53
- export function mapIndexed(f, source, cons$$1) {
54
- if (ArrayBuffer.isView(source)) {
55
- const len = source.length | 0;
56
- const target$$1 = new cons$$1(len);
57
-
58
- for (let i$$2 = 0; i$$2 <= len - 1; i$$2++) {
59
- target$$1[i$$2] = f(i$$2, source[i$$2]);
60
- }
61
-
62
- return target$$1;
63
- } else {
64
- return source.map(function (delegateArg0, delegateArg1) {
65
- return f(delegateArg1, delegateArg0);
66
- });
67
- }
68
- }
69
- export function map(f$$1, source$$1, cons$$2) {
70
- if (ArrayBuffer.isView(source$$1)) {
71
- const len$$1 = source$$1.length | 0;
72
- const target$$2 = new cons$$2(len$$1);
73
-
74
- for (let i$$4 = 0; i$$4 <= len$$1 - 1; i$$4++) {
75
- target$$2[i$$4] = f$$1(source$$1[i$$4]);
76
- }
77
-
78
- return target$$2;
79
- } else {
80
- return source$$1.map(function mapping$$1(x$$1) {
81
- return f$$1(x$$1);
82
- });
83
- }
84
- }
85
- export function mapIndexed2(f$$2, source1, source2, cons$$3) {
86
- if (source1.length !== source2.length) {
87
- throw new Error("Arrays had different lengths");
88
- } else {
89
- void null;
90
- }
91
-
92
- const result = new cons$$3(source1.length);
93
-
94
- for (let i$$5 = 0; i$$5 <= source1.length - 1; i$$5++) {
95
- result[i$$5] = f$$2(i$$5, source1[i$$5], source2[i$$5]);
96
- }
97
-
98
- return result;
99
- }
100
- export function map2(f$$3, source1$$1, source2$$1, cons$$4) {
101
- if (source1$$1.length !== source2$$1.length) {
102
- throw new Error("Arrays had different lengths");
103
- } else {
104
- void null;
105
- }
106
-
107
- const result$$1 = new cons$$4(source1$$1.length);
108
-
109
- for (let i$$6 = 0; i$$6 <= source1$$1.length - 1; i$$6++) {
110
- result$$1[i$$6] = f$$3(source1$$1[i$$6], source2$$1[i$$6]);
111
- }
112
-
113
- return result$$1;
114
- }
115
- export function mapIndexed3(f$$4, source1$$2, source2$$2, source3, cons$$5) {
116
- if (source1$$2.length !== source2$$2.length ? true : source2$$2.length !== source3.length) {
117
- throw new Error("Arrays had different lengths");
118
- } else {
119
- void null;
120
- }
121
-
122
- const result$$2 = new cons$$5(source1$$2.length);
123
-
124
- for (let i$$7 = 0; i$$7 <= source1$$2.length - 1; i$$7++) {
125
- result$$2[i$$7] = f$$4(i$$7, source1$$2[i$$7], source2$$2[i$$7], source3[i$$7]);
126
- }
127
-
128
- return result$$2;
129
- }
130
- export function map3(f$$5, source1$$3, source2$$3, source3$$1, cons$$6) {
131
- if (source1$$3.length !== source2$$3.length ? true : source2$$3.length !== source3$$1.length) {
132
- throw new Error("Arrays had different lengths");
133
- } else {
134
- void null;
135
- }
136
-
137
- const result$$3 = new cons$$6(source1$$3.length);
138
-
139
- for (let i$$8 = 0; i$$8 <= source1$$3.length - 1; i$$8++) {
140
- result$$3[i$$8] = f$$5(source1$$3[i$$8], source2$$3[i$$8], source3$$1[i$$8]);
141
- }
142
-
143
- return result$$3;
144
- }
145
- export function mapFold(mapping$$2, state, array$$9, cons$$7) {
146
- const matchValue = array$$9.length | 0;
147
-
148
- if (matchValue === 0) {
149
- return [[], state];
150
- } else {
151
- let acc = state;
152
- const res = new cons$$7(matchValue);
153
-
154
- for (let i$$9 = 0; i$$9 <= array$$9.length - 1; i$$9++) {
155
- const patternInput = mapping$$2(acc, array$$9[i$$9]);
156
- res[i$$9] = patternInput[0];
157
- acc = patternInput[1];
158
- }
159
-
160
- return [res, acc];
161
- }
162
- }
163
- export function mapFoldBack(mapping$$3, array$$10, state$$1, cons$$8) {
164
- const matchValue$$1 = array$$10.length | 0;
165
-
166
- if (matchValue$$1 === 0) {
167
- return [[], state$$1];
168
- } else {
169
- let acc$$1 = state$$1;
170
- const res$$1 = new cons$$8(matchValue$$1);
171
-
172
- for (let i$$10 = array$$10.length - 1; i$$10 >= 0; i$$10--) {
173
- const patternInput$$1 = mapping$$3(array$$10[i$$10], acc$$1);
174
- res$$1[i$$10] = patternInput$$1[0];
175
- acc$$1 = patternInput$$1[1];
176
- }
177
-
178
- return [res$$1, acc$$1];
179
- }
180
- }
181
- export function indexed(source$$2) {
182
- const len$$4 = source$$2.length | 0;
183
- const target$$3 = new Array(len$$4);
184
-
185
- for (let i$$11 = 0; i$$11 <= len$$4 - 1; i$$11++) {
186
- target$$3[i$$11] = [i$$11, source$$2[i$$11]];
187
- }
188
-
189
- return target$$3;
190
- }
191
- export function truncate(count$$4, array$$11) {
192
- const count$$5 = max$$1(comparePrimitives, 0, count$$4) | 0;
193
- return array$$11.slice(0, 0 + count$$5);
194
- }
195
- export function concat(arrays, cons$$9) {
196
- var arr$$4;
197
- const arrays$$1 = Array.isArray(arrays) ? arrays : Array.from(arrays);
198
- const matchValue$$2 = arrays$$1.length | 0;
199
-
200
- switch (matchValue$$2) {
201
- case 0:
202
- {
203
- return new cons$$9(0);
204
- }
205
-
206
- case 1:
207
- {
208
- return arrays$$1[0];
209
- }
210
-
211
- default:
212
- {
213
- if (arr$$4 = arrays$$1[0], ArrayBuffer.isView(arr$$4)) {
214
- let totalIdx = 0;
215
- let totalLength = 0;
216
-
217
- for (let idx = 0; idx <= arrays$$1.length - 1; idx++) {
218
- const arr$$5 = arrays$$1[idx];
219
- totalLength = totalLength + arr$$5.length;
220
- }
221
-
222
- const result$$4 = new cons$$9(totalLength);
223
-
224
- for (let idx$$1 = 0; idx$$1 <= arrays$$1.length - 1; idx$$1++) {
225
- const arr$$6 = arrays$$1[idx$$1];
226
-
227
- for (let j = 0; j <= arr$$6.length - 1; j++) {
228
- result$$4[totalIdx] = arr$$6[j];
229
- totalIdx = totalIdx + 1;
230
- }
231
- }
232
-
233
- return result$$4;
234
- } else {
235
- return arrays$$1[0].concat(...arrays$$1.slice(1));
236
- }
237
- }
238
- }
239
- }
240
- export function collect(mapping$$4, array$$14, cons$$10) {
241
- const mapped = map(mapping$$4, array$$14, Array);
242
- return concat(mapped, cons$$10);
243
- }
244
- export function countBy(projection, array$$15, eq) {
245
- const dict = createMutable([], eq);
246
- const keys = [];
247
-
248
- for (let idx$$2 = 0; idx$$2 <= array$$15.length - 1; idx$$2++) {
249
- const value$$2 = array$$15[idx$$2];
250
- const key = projection(value$$2);
251
- const matchValue$$3 = tryGetValue(dict, key, 0);
252
-
253
- if (matchValue$$3[0]) {
254
- dict.set(key, matchValue$$3[1] + 1);
255
- } else {
256
- dict.set(key, 1);
257
- const value$$3 = keys.push(key);
258
- void value$$3;
259
- }
260
- }
261
-
262
- const result$$5 = map(function (key$$1) {
263
- return [key$$1, getItemFromDict(dict, key$$1)];
264
- }, keys, Array);
265
- return result$$5;
266
- }
267
- export function distinctBy(projection$$1, array$$17, eq$$1) {
268
- const hashSet = createMutable$$1([], eq$$1);
269
- return filter(function predicate$$2($arg$$3) {
270
- const arg00 = projection$$1($arg$$3);
271
- return addToSet(arg00, hashSet);
272
- }, array$$17);
273
- }
274
- export function distinct(array$$19, eq$$2) {
275
- return distinctBy(function (x$$2) {
276
- return x$$2;
277
- }, array$$19, eq$$2);
278
- }
279
- export function where(predicate$$3, array$$20) {
280
- return array$$20.filter(predicate$$3);
281
- }
282
- export function contains(value$$4, array$$22, eq$$3) {
283
- const loop = function loop($i$$12$$79) {
284
- loop: while (true) {
285
- const i$$12 = $i$$12$$79;
286
-
287
- if (i$$12 >= array$$22.length) {
288
- return false;
289
- } else if (eq$$3.Equals(value$$4, array$$22[i$$12])) {
290
- return true;
291
- } else {
292
- $i$$12$$79 = i$$12 + 1;
293
- continue loop;
294
- }
295
-
296
- break;
297
- }
298
- };
299
-
300
- return loop(0);
301
- }
302
- export function except(itemsToExclude, array$$23, eq$$4) {
303
- if (array$$23.length === 0) {
304
- return array$$23;
305
- } else {
306
- const cached = createMutable$$1(itemsToExclude, eq$$4);
307
- return array$$23.filter(function predicate$$5(arg00$$1) {
308
- return addToSet(arg00$$1, cached);
309
- });
310
- }
311
- }
312
- export function groupBy(projection$$2, array$$26, cons$$11, eq$$5) {
313
- const dict$$1 = createMutable([], eq$$5);
314
- const keys$$1 = [];
315
-
316
- for (let idx$$3 = 0; idx$$3 <= array$$26.length - 1; idx$$3++) {
317
- const v = array$$26[idx$$3];
318
- const key$$2 = projection$$2(v);
319
- const matchValue$$4 = tryGetValue(dict$$1, key$$2, null);
320
-
321
- if (matchValue$$4[0]) {
322
- dict$$1.set(key$$2, new List(v, matchValue$$4[1]));
323
- } else {
324
- addToDict(dict$$1, key$$2, new List(v, new List()));
325
- const value$$5 = keys$$1.push(key$$2);
326
- void value$$5;
327
- }
328
- }
329
-
330
- const result$$6 = map(function (key$$3) {
331
- var array$$28;
332
- return [key$$3, (array$$28 = cons$$11.from(getItemFromDict(dict$$1, key$$3)), array$$28.reverse())];
333
- }, keys$$1, Array);
334
- return result$$6;
335
- }
336
- export function empty(cons$$12) {
337
- return new cons$$12(0);
338
- }
339
- export function singleton(value$$6, cons$$14) {
340
- const ar = new cons$$14(1);
341
- ar[0] = value$$6;
342
- return ar;
343
- }
344
- export function initialize(count$$8, initializer, cons$$15) {
345
- if (count$$8 < 0) {
346
- throw new Error("The input must be non-negative\\nParameter name: count");
347
- } else {
348
- void null;
349
- }
350
-
351
- const result$$7 = new cons$$15(count$$8);
352
-
353
- for (let i$$13 = 0; i$$13 <= count$$8 - 1; i$$13++) {
354
- result$$7[i$$13] = initializer(i$$13);
355
- }
356
-
357
- return result$$7;
358
- }
359
- export function pairwise(array$$30) {
360
- if (array$$30.length < 2) {
361
- return [];
362
- } else {
363
- const count$$9 = array$$30.length - 1 | 0;
364
- const result$$8 = new Array(count$$9);
365
-
366
- for (let i$$14 = 0; i$$14 <= count$$9 - 1; i$$14++) {
367
- result$$8[i$$14] = [array$$30[i$$14], array$$30[i$$14 + 1]];
368
- }
369
-
370
- return result$$8;
371
- }
372
- }
373
- export function replicate(count$$10, initial, cons$$16) {
374
- if (count$$10 < 0) {
375
- throw new Error("The input must be non-negative\\nParameter name: count");
376
- } else {
377
- void null;
378
- }
379
-
380
- const result$$9 = new cons$$16(count$$10);
381
-
382
- for (let i$$15 = 0; i$$15 <= result$$9.length - 1; i$$15++) {
383
- result$$9[i$$15] = initial;
384
- }
385
-
386
- return result$$9;
387
- }
388
- export function copy(array$$31, cons$$17) {
389
- return array$$31.slice();
390
- }
391
- export function reverse(array$$33, cons$$18) {
392
- const array$$35 = array$$33.slice();
393
- return array$$35.reverse();
394
- }
395
- export function scan(folder, state$$2, array$$37, cons$$19) {
396
- const res$$2 = new cons$$19(array$$37.length + 1);
397
- res$$2[0] = state$$2;
398
-
399
- for (let i$$16 = 0; i$$16 <= array$$37.length - 1; i$$16++) {
400
- res$$2[i$$16 + 1] = folder(res$$2[i$$16], array$$37[i$$16]);
401
- }
402
-
403
- return res$$2;
404
- }
405
- export function scanBack(folder$$1, array$$38, state$$3, cons$$20) {
406
- const res$$3 = new cons$$20(array$$38.length + 1);
407
- res$$3[array$$38.length] = state$$3;
408
-
409
- for (let i$$17 = array$$38.length - 1; i$$17 >= 0; i$$17--) {
410
- res$$3[i$$17] = folder$$1(array$$38[i$$17], res$$3[i$$17 + 1]);
411
- }
412
-
413
- return res$$3;
414
- }
415
- export function skip(count$$11, array$$39, cons$$21) {
416
- if (count$$11 > array$$39.length) {
417
- throw new Error("count is greater than array length\\nParameter name: count");
418
- } else {
419
- void null;
420
- }
421
-
422
- if (count$$11 === array$$39.length) {
423
- return new cons$$21(0);
424
- } else {
425
- const count$$12 = (count$$11 < 0 ? 0 : count$$11) | 0;
426
- return array$$39.slice(count$$12);
427
- }
428
- }
429
- export function skipWhile(predicate$$7, array$$41, cons$$23) {
430
- let count$$14 = 0;
431
-
432
- while (count$$14 < array$$41.length ? predicate$$7(array$$41[count$$14]) : false) {
433
- count$$14 = count$$14 + 1;
434
- }
435
-
436
- if (count$$14 === array$$41.length) {
437
- return new cons$$23(0);
438
- } else {
439
- const count$$15 = count$$14 | 0;
440
- return array$$41.slice(count$$15);
441
- }
442
- }
443
- export function take(count$$16, array$$43, cons$$25) {
444
- if (count$$16 < 0) {
445
- throw new Error("The input must be non-negative\\nParameter name: count");
446
- } else {
447
- void null;
448
- }
449
-
450
- if (count$$16 > array$$43.length) {
451
- throw new Error("count is greater than array length\\nParameter name: count");
452
- } else {
453
- void null;
454
- }
455
-
456
- if (count$$16 === 0) {
457
- return new cons$$25(0);
458
- } else {
459
- return array$$43.slice(0, 0 + count$$16);
460
- }
461
- }
462
- export function takeWhile(predicate$$8, array$$45, cons$$27) {
463
- let count$$18 = 0;
464
-
465
- while (count$$18 < array$$45.length ? predicate$$8(array$$45[count$$18]) : false) {
466
- count$$18 = count$$18 + 1;
467
- }
468
-
469
- if (count$$18 === 0) {
470
- return new cons$$27(0);
471
- } else {
472
- const count$$19 = count$$18 | 0;
473
- return array$$45.slice(0, 0 + count$$19);
474
- }
475
- }
476
- export function addInPlace(x$$3, array$$47) {
477
- const value$$7 = array$$47.push(x$$3);
478
- void value$$7;
479
- }
480
- export function addRangeInPlace(range, array$$49) {
481
- iterate$$1(function (x$$4) {
482
- const value$$8 = array$$49.push(x$$4);
483
- void value$$8;
484
- }, range);
485
- }
486
- export function removeInPlace(item$$5, array$$51) {
487
- const i$$18 = array$$51.indexOf(item$$5);
488
-
489
- if (i$$18 > -1) {
490
- const value$$9 = array$$51.splice(i$$18, 1);
491
- void value$$9;
492
- return true;
493
- } else {
494
- return false;
495
- }
496
- }
497
- export function removeAllInPlace(predicate$$9, array$$54) {
498
- const countRemoveAll = function countRemoveAll(count$$20) {
499
- const i$$19 = array$$54.findIndex(predicate$$9);
500
-
501
- if (i$$19 > -1) {
502
- const value$$10 = array$$54.splice(i$$19, 1);
503
- void value$$10;
504
- return countRemoveAll(count$$20) + 1 | 0;
505
- } else {
506
- return count$$20 | 0;
507
- }
508
- };
509
-
510
- return countRemoveAll(0) | 0;
511
- }
512
- export function copyTo(source$$3, sourceIndex, target$$4, targetIndex$$1, count$$21) {
513
- const diff = targetIndex$$1 - sourceIndex | 0;
514
-
515
- for (let i$$20 = sourceIndex; i$$20 <= sourceIndex + count$$21 - 1; i$$20++) {
516
- target$$4[i$$20 + diff] = source$$3[i$$20];
517
- }
518
- }
519
- export function partition(f$$6, source$$4, cons$$29) {
520
- const len$$7 = source$$4.length | 0;
521
- const res1 = new cons$$29(len$$7);
522
- const res2 = new cons$$29(len$$7);
523
- let iTrue = 0;
524
- let iFalse = 0;
525
-
526
- for (let i$$21 = 0; i$$21 <= len$$7 - 1; i$$21++) {
527
- if (f$$6(source$$4[i$$21])) {
528
- res1[iTrue] = source$$4[i$$21];
529
- iTrue = iTrue + 1;
530
- } else {
531
- res2[iFalse] = source$$4[i$$21];
532
- iFalse = iFalse + 1;
533
- }
534
- }
535
-
536
- return [truncate(iTrue, res1), truncate(iFalse, res2)];
537
- }
538
- export function find(predicate$$11, array$$59) {
539
- const matchValue$$5 = array$$59.find(predicate$$11);
540
-
541
- if (matchValue$$5 == null) {
542
- throw new Error(indexNotFoundMsg);
543
- } else {
544
- const res$$4 = value$$15(matchValue$$5);
545
- return res$$4;
546
- }
547
- }
548
- export function tryFind(predicate$$13, array$$61) {
549
- return array$$61.find(predicate$$13);
550
- }
551
- export function findIndex(predicate$$15, array$$63) {
552
- const matchValue$$6 = array$$63.findIndex(predicate$$15);
553
-
554
- if (matchValue$$6 > -1) {
555
- return matchValue$$6 | 0;
556
- } else {
557
- throw new Error(indexNotFoundMsg);
558
- }
559
- }
560
- export function tryFindIndex(predicate$$17, array$$65) {
561
- const matchValue$$7 = array$$65.findIndex(predicate$$17);
562
-
563
- if (matchValue$$7 > -1) {
564
- return matchValue$$7;
565
- } else {
566
- return undefined;
567
- }
568
- }
569
- export function pick(chooser, array$$67) {
570
- const loop$$1 = function loop$$1($i$$22$$149) {
571
- loop$$1: while (true) {
572
- const i$$22 = $i$$22$$149;
573
-
574
- if (i$$22 >= array$$67.length) {
575
- throw new Error(indexNotFoundMsg);
576
- } else {
577
- const matchValue$$8 = chooser(array$$67[i$$22]);
578
-
579
- if (matchValue$$8 != null) {
580
- const res$$5 = value$$15(matchValue$$8);
581
- return res$$5;
582
- } else {
583
- $i$$22$$149 = i$$22 + 1;
584
- continue loop$$1;
585
- }
586
- }
587
-
588
- break;
589
- }
590
- };
591
-
592
- return loop$$1(0);
593
- }
594
- export function tryPick(chooser$$1, array$$68) {
595
- const loop$$2 = function loop$$2($i$$23$$152) {
596
- loop$$2: while (true) {
597
- const i$$23 = $i$$23$$152;
598
-
599
- if (i$$23 >= array$$68.length) {
600
- return undefined;
601
- } else {
602
- const matchValue$$9 = chooser$$1(array$$68[i$$23]);
603
-
604
- if (matchValue$$9 == null) {
605
- $i$$23$$152 = i$$23 + 1;
606
- continue loop$$2;
607
- } else {
608
- return matchValue$$9;
609
- }
610
- }
611
-
612
- break;
613
- }
614
- };
615
-
616
- return loop$$2(0);
617
- }
618
- export function findBack(predicate$$19, array$$69) {
619
- const loop$$3 = function loop$$3($i$$24$$155) {
620
- loop$$3: while (true) {
621
- const i$$24 = $i$$24$$155;
622
-
623
- if (i$$24 < 0) {
624
- throw new Error(indexNotFoundMsg);
625
- } else if (predicate$$19(array$$69[i$$24])) {
626
- return array$$69[i$$24];
627
- } else {
628
- $i$$24$$155 = i$$24 - 1;
629
- continue loop$$3;
630
- }
631
-
632
- break;
633
- }
634
- };
635
-
636
- return loop$$3(array$$69.length - 1);
637
- }
638
- export function tryFindBack(predicate$$20, array$$70) {
639
- const loop$$4 = function loop$$4($i$$25$$158) {
640
- loop$$4: while (true) {
641
- const i$$25 = $i$$25$$158;
642
-
643
- if (i$$25 < 0) {
644
- return undefined;
645
- } else if (predicate$$20(array$$70[i$$25])) {
646
- return some(array$$70[i$$25]);
647
- } else {
648
- $i$$25$$158 = i$$25 - 1;
649
- continue loop$$4;
650
- }
651
-
652
- break;
653
- }
654
- };
655
-
656
- return loop$$4(array$$70.length - 1);
657
- }
658
- export function findLastIndex(predicate$$21, array$$71) {
659
- const loop$$5 = function loop$$5($i$$26$$161) {
660
- loop$$5: while (true) {
661
- const i$$26 = $i$$26$$161;
662
-
663
- if (i$$26 < 0) {
664
- return -1 | 0;
665
- } else if (predicate$$21(array$$71[i$$26])) {
666
- return i$$26 | 0;
667
- } else {
668
- $i$$26$$161 = i$$26 - 1;
669
- continue loop$$5;
670
- }
671
-
672
- break;
673
- }
674
- };
675
-
676
- return loop$$5(array$$71.length - 1) | 0;
677
- }
678
- export function findIndexBack(predicate$$22, array$$72) {
679
- const loop$$6 = function loop$$6($i$$27$$164) {
680
- loop$$6: while (true) {
681
- const i$$27 = $i$$27$$164;
682
-
683
- if (i$$27 < 0) {
684
- throw new Error(indexNotFoundMsg);
685
- } else if (predicate$$22(array$$72[i$$27])) {
686
- return i$$27 | 0;
687
- } else {
688
- $i$$27$$164 = i$$27 - 1;
689
- continue loop$$6;
690
- }
691
-
692
- break;
693
- }
694
- };
695
-
696
- return loop$$6(array$$72.length - 1) | 0;
697
- }
698
- export function tryFindIndexBack(predicate$$23, array$$73) {
699
- const loop$$7 = function loop$$7($i$$28$$167) {
700
- loop$$7: while (true) {
701
- const i$$28 = $i$$28$$167;
702
-
703
- if (i$$28 < 0) {
704
- return undefined;
705
- } else if (predicate$$23(array$$73[i$$28])) {
706
- return i$$28;
707
- } else {
708
- $i$$28$$167 = i$$28 - 1;
709
- continue loop$$7;
710
- }
711
-
712
- break;
713
- }
714
- };
715
-
716
- return loop$$7(array$$73.length - 1);
717
- }
718
- export function choose(chooser$$2, array$$74, cons$$30) {
719
- const arr$$7 = array$$74.filter(function f$$7(x$$5) {
720
- const option = chooser$$2(x$$5);
721
- return option != null;
722
- });
723
- return map(function g(x$$6) {
724
- const option$$1 = chooser$$2(x$$6);
725
- return value$$15(option$$1);
726
- }, arr$$7, cons$$30);
727
- }
728
- export function foldIndexed(folder$$2, state$$4, array$$76) {
729
- return array$$76.reduce(function (delegateArg0$$1, delegateArg1$$1, delegateArg2) {
730
- return folder$$2(delegateArg2, delegateArg0$$1, delegateArg1$$1);
731
- }, state$$4);
732
- }
733
- export function fold(folder$$4, state$$6, array$$78) {
734
- return array$$78.reduce(function (delegateArg0$$2, delegateArg1$$2) {
735
- return folder$$4(delegateArg0$$2, delegateArg1$$2);
736
- }, state$$6);
737
- }
738
- export function iterate(action, array$$80) {
739
- for (let i$$30 = 0; i$$30 <= array$$80.length - 1; i$$30++) {
740
- action(array$$80[i$$30]);
741
- }
742
- }
743
- export function iterateIndexed(action$$1, array$$81) {
744
- for (let i$$31 = 0; i$$31 <= array$$81.length - 1; i$$31++) {
745
- action$$1(i$$31, array$$81[i$$31]);
746
- }
747
- }
748
- export function iterate2(action$$2, array1$$2, array2$$2) {
749
- if (array1$$2.length !== array2$$2.length) {
750
- throw new Error("Arrays had different lengths");
751
- } else {
752
- void null;
753
- }
754
-
755
- for (let i$$32 = 0; i$$32 <= array1$$2.length - 1; i$$32++) {
756
- action$$2(array1$$2[i$$32], array2$$2[i$$32]);
757
- }
758
- }
759
- export function iterateIndexed2(action$$3, array1$$3, array2$$3) {
760
- if (array1$$3.length !== array2$$3.length) {
761
- throw new Error("Arrays had different lengths");
762
- } else {
763
- void null;
764
- }
765
-
766
- for (let i$$33 = 0; i$$33 <= array1$$3.length - 1; i$$33++) {
767
- action$$3(i$$33, array1$$3[i$$33], array2$$3[i$$33]);
768
- }
769
- }
770
- export function isEmpty(array$$82) {
771
- return array$$82.length === 0;
772
- }
773
- export function forAll(predicate$$25, array$$83) {
774
- return array$$83.every(predicate$$25);
775
- }
776
- export function permute(f$$8, array$$85) {
777
- const size = array$$85.length | 0;
778
- const res$$7 = array$$85.slice();
779
- const checkFlags = new Int32Array(size);
780
- iterateIndexed(function (i$$34, x$$9) {
781
- const j$$1 = f$$8(i$$34) | 0;
782
-
783
- if (j$$1 < 0 ? true : j$$1 >= size) {
784
- throw new Error("Not a valid permutation");
785
- } else {
786
- void null;
787
- }
788
-
789
- res$$7[j$$1] = x$$9;
790
- checkFlags[j$$1] = 1;
791
- }, array$$85);
792
- let isValid;
793
- isValid = checkFlags.every(function predicate$$27(y) {
794
- return 1 === y;
795
- });
796
-
797
- if (!isValid) {
798
- throw new Error("Not a valid permutation");
799
- } else {
800
- void null;
801
- }
802
-
803
- return res$$7;
804
- }
805
- export function setSlice(target$$5, lower, upper, source$$5) {
806
- const lower$$1 = defaultArg(lower, 0) | 0;
807
- const upper$$1 = defaultArg(upper, 0) | 0;
808
- const length = (upper$$1 > 0 ? upper$$1 : target$$5.length - 1) - lower$$1 | 0;
809
-
810
- for (let i$$35 = 0; i$$35 <= length; i$$35++) {
811
- target$$5[i$$35 + lower$$1] = source$$5[i$$35];
812
- }
813
- }
814
- export function sortInPlaceBy(projection$$3, xs, comparer) {
815
- xs.sort(function (x$$11, y$$1) {
816
- return comparer.Compare(projection$$3(x$$11), projection$$3(y$$1));
817
- });
818
- }
819
- export function sortInPlace(xs$$1, comparer$$1) {
820
- xs$$1.sort(function (x$$12, y$$2) {
821
- return comparer$$1.Compare(x$$12, y$$2);
822
- });
823
- }
824
- export function sort(xs$$2, comparer$$2) {
825
- const xs$$3 = xs$$2.slice();
826
- xs$$3.sort(function comparer$$3(x$$13, y$$3) {
827
- return comparer$$2.Compare(x$$13, y$$3);
828
- });
829
- return xs$$3;
830
- }
831
- export function sortBy(projection$$4, xs$$4, comparer$$4) {
832
- const xs$$5 = xs$$4.slice();
833
- xs$$5.sort(function comparer$$5(x$$14, y$$4) {
834
- return comparer$$4.Compare(projection$$4(x$$14), projection$$4(y$$4));
835
- });
836
- return xs$$5;
837
- }
838
- export function sortDescending(xs$$6, comparer$$6) {
839
- const xs$$7 = xs$$6.slice();
840
- xs$$7.sort(function comparer$$7(x$$15, y$$5) {
841
- return comparer$$6.Compare(x$$15, y$$5) * -1;
842
- });
843
- return xs$$7;
844
- }
845
- export function sortByDescending(projection$$5, xs$$8, comparer$$8) {
846
- const xs$$9 = xs$$8.slice();
847
- xs$$9.sort(function comparer$$9(x$$16, y$$6) {
848
- return comparer$$8.Compare(projection$$5(x$$16), projection$$5(y$$6)) * -1;
849
- });
850
- return xs$$9;
851
- }
852
- export function sortWith(comparer$$10, xs$$10) {
853
- const xs$$11 = xs$$10.slice();
854
- xs$$11.sort(comparer$$10);
855
- return xs$$11;
856
- }
857
- export function unfold(generator, state$$8) {
858
- const res$$8 = [];
859
-
860
- const loop$$8 = function loop$$8($state$$9$$226) {
861
- loop$$8: while (true) {
862
- const state$$9 = $state$$9$$226;
863
- const matchValue$$10 = generator(state$$9);
864
-
865
- if (matchValue$$10 != null) {
866
- const x$$17 = matchValue$$10[0];
867
- const s$$2 = matchValue$$10[1];
868
- const value$$11 = res$$8.push(x$$17);
869
- void value$$11;
870
- $state$$9$$226 = s$$2;
871
- continue loop$$8;
872
- } else {
873
- void null;
874
- }
875
-
876
- break;
877
- }
878
- };
879
-
880
- loop$$8(state$$8);
881
- return res$$8;
882
- }
883
- export function unzip(array$$95) {
884
- const len$$8 = array$$95.length | 0;
885
- const res1$$1 = new Array(len$$8);
886
- const res2$$1 = new Array(len$$8);
887
- iterateIndexed(function (i$$36, tupledArg) {
888
- res1$$1[i$$36] = tupledArg[0];
889
- res2$$1[i$$36] = tupledArg[1];
890
- }, array$$95);
891
- return [res1$$1, res2$$1];
892
- }
893
- export function unzip3(array$$96) {
894
- const len$$11 = array$$96.length | 0;
895
- const res1$$2 = new Array(len$$11);
896
- const res2$$2 = new Array(len$$11);
897
- const res3 = new Array(len$$11);
898
- iterateIndexed(function (i$$37, tupledArg$$1) {
899
- res1$$2[i$$37] = tupledArg$$1[0];
900
- res2$$2[i$$37] = tupledArg$$1[1];
901
- res3[i$$37] = tupledArg$$1[2];
902
- }, array$$96);
903
- return [res1$$2, res2$$2, res3];
904
- }
905
- export function zip(array1$$4, array2$$4) {
906
- if (array1$$4.length !== array2$$4.length) {
907
- throw new Error("Arrays had different lengths");
908
- } else {
909
- void null;
910
- }
911
-
912
- let result$$10;
913
- const len$$15 = array1$$4.length | 0;
914
- result$$10 = new Array(len$$15);
915
-
916
- for (let i$$38 = 0; i$$38 <= array1$$4.length - 1; i$$38++) {
917
- result$$10[i$$38] = [array1$$4[i$$38], array2$$4[i$$38]];
918
- }
919
-
920
- return result$$10;
921
- }
922
- export function zip3(array1$$5, array2$$5, array3) {
923
- if (array1$$5.length !== array2$$5.length ? true : array2$$5.length !== array3.length) {
924
- throw new Error("Arrays had different lengths");
925
- } else {
926
- void null;
927
- }
928
-
929
- let result$$11;
930
- const len$$16 = array1$$5.length | 0;
931
- result$$11 = new Array(len$$16);
932
-
933
- for (let i$$39 = 0; i$$39 <= array1$$5.length - 1; i$$39++) {
934
- result$$11[i$$39] = [array1$$5[i$$39], array2$$5[i$$39], array3[i$$39]];
935
- }
936
-
937
- return result$$11;
938
- }
939
- export function chunkBySize(chunkSize, array$$97) {
940
- if (chunkSize < 1) {
941
- throw new Error("The input must be positive.\\nParameter name: size");
942
- } else {
943
- void null;
944
- }
945
-
946
- if (array$$97.length === 0) {
947
- return [[]];
948
- } else {
949
- const result$$12 = [];
950
-
951
- for (let x$$18 = 0; x$$18 <= ~~Math.ceil(array$$97.length / chunkSize) - 1; x$$18++) {
952
- const start$$8 = x$$18 * chunkSize | 0;
953
- const slice = array$$97.slice(start$$8, start$$8 + chunkSize);
954
- const value$$12 = result$$12.push(slice);
955
- void value$$12;
956
- }
957
-
958
- return result$$12;
959
- }
960
- }
961
- export function splitAt(index$$4, array$$100) {
962
- if (index$$4 < 0) {
963
- throw new Error("The input must be non-negative\\nParameter name: index");
964
- } else {
965
- void null;
966
- }
967
-
968
- if (index$$4 > array$$100.length) {
969
- throw new Error("The input sequence has an insufficient number of elements.\\nParameter name: index");
970
- } else {
971
- void null;
972
- }
973
-
974
- return [array$$100.slice(0, 0 + index$$4), array$$100.slice(index$$4)];
975
- }
976
- export function compareWith(comparer$$12, array1$$6, array2$$6) {
977
- if (array1$$6 == null) {
978
- if (array2$$6 == null) {
979
- return 0;
980
- } else {
981
- return -1 | 0;
982
- }
983
- } else if (array2$$6 == null) {
984
- return 1;
985
- } else {
986
- let i$$40 = 0;
987
- let result$$13 = 0;
988
- const length1 = array1$$6.length | 0;
989
- const length2 = array2$$6.length | 0;
990
-
991
- if (length1 > length2) {
992
- return 1;
993
- } else if (length1 < length2) {
994
- return -1 | 0;
995
- } else {
996
- while (i$$40 < length1 ? result$$13 === 0 : false) {
997
- result$$13 = comparer$$12(array1$$6[i$$40], array2$$6[i$$40]);
998
- i$$40 = i$$40 + 1;
999
- }
1000
-
1001
- return result$$13 | 0;
1002
- }
1003
- }
1004
- }
1005
- export function equalsWith(comparer$$13, array1$$7, array2$$7) {
1006
- return compareWith(compare, array1$$7, array2$$7) === 0;
1007
- }
1008
- export function exactlyOne(array$$103) {
1009
- if (array$$103.length === 1) {
1010
- return array$$103[0];
1011
- } else if (array$$103.length === 0) {
1012
- throw new Error("The input sequence was empty\\nParameter name: array");
1013
- } else {
1014
- throw new Error("Input array too long\\nParameter name: array");
1015
- }
1016
- }
1017
- export function head(array$$104) {
1018
- if (array$$104.length === 0) {
1019
- throw new Error("The input array was empty\\nParameter name: array");
1020
- } else {
1021
- return array$$104[0];
1022
- }
1023
- }
1024
- export function tryHead(array$$105) {
1025
- if (array$$105.length === 0) {
1026
- return undefined;
1027
- } else {
1028
- return some(array$$105[0]);
1029
- }
1030
- }
1031
- export function tail(array$$106) {
1032
- if (array$$106.length === 0) {
1033
- throw new Error("Not enough elements\\nParameter name: array");
1034
- } else {
1035
- void null;
1036
- }
1037
-
1038
- return array$$106.slice(1);
1039
- }
1040
- export function item(index$$5, array$$108) {
1041
- return array$$108[index$$5];
1042
- }
1043
- export function tryItem(index$$6, array$$109) {
1044
- if (index$$6 < 0 ? true : index$$6 >= array$$109.length) {
1045
- return undefined;
1046
- } else {
1047
- return some(array$$109[index$$6]);
1048
- }
1049
- }
1050
- export function foldBackIndexed(folder$$6, array$$110, state$$10) {
1051
- return array$$110.reduceRight(function (delegateArg0$$3, delegateArg1$$3, delegateArg2$$1) {
1052
- return folder$$6(delegateArg2$$1, delegateArg1$$3, delegateArg0$$3);
1053
- }, state$$10);
1054
- }
1055
- export function foldBack(folder$$8, array$$112, state$$12) {
1056
- return array$$112.reduceRight(function (delegateArg0$$4, delegateArg1$$4) {
1057
- return folder$$8(delegateArg1$$4, delegateArg0$$4);
1058
- }, state$$12);
1059
- }
1060
- export function foldIndexed2(folder$$10, state$$14, array1$$8, array2$$8) {
1061
- let acc$$6 = state$$14;
1062
-
1063
- if (array1$$8.length !== array2$$8.length) {
1064
- throw new Error("Arrays have different lengths");
1065
- } else {
1066
- void null;
1067
- }
1068
-
1069
- for (let i$$42 = 0; i$$42 <= array1$$8.length - 1; i$$42++) {
1070
- acc$$6 = folder$$10(i$$42, acc$$6, array1$$8[i$$42], array2$$8[i$$42]);
1071
- }
1072
-
1073
- return acc$$6;
1074
- }
1075
- export function fold2(folder$$11, state$$15, array1$$9, array2$$9) {
1076
- return foldIndexed2(function (_arg1, acc$$7, x$$21, y$$7) {
1077
- return folder$$11(acc$$7, x$$21, y$$7);
1078
- }, state$$15, array1$$9, array2$$9);
1079
- }
1080
- export function foldBackIndexed2(folder$$12, array1$$10, array2$$10, state$$16) {
1081
- let acc$$8 = state$$16;
1082
-
1083
- if (array1$$10.length !== array2$$10.length) {
1084
- throw new Error("Arrays had different lengths");
1085
- } else {
1086
- void null;
1087
- }
1088
-
1089
- const size$$1 = array1$$10.length | 0;
1090
-
1091
- for (let i$$43 = 1; i$$43 <= size$$1; i$$43++) {
1092
- acc$$8 = folder$$12(i$$43 - 1, array1$$10[size$$1 - i$$43], array2$$10[size$$1 - i$$43], acc$$8);
1093
- }
1094
-
1095
- return acc$$8;
1096
- }
1097
- export function foldBack2(f$$9, array1$$11, array2$$11, state$$17) {
1098
- return foldBackIndexed2(function (_arg1$$1, x$$22, y$$8, acc$$9) {
1099
- return f$$9(x$$22, y$$8, acc$$9);
1100
- }, array1$$11, array2$$11, state$$17);
1101
- }
1102
- export function reduce(reduction, array$$114) {
1103
- if (array$$114.length === 0) {
1104
- throw new Error("The input array was empty");
1105
- } else {
1106
- void null;
1107
- }
1108
-
1109
- return array$$114.reduce(reduction);
1110
- }
1111
- export function reduceBack(reduction$$2, array$$116) {
1112
- if (array$$116.length === 0) {
1113
- throw new Error("The input array was empty");
1114
- } else {
1115
- void null;
1116
- }
1117
-
1118
- return array$$116.reduceRight(reduction$$2);
1119
- }
1120
- export function forAll2(predicate$$29, array1$$12, array2$$12) {
1121
- return fold2(function (acc$$10, x$$23, y$$9) {
1122
- return acc$$10 ? predicate$$29(x$$23, y$$9) : false;
1123
- }, true, array1$$12, array2$$12);
1124
- }
1125
- export function existsOffset($predicate$$30$$281, $array$$118$$282, $index$$7$$283) {
1126
- existsOffset: while (true) {
1127
- const predicate$$30 = $predicate$$30$$281,
1128
- array$$118 = $array$$118$$282,
1129
- index$$7 = $index$$7$$283;
1130
-
1131
- if (index$$7 === array$$118.length) {
1132
- return false;
1133
- } else if (predicate$$30(array$$118[index$$7])) {
1134
- return true;
1135
- } else {
1136
- $predicate$$30$$281 = predicate$$30;
1137
- $array$$118$$282 = array$$118;
1138
- $index$$7$$283 = index$$7 + 1;
1139
- continue existsOffset;
1140
- }
1141
-
1142
- break;
1143
- }
1144
- }
1145
- export function exists(predicate$$31, array$$119) {
1146
- return existsOffset(predicate$$31, array$$119, 0);
1147
- }
1148
- export function existsOffset2($predicate$$32$$286, $array1$$13$$287, $array2$$13$$288, $index$$8$$289) {
1149
- existsOffset2: while (true) {
1150
- const predicate$$32 = $predicate$$32$$286,
1151
- array1$$13 = $array1$$13$$287,
1152
- array2$$13 = $array2$$13$$288,
1153
- index$$8 = $index$$8$$289;
1154
-
1155
- if (index$$8 === array1$$13.length) {
1156
- return false;
1157
- } else if (predicate$$32(array1$$13[index$$8], array2$$13[index$$8])) {
1158
- return true;
1159
- } else {
1160
- $predicate$$32$$286 = predicate$$32;
1161
- $array1$$13$$287 = array1$$13;
1162
- $array2$$13$$288 = array2$$13;
1163
- $index$$8$$289 = index$$8 + 1;
1164
- continue existsOffset2;
1165
- }
1166
-
1167
- break;
1168
- }
1169
- }
1170
- export function exists2(predicate$$33, array1$$14, array2$$14) {
1171
- if (array1$$14.length !== array2$$14.length) {
1172
- throw new Error("Arrays had different lengths");
1173
- } else {
1174
- void null;
1175
- }
1176
-
1177
- return existsOffset2(predicate$$33, array1$$14, array2$$14, 0);
1178
- }
1179
- export function sum(array$$120, adder) {
1180
- let acc$$11 = adder.GetZero();
1181
-
1182
- for (let i$$44 = 0; i$$44 <= array$$120.length - 1; i$$44++) {
1183
- acc$$11 = adder.Add(acc$$11, array$$120[i$$44]);
1184
- }
1185
-
1186
- return acc$$11;
1187
- }
1188
- export function sumBy(projection$$6, array$$121, adder$$1) {
1189
- let acc$$12 = adder$$1.GetZero();
1190
-
1191
- for (let i$$45 = 0; i$$45 <= array$$121.length - 1; i$$45++) {
1192
- acc$$12 = adder$$1.Add(acc$$12, projection$$6(array$$121[i$$45]));
1193
- }
1194
-
1195
- return acc$$12;
1196
- }
1197
- export function maxBy(projection$$7, xs$$12, comparer$$14) {
1198
- return reduce(function (x$$24, y$$10) {
1199
- return comparer$$14.Compare(projection$$7(y$$10), projection$$7(x$$24)) > 0 ? y$$10 : x$$24;
1200
- }, xs$$12);
1201
- }
1202
- export function max(xs$$13, comparer$$15) {
1203
- return reduce(function (x$$25, y$$11) {
1204
- return comparer$$15.Compare(y$$11, x$$25) > 0 ? y$$11 : x$$25;
1205
- }, xs$$13);
1206
- }
1207
- export function minBy(projection$$8, xs$$14, comparer$$16) {
1208
- return reduce(function (x$$26, y$$12) {
1209
- return comparer$$16.Compare(projection$$8(y$$12), projection$$8(x$$26)) > 0 ? x$$26 : y$$12;
1210
- }, xs$$14);
1211
- }
1212
- export function min(xs$$15, comparer$$17) {
1213
- return reduce(function (x$$27, y$$13) {
1214
- return comparer$$17.Compare(y$$13, x$$27) > 0 ? x$$27 : y$$13;
1215
- }, xs$$15);
1216
- }
1217
- export function average(array$$122, averager) {
1218
- if (array$$122.length === 0) {
1219
- throw new Error("The input array was empty\\nParameter name: array");
1220
- } else {
1221
- void null;
1222
- }
1223
-
1224
- let total = averager.GetZero();
1225
-
1226
- for (let i$$46 = 0; i$$46 <= array$$122.length - 1; i$$46++) {
1227
- total = averager.Add(total, array$$122[i$$46]);
1228
- }
1229
-
1230
- return averager.DivideByInt(total, array$$122.length);
1231
- }
1232
- export function averageBy(projection$$9, array$$123, averager$$1) {
1233
- if (array$$123.length === 0) {
1234
- throw new Error("The input array was empty\\nParameter name: array");
1235
- } else {
1236
- void null;
1237
- }
1238
-
1239
- let total$$1 = averager$$1.GetZero();
1240
-
1241
- for (let i$$47 = 0; i$$47 <= array$$123.length - 1; i$$47++) {
1242
- total$$1 = averager$$1.Add(total$$1, projection$$9(array$$123[i$$47]));
1243
- }
1244
-
1245
- return averager$$1.DivideByInt(total$$1, array$$123.length);
1246
- }
1247
- export function ofSeq(source$$6, cons$$31) {
1248
- return cons$$31.from(source$$6);
1249
- }
1250
- export function ofList(source$$7, cons$$32) {
1251
- return cons$$32.from(source$$7);
1252
- }
1253
- export function toList(source$$8) {
1254
- const len$$17 = source$$8.length | 0;
1255
- let target$$6 = new List();
1256
-
1257
- for (let i$$48 = len$$17 - 1; i$$48 >= 0; i$$48--) {
1258
- target$$6 = new List(source$$8[i$$48], target$$6);
1259
- }
1260
-
1261
- return target$$6;
1262
- }
1263
- export function windowed(windowSize, source$$9) {
1264
- if (windowSize <= 0) {
1265
- throw new Error("windowSize must be positive");
1266
- } else {
1267
- void null;
1268
- }
1269
-
1270
- let res$$9;
1271
- const len$$18 = max$$1(comparePrimitives, 0, source$$9.length - windowSize) | 0;
1272
- res$$9 = new Array(len$$18);
1273
-
1274
- for (let i$$49 = windowSize; i$$49 <= source$$9.length; i$$49++) {
1275
- res$$9[i$$49 - windowSize] = source$$9.slice(i$$49 - windowSize, i$$49 - 1 + 1);
1276
- }
1277
-
1278
- return res$$9;
1279
- }
1280
- export function splitInto(chunks, array$$124) {
1281
- if (chunks < 1) {
1282
- throw new Error("The input must be positive.\\nParameter name: chunks");
1283
- } else {
1284
- void null;
1285
- }
1286
-
1287
- if (array$$124.length === 0) {
1288
- return [[]];
1289
- } else {
1290
- const result$$14 = [];
1291
- const chunks$$1 = min$$1(comparePrimitives, chunks, array$$124.length) | 0;
1292
- const minChunkSize = ~~(array$$124.length / chunks$$1) | 0;
1293
- const chunksWithExtraItem = array$$124.length % chunks$$1 | 0;
1294
-
1295
- for (let i$$50 = 0; i$$50 <= chunks$$1 - 1; i$$50++) {
1296
- const chunkSize$$1 = (i$$50 < chunksWithExtraItem ? minChunkSize + 1 : minChunkSize) | 0;
1297
- const start$$11 = i$$50 * minChunkSize + min$$1(comparePrimitives, chunksWithExtraItem, i$$50) | 0;
1298
- const slice$$1 = array$$124.slice(start$$11, start$$11 + chunkSize$$1);
1299
- const value$$13 = result$$14.push(slice$$1);
1300
- void value$$13;
1301
- }
1302
-
1303
- return result$$14;
1304
- }
1305
- }
1306
- export function transpose(arrays$$2, cons$$33) {
1307
- var value$$14;
1308
- const arrays$$3 = Array.isArray(arrays$$2) ? arrays$$2 : Array.from(arrays$$2);
1309
- const len$$20 = arrays$$3.length | 0;
1310
-
1311
- if (len$$20 === 0) {
1312
- return new Array(0);
1313
- } else {
1314
- const lenInner = arrays$$3[0].length | 0;
1315
-
1316
- if (value$$14 = forAll(function predicate$$34(a) {
1317
- return a.length === lenInner;
1318
- }, arrays$$3), !value$$14) {
1319
- throw new Error("Arrays had different lengths");
1320
- } else {
1321
- void null;
1322
- }
1323
-
1324
- const result$$15 = new Array(lenInner);
1325
-
1326
- for (let i$$51 = 0; i$$51 <= lenInner - 1; i$$51++) {
1327
- result$$15[i$$51] = new cons$$33(len$$20);
1328
-
1329
- for (let j$$2 = 0; j$$2 <= len$$20 - 1; j$$2++) {
1330
- result$$15[i$$51][j$$2] = arrays$$3[j$$2][i$$51];
1331
- }
1332
- }
1333
-
1334
- return result$$15;
1335
- }
1336
- }