compostjs 0.0.8 → 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/README.md +4 -4
  2. package/dist/fable_modules/fable-library-js.4.28.0/Array.d.ts +123 -0
  3. package/dist/fable_modules/fable-library-js.4.28.0/Array.js +1242 -0
  4. package/dist/fable_modules/fable-library-js.4.28.0/Async.d.ts +26 -0
  5. package/dist/fable_modules/fable-library-js.4.28.0/Async.js +145 -0
  6. package/dist/fable_modules/fable-library-js.4.28.0/AsyncBuilder.d.ts +59 -0
  7. package/dist/fable_modules/fable-library-js.4.28.0/AsyncBuilder.js +183 -0
  8. package/dist/fable_modules/fable-library-js.4.28.0/BigInt.d.ts +115 -0
  9. package/dist/fable_modules/fable-library-js.4.28.0/BigInt.js +283 -0
  10. package/dist/fable_modules/fable-library-js.4.28.0/BitConverter.d.ts +27 -0
  11. package/dist/fable_modules/fable-library-js.4.28.0/BitConverter.js +138 -0
  12. package/dist/fable_modules/fable-library-js.4.28.0/Boolean.d.ts +3 -0
  13. package/dist/fable_modules/fable-library-js.4.28.0/Boolean.js +21 -0
  14. package/dist/fable_modules/fable-library-js.4.28.0/CHANGELOG.md +100 -0
  15. package/dist/fable_modules/fable-library-js.4.28.0/Char.d.ts +65 -0
  16. package/dist/fable_modules/fable-library-js.4.28.0/Char.js +169 -0
  17. package/dist/fable_modules/fable-library-js.4.28.0/Choice.d.ts +121 -0
  18. package/dist/fable_modules/fable-library-js.4.28.0/Choice.js +184 -0
  19. package/dist/fable_modules/fable-library-js.4.28.0/CollectionUtil.d.ts +7 -0
  20. package/dist/fable_modules/fable-library-js.4.28.0/CollectionUtil.js +182 -0
  21. package/dist/fable_modules/fable-library-js.4.28.0/ConditionalWeakTable.d.ts +9 -0
  22. package/dist/fable_modules/fable-library-js.4.28.0/ConditionalWeakTable.js +21 -0
  23. package/dist/fable_modules/fable-library-js.4.28.0/Date.d.ts +70 -0
  24. package/dist/fable_modules/fable-library-js.4.28.0/Date.js +748 -0
  25. package/dist/fable_modules/fable-library-js.4.28.0/DateOffset.d.ts +63 -0
  26. package/dist/fable_modules/fable-library-js.4.28.0/DateOffset.js +268 -0
  27. package/dist/fable_modules/fable-library-js.4.28.0/DateOnly.d.ts +18 -0
  28. package/dist/fable_modules/fable-library-js.4.28.0/DateOnly.js +124 -0
  29. package/dist/fable_modules/fable-library-js.4.28.0/Decimal.d.ts +45 -0
  30. package/dist/fable_modules/fable-library-js.4.28.0/Decimal.js +212 -0
  31. package/dist/fable_modules/fable-library-js.4.28.0/Double.d.ts +11 -0
  32. package/dist/fable_modules/fable-library-js.4.28.0/Double.js +46 -0
  33. package/dist/fable_modules/fable-library-js.4.28.0/Encoding.d.ts +12 -0
  34. package/dist/fable_modules/fable-library-js.4.28.0/Encoding.js +173 -0
  35. package/dist/fable_modules/fable-library-js.4.28.0/Event.d.ts +31 -0
  36. package/dist/fable_modules/fable-library-js.4.28.0/Event.js +93 -0
  37. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Collections.d.ts +7 -0
  38. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Collections.js +27 -0
  39. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.CompilerServices.d.ts +12 -0
  40. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.CompilerServices.js +27 -0
  41. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.d.ts +17 -0
  42. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.js +69 -0
  43. package/dist/fable_modules/fable-library-js.4.28.0/Global.d.ts +24 -0
  44. package/dist/fable_modules/fable-library-js.4.28.0/Global.js +8 -0
  45. package/dist/fable_modules/fable-library-js.4.28.0/Guid.d.ts +10 -0
  46. package/dist/fable_modules/fable-library-js.4.28.0/Guid.js +142 -0
  47. package/dist/fable_modules/fable-library-js.4.28.0/Int32.d.ts +28 -0
  48. package/dist/fable_modules/fable-library-js.4.28.0/Int32.js +135 -0
  49. package/dist/fable_modules/fable-library-js.4.28.0/List.d.ts +143 -0
  50. package/dist/fable_modules/fable-library-js.4.28.0/List.js +1273 -0
  51. package/dist/fable_modules/fable-library-js.4.28.0/Long.d.ts +3 -0
  52. package/dist/fable_modules/fable-library-js.4.28.0/Long.js +46 -0
  53. package/dist/fable_modules/fable-library-js.4.28.0/MailboxProcessor.d.ts +25 -0
  54. package/dist/fable_modules/fable-library-js.4.28.0/MailboxProcessor.js +93 -0
  55. package/dist/fable_modules/fable-library-js.4.28.0/Map.d.ts +178 -0
  56. package/dist/fable_modules/fable-library-js.4.28.0/Map.js +1396 -0
  57. package/dist/fable_modules/fable-library-js.4.28.0/MapUtil.d.ts +12 -0
  58. package/dist/fable_modules/fable-library-js.4.28.0/MapUtil.js +127 -0
  59. package/dist/fable_modules/fable-library-js.4.28.0/MutableMap.d.ts +52 -0
  60. package/dist/fable_modules/fable-library-js.4.28.0/MutableMap.js +327 -0
  61. package/dist/fable_modules/fable-library-js.4.28.0/MutableSet.d.ts +39 -0
  62. package/dist/fable_modules/fable-library-js.4.28.0/MutableSet.js +233 -0
  63. package/dist/fable_modules/fable-library-js.4.28.0/Native.d.ts +2 -0
  64. package/dist/fable_modules/fable-library-js.4.28.0/Native.js +8 -0
  65. package/dist/fable_modules/fable-library-js.4.28.0/Numeric.d.ts +19 -0
  66. package/dist/fable_modules/fable-library-js.4.28.0/Numeric.js +71 -0
  67. package/dist/fable_modules/fable-library-js.4.28.0/Observable.d.ts +32 -0
  68. package/dist/fable_modules/fable-library-js.4.28.0/Observable.js +113 -0
  69. package/dist/fable_modules/fable-library-js.4.28.0/Option.d.ts +28 -0
  70. package/dist/fable_modules/fable-library-js.4.28.0/Option.js +96 -0
  71. package/dist/fable_modules/fable-library-js.4.28.0/README.md +3 -0
  72. package/dist/fable_modules/fable-library-js.4.28.0/Random.d.ts +37 -0
  73. package/dist/fable_modules/fable-library-js.4.28.0/Random.js +170 -0
  74. package/dist/fable_modules/fable-library-js.4.28.0/Range.d.ts +12 -0
  75. package/dist/fable_modules/fable-library-js.4.28.0/Range.js +45 -0
  76. package/dist/fable_modules/fable-library-js.4.28.0/Reflection.d.ts +119 -0
  77. package/dist/fable_modules/fable-library-js.4.28.0/Reflection.js +461 -0
  78. package/dist/fable_modules/fable-library-js.4.28.0/RegExp.d.ts +10 -0
  79. package/dist/fable_modules/fable-library-js.4.28.0/RegExp.js +131 -0
  80. package/dist/fable_modules/fable-library-js.4.28.0/Result.d.ts +37 -0
  81. package/dist/fable_modules/fable-library-js.4.28.0/Result.js +165 -0
  82. package/dist/fable_modules/fable-library-js.4.28.0/Seq.d.ts +165 -0
  83. package/dist/fable_modules/fable-library-js.4.28.0/Seq.js +1378 -0
  84. package/dist/fable_modules/fable-library-js.4.28.0/Seq2.d.ts +18 -0
  85. package/dist/fable_modules/fable-library-js.4.28.0/Seq2.js +111 -0
  86. package/dist/fable_modules/fable-library-js.4.28.0/Set.d.ts +190 -0
  87. package/dist/fable_modules/fable-library-js.4.28.0/Set.js +1789 -0
  88. package/dist/fable_modules/fable-library-js.4.28.0/String.d.ts +58 -0
  89. package/dist/fable_modules/fable-library-js.4.28.0/String.js +554 -0
  90. package/dist/fable_modules/fable-library-js.4.28.0/System.Collections.Generic.d.ts +79 -0
  91. package/dist/fable_modules/fable-library-js.4.28.0/System.Collections.Generic.js +317 -0
  92. package/dist/fable_modules/fable-library-js.4.28.0/System.Text.d.ts +38 -0
  93. package/dist/fable_modules/fable-library-js.4.28.0/System.Text.js +162 -0
  94. package/dist/fable_modules/fable-library-js.4.28.0/SystemException.d.ts +5 -0
  95. package/dist/fable_modules/fable-library-js.4.28.0/SystemException.js +5 -0
  96. package/dist/fable_modules/fable-library-js.4.28.0/TimeOnly.d.ts +15 -0
  97. package/dist/fable_modules/fable-library-js.4.28.0/TimeOnly.js +122 -0
  98. package/dist/fable_modules/fable-library-js.4.28.0/TimeSpan.d.ts +34 -0
  99. package/dist/fable_modules/fable-library-js.4.28.0/TimeSpan.js +177 -0
  100. package/dist/fable_modules/fable-library-js.4.28.0/Timer.d.ts +19 -0
  101. package/dist/fable_modules/fable-library-js.4.28.0/Timer.js +67 -0
  102. package/dist/fable_modules/fable-library-js.4.28.0/Types.d.ts +58 -0
  103. package/dist/fable_modules/fable-library-js.4.28.0/Types.js +208 -0
  104. package/dist/fable_modules/fable-library-js.4.28.0/Unicode.13.0.0.d.ts +2 -0
  105. package/dist/fable_modules/fable-library-js.4.28.0/Unicode.13.0.0.js +4 -0
  106. package/dist/fable_modules/fable-library-js.4.28.0/Uri.d.ts +31 -0
  107. package/dist/fable_modules/fable-library-js.4.28.0/Uri.js +159 -0
  108. package/dist/fable_modules/fable-library-js.4.28.0/Util.d.ts +210 -0
  109. package/dist/fable_modules/fable-library-js.4.28.0/Util.js +769 -0
  110. package/dist/fable_modules/fable-library-js.4.28.0/big.d.ts +338 -0
  111. package/dist/fable_modules/fable-library-js.4.28.0/lib/big.d.ts +5 -0
  112. package/dist/fable_modules/fable-library-js.4.28.0/lib/big.js +825 -0
  113. package/dist/fable_modules/fable-library-js.4.28.0/package.json +24 -0
  114. package/dist/fable_modules/project_cracked.json +1 -0
  115. package/package.json +6 -5
  116. package/.claude/settings.local.json +0 -11
  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
@@ -0,0 +1,769 @@
1
+ export function isArrayLike(x) {
2
+ return Array.isArray(x) || ArrayBuffer.isView(x);
3
+ }
4
+ export function isIterable(x) {
5
+ return x != null && typeof x === "object" && Symbol.iterator in x;
6
+ }
7
+ export function isEnumerable(x) {
8
+ return x != null && typeof x.GetEnumerator === "function";
9
+ }
10
+ export function isComparer(x) {
11
+ return x != null && typeof x.Compare === "function";
12
+ }
13
+ export function isComparable(x) {
14
+ return x != null && typeof x.CompareTo === "function";
15
+ }
16
+ export function isEquatable(x) {
17
+ return x != null && typeof x.Equals === "function";
18
+ }
19
+ export function isHashable(x) {
20
+ return x != null && typeof x.GetHashCode === "function";
21
+ }
22
+ export function isDisposable(x) {
23
+ return x != null && typeof x.Dispose === "function";
24
+ }
25
+ export function disposeSafe(x) {
26
+ if (isDisposable(x)) {
27
+ x.Dispose();
28
+ }
29
+ }
30
+ export function defaultOf() {
31
+ return null;
32
+ }
33
+ export function sameConstructor(x, y) {
34
+ return Object.getPrototypeOf(x)?.constructor === Object.getPrototypeOf(y)?.constructor;
35
+ }
36
+ export class Enumerable {
37
+ constructor(en) {
38
+ this.en = en;
39
+ }
40
+ GetEnumerator() { return this.en; }
41
+ "System.Collections.IEnumerable.GetEnumerator"() { return this.en; }
42
+ [Symbol.iterator]() {
43
+ return this;
44
+ }
45
+ next() {
46
+ const hasNext = this.en["System.Collections.IEnumerator.MoveNext"]();
47
+ const current = hasNext ? this.en["System.Collections.Generic.IEnumerator`1.get_Current"]() : undefined;
48
+ return { done: !hasNext, value: current };
49
+ }
50
+ }
51
+ export class Enumerator {
52
+ constructor(iter) {
53
+ this.iter = iter;
54
+ this.current = defaultOf();
55
+ }
56
+ ["System.Collections.Generic.IEnumerator`1.get_Current"]() {
57
+ return this.current;
58
+ }
59
+ ["System.Collections.IEnumerator.get_Current"]() {
60
+ return this.current;
61
+ }
62
+ ["System.Collections.IEnumerator.MoveNext"]() {
63
+ const cur = this.iter.next();
64
+ this.current = cur.value;
65
+ return !cur.done;
66
+ }
67
+ ["System.Collections.IEnumerator.Reset"]() {
68
+ throw new Error("JS iterators cannot be reset");
69
+ }
70
+ Dispose() {
71
+ return;
72
+ }
73
+ }
74
+ export function toEnumerable(e) {
75
+ if (isEnumerable(e)) {
76
+ return e;
77
+ }
78
+ else {
79
+ return new Enumerable(new Enumerator(e[Symbol.iterator]()));
80
+ }
81
+ }
82
+ export function getEnumerator(e) {
83
+ if (isEnumerable(e)) {
84
+ return e.GetEnumerator();
85
+ }
86
+ else {
87
+ return new Enumerator(e[Symbol.iterator]());
88
+ }
89
+ }
90
+ export function toIterator(en) {
91
+ return {
92
+ next() {
93
+ const hasNext = en["System.Collections.IEnumerator.MoveNext"]();
94
+ const current = hasNext ? en["System.Collections.Generic.IEnumerator`1.get_Current"]() : undefined;
95
+ return { done: !hasNext, value: current };
96
+ },
97
+ };
98
+ }
99
+ export function enumerableToIterator(e) {
100
+ return toIterator(toEnumerable(e).GetEnumerator());
101
+ }
102
+ export class Comparer {
103
+ constructor(f) {
104
+ this.Compare = f || compare;
105
+ }
106
+ }
107
+ export function comparerFromEqualityComparer(comparer) {
108
+ // Sometimes IEqualityComparer also implements IComparer
109
+ if (isComparer(comparer)) {
110
+ return new Comparer(comparer.Compare);
111
+ }
112
+ else {
113
+ return new Comparer((x, y) => {
114
+ const xhash = comparer.GetHashCode(x);
115
+ const yhash = comparer.GetHashCode(y);
116
+ if (xhash === yhash) {
117
+ return comparer.Equals(x, y) ? 0 : -1;
118
+ }
119
+ else {
120
+ return xhash < yhash ? -1 : 1;
121
+ }
122
+ });
123
+ }
124
+ }
125
+ export function assertEqual(actual, expected, msg) {
126
+ if (!equals(actual, expected)) {
127
+ throw Object.assign(new Error(msg || `Expected: ${expected} - Actual: ${actual}`), {
128
+ actual,
129
+ expected,
130
+ });
131
+ }
132
+ }
133
+ export function assertNotEqual(actual, expected, msg) {
134
+ if (equals(actual, expected)) {
135
+ throw Object.assign(new Error(msg || `Expected: ${expected} - Actual: ${actual}`), {
136
+ actual,
137
+ expected,
138
+ });
139
+ }
140
+ }
141
+ export class Lazy {
142
+ constructor(factory) {
143
+ this.factory = factory;
144
+ this.isValueCreated = false;
145
+ }
146
+ get Value() {
147
+ if (!this.isValueCreated) {
148
+ this.createdValue = this.factory();
149
+ this.isValueCreated = true;
150
+ }
151
+ return this.createdValue;
152
+ }
153
+ get IsValueCreated() {
154
+ return this.isValueCreated;
155
+ }
156
+ }
157
+ export function lazyFromValue(v) {
158
+ return new Lazy(() => v);
159
+ }
160
+ export function padWithZeros(i, length) {
161
+ return i.toString(10).padStart(length, "0");
162
+ }
163
+ export function padLeftAndRightWithZeros(i, lengthLeft, lengthRight) {
164
+ return i.toString(10).padStart(lengthLeft, "0").padEnd(lengthRight, "0");
165
+ }
166
+ export function dateOffset(date) {
167
+ const date1 = date;
168
+ return typeof date1.offset === "number"
169
+ ? date1.offset
170
+ : (date.kind === 1 /* DateKind.UTC */
171
+ ? 0 : date.getTimezoneOffset() * -60000);
172
+ }
173
+ export function int16ToString(i, radix) {
174
+ i = i < 0 && radix != null && radix !== 10 ? 0xFFFF + i + 1 : i;
175
+ return i.toString(radix);
176
+ }
177
+ export function int32ToString(i, radix) {
178
+ i = i < 0 && radix != null && radix !== 10 ? 0xFFFFFFFF + i + 1 : i;
179
+ return i.toString(radix);
180
+ }
181
+ export function int64ToString(i, radix) {
182
+ i = i < 0 && radix != null && radix !== 10 ? 0xffffffffffffffffn + i + 1n : i;
183
+ return i.toString(radix);
184
+ }
185
+ export class ObjectRef {
186
+ static id(o) {
187
+ if (!ObjectRef.idMap.has(o)) {
188
+ ObjectRef.idMap.set(o, ++ObjectRef.count);
189
+ }
190
+ return ObjectRef.idMap.get(o);
191
+ }
192
+ }
193
+ ObjectRef.idMap = new WeakMap();
194
+ ObjectRef.count = 0;
195
+ export function stringHash(s) {
196
+ let i = 0;
197
+ let h = 5381;
198
+ const len = s.length;
199
+ while (i < len) {
200
+ h = (h * 33) ^ s.charCodeAt(i++);
201
+ }
202
+ return h;
203
+ }
204
+ export function numberHash(x) {
205
+ return x * 2654435761 | 0;
206
+ }
207
+ export function bigintHash(x) {
208
+ return stringHash(x.toString(32));
209
+ }
210
+ // From https://stackoverflow.com/a/37449594
211
+ export function combineHashCodes(hashes) {
212
+ let h1 = 0;
213
+ const len = hashes.length;
214
+ for (let i = 0; i < len; i++) {
215
+ const h2 = hashes[i];
216
+ h1 = ((h1 << 5) + h1) ^ h2;
217
+ }
218
+ return h1;
219
+ }
220
+ export function physicalHash(x) {
221
+ if (x == null) {
222
+ return 0;
223
+ }
224
+ switch (typeof x) {
225
+ case "boolean":
226
+ return x ? 1 : 0;
227
+ case "number":
228
+ return numberHash(x);
229
+ case "bigint":
230
+ return bigintHash(x);
231
+ case "string":
232
+ return stringHash(x);
233
+ default:
234
+ return numberHash(ObjectRef.id(x));
235
+ }
236
+ }
237
+ export function identityHash(x) {
238
+ if (isHashable(x)) {
239
+ return x.GetHashCode();
240
+ }
241
+ else {
242
+ return physicalHash(x);
243
+ }
244
+ }
245
+ export function dateHash(x) {
246
+ return x.getTime();
247
+ }
248
+ export function arrayHash(x) {
249
+ const len = x.length;
250
+ const hashes = new Array(len);
251
+ for (let i = 0; i < len; i++) {
252
+ hashes[i] = structuralHash(x[i]);
253
+ }
254
+ return combineHashCodes(hashes);
255
+ }
256
+ export function structuralHash(x) {
257
+ if (x == null) {
258
+ return 0;
259
+ }
260
+ switch (typeof x) {
261
+ case "boolean":
262
+ return x ? 1 : 0;
263
+ case "number":
264
+ return numberHash(x);
265
+ case "bigint":
266
+ return bigintHash(x);
267
+ case "string":
268
+ return stringHash(x);
269
+ default: {
270
+ if (isHashable(x)) {
271
+ return x.GetHashCode();
272
+ }
273
+ else if (isArrayLike(x)) {
274
+ return arrayHash(x);
275
+ }
276
+ else if (x instanceof Date) {
277
+ return dateHash(x);
278
+ }
279
+ else if (Object.getPrototypeOf(x)?.constructor === Object) {
280
+ // TODO: check call-stack to prevent cyclic objects?
281
+ const hashes = Object.values(x).map((v) => structuralHash(v));
282
+ return combineHashCodes(hashes);
283
+ }
284
+ else {
285
+ // Classes don't implement GetHashCode by default, but must use identity hashing
286
+ return numberHash(ObjectRef.id(x));
287
+ // return stringHash(String(x));
288
+ }
289
+ }
290
+ }
291
+ }
292
+ // Intended for custom numeric types, like long or decimal
293
+ export function fastStructuralHash(x) {
294
+ return stringHash(String(x));
295
+ }
296
+ // Intended for declared types that may or may not implement GetHashCode
297
+ export function safeHash(x) {
298
+ // return x == null ? 0 : isHashable(x) ? x.GetHashCode() : numberHash(ObjectRef.id(x));
299
+ return identityHash(x);
300
+ }
301
+ export function equalArraysWith(x, y, eq) {
302
+ if (x == null) {
303
+ return y == null;
304
+ }
305
+ if (y == null) {
306
+ return false;
307
+ }
308
+ if (x.length !== y.length) {
309
+ return false;
310
+ }
311
+ for (let i = 0; i < x.length; i++) {
312
+ if (!eq(x[i], y[i])) {
313
+ return false;
314
+ }
315
+ }
316
+ return true;
317
+ }
318
+ export function equalArrays(x, y) {
319
+ return equalArraysWith(x, y, equals);
320
+ }
321
+ function equalObjects(x, y) {
322
+ const xKeys = Object.keys(x);
323
+ const yKeys = Object.keys(y);
324
+ if (xKeys.length !== yKeys.length) {
325
+ return false;
326
+ }
327
+ xKeys.sort();
328
+ yKeys.sort();
329
+ for (let i = 0; i < xKeys.length; i++) {
330
+ if (xKeys[i] !== yKeys[i] || !equals(x[xKeys[i]], y[yKeys[i]])) {
331
+ return false;
332
+ }
333
+ }
334
+ return true;
335
+ }
336
+ export function physicalEquality(x, y) {
337
+ return x === y;
338
+ }
339
+ export function equals(x, y) {
340
+ if (x === y) {
341
+ return true;
342
+ }
343
+ else if (x == null) {
344
+ return y == null;
345
+ }
346
+ else if (y == null) {
347
+ return false;
348
+ }
349
+ else if (isEquatable(x)) {
350
+ return x.Equals(y);
351
+ }
352
+ else if (isArrayLike(x)) {
353
+ return isArrayLike(y) && equalArrays(x, y);
354
+ }
355
+ else if (typeof x !== "object") {
356
+ return false;
357
+ }
358
+ else if (x instanceof Date) {
359
+ return (y instanceof Date) && compareDates(x, y) === 0;
360
+ }
361
+ else {
362
+ return Object.getPrototypeOf(x)?.constructor === Object && equalObjects(x, y);
363
+ }
364
+ }
365
+ export function compareDates(x, y) {
366
+ let xtime;
367
+ let ytime;
368
+ // DateTimeOffset and DateTime deals with equality differently.
369
+ if ("offset" in x && "offset" in y) {
370
+ xtime = x.getTime();
371
+ ytime = y.getTime();
372
+ }
373
+ else {
374
+ xtime = x.getTime() + dateOffset(x);
375
+ ytime = y.getTime() + dateOffset(y);
376
+ }
377
+ return xtime === ytime ? 0 : (xtime < ytime ? -1 : 1);
378
+ }
379
+ export function comparePrimitives(x, y) {
380
+ return x === y ? 0 : (x < y ? -1 : 1);
381
+ }
382
+ export function compareArraysWith(x, y, comp) {
383
+ if (x == null) {
384
+ return y == null ? 0 : 1;
385
+ }
386
+ if (y == null) {
387
+ return -1;
388
+ }
389
+ if (x.length !== y.length) {
390
+ return x.length < y.length ? -1 : 1;
391
+ }
392
+ for (let i = 0, j = 0; i < x.length; i++) {
393
+ j = comp(x[i], y[i]);
394
+ if (j !== 0) {
395
+ return j;
396
+ }
397
+ }
398
+ return 0;
399
+ }
400
+ export function compareArrays(x, y) {
401
+ return compareArraysWith(x, y, compare);
402
+ }
403
+ function compareObjects(x, y) {
404
+ const xKeys = Object.keys(x);
405
+ const yKeys = Object.keys(y);
406
+ if (xKeys.length !== yKeys.length) {
407
+ return xKeys.length < yKeys.length ? -1 : 1;
408
+ }
409
+ xKeys.sort();
410
+ yKeys.sort();
411
+ for (let i = 0, j = 0; i < xKeys.length; i++) {
412
+ const key = xKeys[i];
413
+ if (key !== yKeys[i]) {
414
+ return key < yKeys[i] ? -1 : 1;
415
+ }
416
+ else {
417
+ j = compare(x[key], y[key]);
418
+ if (j !== 0) {
419
+ return j;
420
+ }
421
+ }
422
+ }
423
+ return 0;
424
+ }
425
+ export function compare(x, y) {
426
+ if (x === y) {
427
+ return 0;
428
+ }
429
+ else if (x == null) {
430
+ return y == null ? 0 : -1;
431
+ }
432
+ else if (y == null) {
433
+ return 1;
434
+ }
435
+ else if (isComparable(x)) {
436
+ return x.CompareTo(y);
437
+ }
438
+ else if (isArrayLike(x)) {
439
+ return isArrayLike(y) ? compareArrays(x, y) : -1;
440
+ }
441
+ else if (typeof x !== "object") {
442
+ return x < y ? -1 : 1;
443
+ }
444
+ else if (x instanceof Date) {
445
+ return y instanceof Date ? compareDates(x, y) : -1;
446
+ }
447
+ else {
448
+ return Object.getPrototypeOf(x)?.constructor === Object ? compareObjects(x, y) : -1;
449
+ }
450
+ }
451
+ export function min(comparer, x, y) {
452
+ return comparer(x, y) < 0 ? x : y;
453
+ }
454
+ export function max(comparer, x, y) {
455
+ return comparer(x, y) > 0 ? x : y;
456
+ }
457
+ export function clamp(comparer, value, min, max) {
458
+ return (comparer(value, min) < 0) ? min : (comparer(value, max) > 0) ? max : value;
459
+ }
460
+ export function createAtom(value) {
461
+ let atom = value;
462
+ return (...args) => {
463
+ if (args.length === 0) {
464
+ return atom;
465
+ }
466
+ else {
467
+ atom = args[0];
468
+ }
469
+ };
470
+ }
471
+ export function createObj(fields) {
472
+ const obj = {};
473
+ for (const kv of fields) {
474
+ obj[kv[0]] = kv[1];
475
+ }
476
+ return obj;
477
+ }
478
+ export function jsOptions(mutator) {
479
+ const opts = {};
480
+ mutator(opts);
481
+ return opts;
482
+ }
483
+ export function round(value, digits = 0) {
484
+ const m = Math.pow(10, digits);
485
+ const n = +(digits ? value * m : value).toFixed(8);
486
+ const i = Math.floor(n);
487
+ const f = n - i;
488
+ const e = 1e-8;
489
+ const r = (f > 0.5 - e && f < 0.5 + e) ? ((i % 2 === 0) ? i : i + 1) : Math.round(n);
490
+ return digits ? r / m : r;
491
+ }
492
+ export function sign(x) {
493
+ return x > 0 ? 1 : x < 0 ? -1 : 0;
494
+ }
495
+ export function unescapeDataString(s) {
496
+ // https://stackoverflow.com/a/4458580/524236
497
+ return decodeURIComponent((s).replace(/\+/g, "%20"));
498
+ }
499
+ export function escapeDataString(s) {
500
+ return encodeURIComponent(s).replace(/!/g, "%21")
501
+ .replace(/'/g, "%27")
502
+ .replace(/\(/g, "%28")
503
+ .replace(/\)/g, "%29")
504
+ .replace(/\*/g, "%2A");
505
+ }
506
+ export function escapeUriString(s) {
507
+ return encodeURI(s);
508
+ }
509
+ // ICollection.Clear and Count members can be called on Arrays
510
+ // or Dictionaries so we need a runtime check (see #1120)
511
+ export function count(col) {
512
+ if (isArrayLike(col)) {
513
+ return col.length;
514
+ }
515
+ else {
516
+ let count = 0;
517
+ for (const _ of col) {
518
+ count++;
519
+ }
520
+ return count;
521
+ }
522
+ }
523
+ export function clear(col) {
524
+ if (isArrayLike(col)) {
525
+ col.splice(0);
526
+ }
527
+ else {
528
+ col.clear();
529
+ }
530
+ }
531
+ const curried = new WeakMap();
532
+ export function uncurry2(f) {
533
+ if (f == null) {
534
+ return null;
535
+ }
536
+ const f2 = (a1, a2) => f(a1)(a2);
537
+ curried.set(f2, f);
538
+ return f2;
539
+ }
540
+ export function curry2(f) {
541
+ return curried.get(f) ?? ((a1) => (a2) => f(a1, a2));
542
+ }
543
+ export function uncurry3(f) {
544
+ if (f == null) {
545
+ return null;
546
+ }
547
+ const f2 = (a1, a2, a3) => f(a1)(a2)(a3);
548
+ curried.set(f2, f);
549
+ return f2;
550
+ }
551
+ export function curry3(f) {
552
+ return curried.get(f)
553
+ ?? ((a1) => (a2) => (a3) => f(a1, a2, a3));
554
+ }
555
+ export function uncurry4(f) {
556
+ if (f == null) {
557
+ return null;
558
+ }
559
+ const f2 = (a1, a2, a3, a4) => f(a1)(a2)(a3)(a4);
560
+ curried.set(f2, f);
561
+ return f2;
562
+ }
563
+ export function curry4(f) {
564
+ return curried.get(f)
565
+ ?? ((a1) => (a2) => (a3) => (a4) => f(a1, a2, a3, a4));
566
+ }
567
+ export function uncurry5(f) {
568
+ if (f == null) {
569
+ return null;
570
+ }
571
+ const f2 = (a1, a2, a3, a4, a5) => f(a1)(a2)(a3)(a4)(a5);
572
+ curried.set(f2, f);
573
+ return f2;
574
+ }
575
+ export function curry5(f) {
576
+ return curried.get(f)
577
+ ?? ((a1) => (a2) => (a3) => (a4) => (a5) => f(a1, a2, a3, a4, a5));
578
+ }
579
+ export function uncurry6(f) {
580
+ if (f == null) {
581
+ return null;
582
+ }
583
+ const f2 = (a1, a2, a3, a4, a5, a6) => f(a1)(a2)(a3)(a4)(a5)(a6);
584
+ curried.set(f2, f);
585
+ return f2;
586
+ }
587
+ export function curry6(f) {
588
+ return curried.get(f)
589
+ ?? ((a1) => (a2) => (a3) => (a4) => (a5) => (a6) => f(a1, a2, a3, a4, a5, a6));
590
+ }
591
+ export function uncurry7(f) {
592
+ if (f == null) {
593
+ return null;
594
+ }
595
+ const f2 = (a1, a2, a3, a4, a5, a6, a7) => f(a1)(a2)(a3)(a4)(a5)(a6)(a7);
596
+ curried.set(f2, f);
597
+ return f2;
598
+ }
599
+ export function curry7(f) {
600
+ return curried.get(f)
601
+ ?? ((a1) => (a2) => (a3) => (a4) => (a5) => (a6) => (a7) => f(a1, a2, a3, a4, a5, a6, a7));
602
+ }
603
+ export function uncurry8(f) {
604
+ if (f == null) {
605
+ return null;
606
+ }
607
+ const f2 = (a1, a2, a3, a4, a5, a6, a7, a8) => f(a1)(a2)(a3)(a4)(a5)(a6)(a7)(a8);
608
+ curried.set(f2, f);
609
+ return f2;
610
+ }
611
+ export function curry8(f) {
612
+ return curried.get(f)
613
+ ?? ((a1) => (a2) => (a3) => (a4) => (a5) => (a6) => (a7) => (a8) => f(a1, a2, a3, a4, a5, a6, a7, a8));
614
+ }
615
+ export function uncurry9(f) {
616
+ if (f == null) {
617
+ return null;
618
+ }
619
+ const f2 = (a1, a2, a3, a4, a5, a6, a7, a8, a9) => f(a1)(a2)(a3)(a4)(a5)(a6)(a7)(a8)(a9);
620
+ curried.set(f2, f);
621
+ return f2;
622
+ }
623
+ export function curry9(f) {
624
+ return curried.get(f)
625
+ ?? ((a1) => (a2) => (a3) => (a4) => (a5) => (a6) => (a7) => (a8) => (a9) => f(a1, a2, a3, a4, a5, a6, a7, a8, a9));
626
+ }
627
+ export function uncurry10(f) {
628
+ if (f == null) {
629
+ return null;
630
+ }
631
+ const f2 = (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) => f(a1)(a2)(a3)(a4)(a5)(a6)(a7)(a8)(a9)(a10);
632
+ curried.set(f2, f);
633
+ return f2;
634
+ }
635
+ export function curry10(f) {
636
+ return curried.get(f)
637
+ ?? ((a1) => (a2) => (a3) => (a4) => (a5) => (a6) => (a7) => (a8) => (a9) => (a10) => f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10));
638
+ }
639
+ export function uncurry11(f) {
640
+ if (f == null) {
641
+ return null;
642
+ }
643
+ const f2 = (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) => f(a1)(a2)(a3)(a4)(a5)(a6)(a7)(a8)(a9)(a10)(a11);
644
+ curried.set(f2, f);
645
+ return f2;
646
+ }
647
+ export function curry11(f) {
648
+ return curried.get(f)
649
+ ?? ((a1) => (a2) => (a3) => (a4) => (a5) => (a6) => (a7) => (a8) => (a9) => (a10) => (a11) => f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11));
650
+ }
651
+ export function uncurry12(f) {
652
+ if (f == null) {
653
+ return null;
654
+ }
655
+ const f2 = (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) => f(a1)(a2)(a3)(a4)(a5)(a6)(a7)(a8)(a9)(a10)(a11)(a12);
656
+ curried.set(f2, f);
657
+ return f2;
658
+ }
659
+ export function curry12(f) {
660
+ return curried.get(f)
661
+ ?? ((a1) => (a2) => (a3) => (a4) => (a5) => (a6) => (a7) => (a8) => (a9) => (a10) => (a11) => (a12) => f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12));
662
+ }
663
+ export function uncurry13(f) {
664
+ if (f == null) {
665
+ return null;
666
+ }
667
+ const f2 = (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) => f(a1)(a2)(a3)(a4)(a5)(a6)(a7)(a8)(a9)(a10)(a11)(a12)(a13);
668
+ curried.set(f2, f);
669
+ return f2;
670
+ }
671
+ export function curry13(f) {
672
+ return curried.get(f)
673
+ ?? ((a1) => (a2) => (a3) => (a4) => (a5) => (a6) => (a7) => (a8) => (a9) => (a10) => (a11) => (a12) => (a13) => f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13));
674
+ }
675
+ export function uncurry14(f) {
676
+ if (f == null) {
677
+ return null;
678
+ }
679
+ const f2 = (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14) => f(a1)(a2)(a3)(a4)(a5)(a6)(a7)(a8)(a9)(a10)(a11)(a12)(a13)(a14);
680
+ curried.set(f2, f);
681
+ return f2;
682
+ }
683
+ export function curry14(f) {
684
+ return curried.get(f)
685
+ ?? ((a1) => (a2) => (a3) => (a4) => (a5) => (a6) => (a7) => (a8) => (a9) => (a10) => (a11) => (a12) => (a13) => (a14) => f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14));
686
+ }
687
+ export function uncurry15(f) {
688
+ if (f == null) {
689
+ return null;
690
+ }
691
+ const f2 = (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) => f(a1)(a2)(a3)(a4)(a5)(a6)(a7)(a8)(a9)(a10)(a11)(a12)(a13)(a14)(a15);
692
+ curried.set(f2, f);
693
+ return f2;
694
+ }
695
+ export function curry15(f) {
696
+ return curried.get(f)
697
+ ?? ((a1) => (a2) => (a3) => (a4) => (a5) => (a6) => (a7) => (a8) => (a9) => (a10) => (a11) => (a12) => (a13) => (a14) => (a15) => f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15));
698
+ }
699
+ export function uncurry16(f) {
700
+ if (f == null) {
701
+ return null;
702
+ }
703
+ const f2 = (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16) => f(a1)(a2)(a3)(a4)(a5)(a6)(a7)(a8)(a9)(a10)(a11)(a12)(a13)(a14)(a15)(a16);
704
+ curried.set(f2, f);
705
+ return f2;
706
+ }
707
+ export function curry16(f) {
708
+ return curried.get(f)
709
+ ?? ((a1) => (a2) => (a3) => (a4) => (a5) => (a6) => (a7) => (a8) => (a9) => (a10) => (a11) => (a12) => (a13) => (a14) => (a15) => (a16) => f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16));
710
+ }
711
+ export function uncurry17(f) {
712
+ if (f == null) {
713
+ return null;
714
+ }
715
+ const f2 = (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17) => f(a1)(a2)(a3)(a4)(a5)(a6)(a7)(a8)(a9)(a10)(a11)(a12)(a13)(a14)(a15)(a16)(a17);
716
+ curried.set(f2, f);
717
+ return f2;
718
+ }
719
+ export function curry17(f) {
720
+ return curried.get(f)
721
+ ?? ((a1) => (a2) => (a3) => (a4) => (a5) => (a6) => (a7) => (a8) => (a9) => (a10) => (a11) => (a12) => (a13) => (a14) => (a15) => (a16) => (a17) => f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17));
722
+ }
723
+ export function uncurry18(f) {
724
+ if (f == null) {
725
+ return null;
726
+ }
727
+ const f2 = (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18) => f(a1)(a2)(a3)(a4)(a5)(a6)(a7)(a8)(a9)(a10)(a11)(a12)(a13)(a14)(a15)(a16)(a17)(a18);
728
+ curried.set(f2, f);
729
+ return f2;
730
+ }
731
+ export function curry18(f) {
732
+ return curried.get(f)
733
+ ?? ((a1) => (a2) => (a3) => (a4) => (a5) => (a6) => (a7) => (a8) => (a9) => (a10) => (a11) => (a12) => (a13) => (a14) => (a15) => (a16) => (a17) => (a18) => f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18));
734
+ }
735
+ export function uncurry19(f) {
736
+ if (f == null) {
737
+ return null;
738
+ }
739
+ const f2 = (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19) => f(a1)(a2)(a3)(a4)(a5)(a6)(a7)(a8)(a9)(a10)(a11)(a12)(a13)(a14)(a15)(a16)(a17)(a18)(a19);
740
+ curried.set(f2, f);
741
+ return f2;
742
+ }
743
+ export function curry19(f) {
744
+ return curried.get(f)
745
+ ?? ((a1) => (a2) => (a3) => (a4) => (a5) => (a6) => (a7) => (a8) => (a9) => (a10) => (a11) => (a12) => (a13) => (a14) => (a15) => (a16) => (a17) => (a18) => (a19) => f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19));
746
+ }
747
+ export function uncurry20(f) {
748
+ if (f == null) {
749
+ return null;
750
+ }
751
+ const f2 = (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) => f(a1)(a2)(a3)(a4)(a5)(a6)(a7)(a8)(a9)(a10)(a11)(a12)(a13)(a14)(a15)(a16)(a17)(a18)(a19)(a20);
752
+ curried.set(f2, f);
753
+ return f2;
754
+ }
755
+ export function curry20(f) {
756
+ return curried.get(f)
757
+ ?? ((a1) => (a2) => (a3) => (a4) => (a5) => (a6) => (a7) => (a8) => (a9) => (a10) => (a11) => (a12) => (a13) => (a14) => (a15) => (a16) => (a17) => (a18) => (a19) => (a20) => f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20));
758
+ }
759
+ // More performant method to copy arrays, see #2352
760
+ export function copyToArray(source, sourceIndex, target, targetIndex, count) {
761
+ if (ArrayBuffer.isView(source) && ArrayBuffer.isView(target)) {
762
+ target.set(source.subarray(sourceIndex, sourceIndex + count), targetIndex);
763
+ }
764
+ else {
765
+ for (let i = 0; i < count; ++i) {
766
+ target[targetIndex + i] = source[sourceIndex + i];
767
+ }
768
+ }
769
+ }