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
@@ -0,0 +1,233 @@
1
+ import { disposeSafe, defaultOf, toIterator, getEnumerator } from "./Util.js";
2
+ import { iterate, map, iterateIndexed, concat } from "./Seq.js";
3
+ import { setItem } from "./Array.js";
4
+ import { some } from "./Option.js";
5
+ import { FSharpRef } from "./Types.js";
6
+ import { class_type } from "./Reflection.js";
7
+ import { getItemFromDict, tryGetValue } from "./MapUtil.js";
8
+ export class HashSet {
9
+ constructor(items, comparer) {
10
+ const this$ = new FSharpRef(defaultOf());
11
+ this.comparer = comparer;
12
+ this$.contents = this;
13
+ this.hashMap = (new Map([]));
14
+ this["init@9"] = 1;
15
+ const enumerator = getEnumerator(items);
16
+ try {
17
+ while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
18
+ const item = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
19
+ HashSet__Add_2B595(this$.contents, item);
20
+ }
21
+ }
22
+ finally {
23
+ disposeSafe(enumerator);
24
+ }
25
+ }
26
+ get [Symbol.toStringTag]() {
27
+ return "HashSet";
28
+ }
29
+ toJSON() {
30
+ const this$ = this;
31
+ return Array.from(this$);
32
+ }
33
+ "System.Collections.IEnumerable.GetEnumerator"() {
34
+ const this$ = this;
35
+ return getEnumerator(this$);
36
+ }
37
+ GetEnumerator() {
38
+ const this$ = this;
39
+ return getEnumerator(concat(this$.hashMap.values()));
40
+ }
41
+ [Symbol.iterator]() {
42
+ return toIterator(getEnumerator(this));
43
+ }
44
+ "System.Collections.Generic.ICollection`1.Add2B595"(item) {
45
+ const this$ = this;
46
+ HashSet__Add_2B595(this$, item);
47
+ }
48
+ "System.Collections.Generic.ICollection`1.Clear"() {
49
+ const this$ = this;
50
+ HashSet__Clear(this$);
51
+ }
52
+ "System.Collections.Generic.ICollection`1.Contains2B595"(item) {
53
+ const this$ = this;
54
+ return HashSet__Contains_2B595(this$, item);
55
+ }
56
+ "System.Collections.Generic.ICollection`1.CopyToZ3B4C077E"(array, arrayIndex) {
57
+ const this$ = this;
58
+ iterateIndexed((i, e) => {
59
+ setItem(array, arrayIndex + i, e);
60
+ }, this$);
61
+ }
62
+ "System.Collections.Generic.ICollection`1.get_Count"() {
63
+ const this$ = this;
64
+ return HashSet__get_Count(this$) | 0;
65
+ }
66
+ "System.Collections.Generic.ICollection`1.get_IsReadOnly"() {
67
+ return false;
68
+ }
69
+ "System.Collections.Generic.ICollection`1.Remove2B595"(item) {
70
+ const this$ = this;
71
+ return HashSet__Remove_2B595(this$, item);
72
+ }
73
+ get size() {
74
+ const this$ = this;
75
+ return HashSet__get_Count(this$) | 0;
76
+ }
77
+ add(k) {
78
+ const this$ = this;
79
+ HashSet__Add_2B595(this$, k);
80
+ return this$;
81
+ }
82
+ clear() {
83
+ const this$ = this;
84
+ HashSet__Clear(this$);
85
+ }
86
+ delete(k) {
87
+ const this$ = this;
88
+ return HashSet__Remove_2B595(this$, k);
89
+ }
90
+ has(k) {
91
+ const this$ = this;
92
+ return HashSet__Contains_2B595(this$, k);
93
+ }
94
+ keys() {
95
+ const this$ = this;
96
+ return map((x) => x, this$);
97
+ }
98
+ values() {
99
+ const this$ = this;
100
+ return map((x) => x, this$);
101
+ }
102
+ entries() {
103
+ const this$ = this;
104
+ return map((v) => [v, v], this$);
105
+ }
106
+ forEach(f, thisArg) {
107
+ const this$ = this;
108
+ iterate((x) => {
109
+ f(x, x, this$);
110
+ }, this$);
111
+ }
112
+ }
113
+ export function HashSet_$reflection(gen0) {
114
+ return class_type("Fable.Collections.HashSet", [gen0], HashSet);
115
+ }
116
+ export function HashSet_$ctor_Z6150332D(items, comparer) {
117
+ return new HashSet(items, comparer);
118
+ }
119
+ function HashSet__TryFindIndex_2B595(this$, k) {
120
+ const h = this$.comparer.GetHashCode(k) | 0;
121
+ let matchValue;
122
+ let outArg = defaultOf();
123
+ matchValue = [tryGetValue(this$.hashMap, h, new FSharpRef(() => outArg, (v) => {
124
+ outArg = v;
125
+ })), outArg];
126
+ if (matchValue[0]) {
127
+ return [true, h, matchValue[1].findIndex((v_1) => this$.comparer.Equals(k, v_1))];
128
+ }
129
+ else {
130
+ return [false, h, -1];
131
+ }
132
+ }
133
+ function HashSet__TryFind_2B595(this$, k) {
134
+ const matchValue = HashSet__TryFindIndex_2B595(this$, k);
135
+ let matchResult;
136
+ if (matchValue[0]) {
137
+ if (matchValue[2] > -1) {
138
+ matchResult = 0;
139
+ }
140
+ else {
141
+ matchResult = 1;
142
+ }
143
+ }
144
+ else {
145
+ matchResult = 1;
146
+ }
147
+ switch (matchResult) {
148
+ case 0:
149
+ return some(getItemFromDict(this$.hashMap, matchValue[1])[matchValue[2]]);
150
+ default:
151
+ return undefined;
152
+ }
153
+ }
154
+ export function HashSet__get_Comparer(this$) {
155
+ return this$.comparer;
156
+ }
157
+ export function HashSet__Clear(this$) {
158
+ this$.hashMap.clear();
159
+ }
160
+ export function HashSet__get_Count(this$) {
161
+ let count = 0;
162
+ let enumerator = getEnumerator(this$.hashMap.values());
163
+ try {
164
+ while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
165
+ const items = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
166
+ count = ((count + items.length) | 0);
167
+ }
168
+ }
169
+ finally {
170
+ disposeSafe(enumerator);
171
+ }
172
+ return count | 0;
173
+ }
174
+ export function HashSet__Add_2B595(this$, k) {
175
+ const matchValue = HashSet__TryFindIndex_2B595(this$, k);
176
+ if (matchValue[0]) {
177
+ if (matchValue[2] > -1) {
178
+ return false;
179
+ }
180
+ else {
181
+ const value = void (getItemFromDict(this$.hashMap, matchValue[1]).push(k));
182
+ return true;
183
+ }
184
+ }
185
+ else {
186
+ this$.hashMap.set(matchValue[1], [k]);
187
+ return true;
188
+ }
189
+ }
190
+ export function HashSet__Contains_2B595(this$, k) {
191
+ const matchValue = HashSet__TryFindIndex_2B595(this$, k);
192
+ let matchResult;
193
+ if (matchValue[0]) {
194
+ if (matchValue[2] > -1) {
195
+ matchResult = 0;
196
+ }
197
+ else {
198
+ matchResult = 1;
199
+ }
200
+ }
201
+ else {
202
+ matchResult = 1;
203
+ }
204
+ switch (matchResult) {
205
+ case 0:
206
+ return true;
207
+ default:
208
+ return false;
209
+ }
210
+ }
211
+ export function HashSet__Remove_2B595(this$, k) {
212
+ const matchValue = HashSet__TryFindIndex_2B595(this$, k);
213
+ let matchResult;
214
+ if (matchValue[0]) {
215
+ if (matchValue[2] > -1) {
216
+ matchResult = 0;
217
+ }
218
+ else {
219
+ matchResult = 1;
220
+ }
221
+ }
222
+ else {
223
+ matchResult = 1;
224
+ }
225
+ switch (matchResult) {
226
+ case 0: {
227
+ getItemFromDict(this$.hashMap, matchValue[1]).splice(matchValue[2], 1);
228
+ return true;
229
+ }
230
+ default:
231
+ return false;
232
+ }
233
+ }
@@ -0,0 +1,2 @@
1
+ import { int32 } from "./Int32.js";
2
+ export declare function Helpers_allocateArrayFromCons<T>(cons: any, len: int32): T[];
@@ -0,0 +1,8 @@
1
+ export function Helpers_allocateArrayFromCons(cons, len) {
2
+ if ((typeof cons) === "function") {
3
+ return new cons(len);
4
+ }
5
+ else {
6
+ return new Array(len);
7
+ }
8
+ }
@@ -0,0 +1,19 @@
1
+ import { IComparable } from "./Util.js";
2
+ export declare const symbol: unique symbol;
3
+ export interface CustomNumeric extends IComparable<Numeric> {
4
+ [symbol](): {
5
+ multiply(y: Numeric): Numeric;
6
+ toPrecision(sd?: number): string;
7
+ toExponential(dp?: number): string;
8
+ toFixed(dp?: number): string;
9
+ toHex(): string;
10
+ };
11
+ }
12
+ export type Numeric = number | bigint | CustomNumeric;
13
+ export declare function isNumeric(x: any): any;
14
+ export declare function compare(x: Numeric, y: number): number;
15
+ export declare function multiply(x: Numeric, y: number): Numeric;
16
+ export declare function toFixed(x: Numeric, dp?: number): string | bigint;
17
+ export declare function toPrecision(x: Numeric, sd?: number): string | bigint;
18
+ export declare function toExponential(x: Numeric, dp?: number): string | bigint;
19
+ export declare function toHex(x: Numeric): string;
@@ -0,0 +1,71 @@
1
+ export const symbol = Symbol("numeric");
2
+ export function isNumeric(x) {
3
+ return typeof x === "number" || typeof x === "bigint" || x?.[symbol];
4
+ }
5
+ export function compare(x, y) {
6
+ if (typeof x === "number") {
7
+ return x < y ? -1 : (x > y ? 1 : 0);
8
+ }
9
+ else if (typeof x === "bigint") {
10
+ return x < y ? -1 : (x > y ? 1 : 0);
11
+ }
12
+ else {
13
+ return x.CompareTo(y);
14
+ }
15
+ }
16
+ export function multiply(x, y) {
17
+ if (typeof x === "number") {
18
+ return x * y;
19
+ }
20
+ else if (typeof x === "bigint") {
21
+ return x * BigInt(y);
22
+ }
23
+ else {
24
+ return x[symbol]().multiply(y);
25
+ }
26
+ }
27
+ export function toFixed(x, dp) {
28
+ if (typeof x === "number") {
29
+ return x.toFixed(dp);
30
+ }
31
+ else if (typeof x === "bigint") {
32
+ return x;
33
+ }
34
+ else {
35
+ return x[symbol]().toFixed(dp);
36
+ }
37
+ }
38
+ export function toPrecision(x, sd) {
39
+ if (typeof x === "number") {
40
+ return x.toPrecision(sd);
41
+ }
42
+ else if (typeof x === "bigint") {
43
+ return x;
44
+ }
45
+ else {
46
+ return x[symbol]().toPrecision(sd);
47
+ }
48
+ }
49
+ export function toExponential(x, dp) {
50
+ if (typeof x === "number") {
51
+ return x.toExponential(dp);
52
+ }
53
+ else if (typeof x === "bigint") {
54
+ return x;
55
+ }
56
+ else {
57
+ return x[symbol]().toExponential(dp);
58
+ }
59
+ }
60
+ export function toHex(x) {
61
+ if (typeof x === "number") {
62
+ return (Number(x) >>> 0).toString(16);
63
+ }
64
+ else if (typeof x === "bigint") {
65
+ // TODO: properly handle other bit sizes
66
+ return BigInt.asUintN(64, x).toString(16);
67
+ }
68
+ else {
69
+ return x[symbol]().toHex();
70
+ }
71
+ }
@@ -0,0 +1,32 @@
1
+ import { FSharpChoice$2_$union } from "./Choice.js";
2
+ import { Option } from "./Option.js";
3
+ import { IDisposable } from "./Util.js";
4
+ export interface IObserver<T> {
5
+ OnNext: (x: T) => void;
6
+ OnError: (e: any) => void;
7
+ OnCompleted: () => void;
8
+ }
9
+ export declare class Observer<T> implements IObserver<T> {
10
+ OnNext: (x: T) => void;
11
+ OnError: (e: any) => void;
12
+ OnCompleted: () => void;
13
+ constructor(onNext: (x: T) => void, onError?: (e: any) => void, onCompleted?: () => void);
14
+ }
15
+ export interface IObservable<T> {
16
+ Subscribe: (o: IObserver<T>) => IDisposable;
17
+ }
18
+ declare class Observable<T> implements IObservable<T> {
19
+ Subscribe: (o: IObserver<T>) => IDisposable;
20
+ constructor(subscribe: (o: IObserver<T>) => IDisposable);
21
+ }
22
+ export declare function add<T>(callback: (x: T) => void, source: IObservable<T>): void;
23
+ export declare function choose<T, U>(chooser: (x: T) => Option<U>, source: IObservable<T>): Observable<U>;
24
+ export declare function filter<T>(predicate: (x: T) => boolean, source: IObservable<T>): IObservable<T>;
25
+ export declare function map<T, U>(mapping: (x: T) => U, source: IObservable<T>): IObservable<U>;
26
+ export declare function merge<T>(source1: IObservable<T>, source2: IObservable<T>): IObservable<T>;
27
+ export declare function pairwise<T>(source: IObservable<T>): IObservable<[T, T]>;
28
+ export declare function partition<T>(predicate: (x: T) => boolean, source: IObservable<T>): [Observable<T>, Observable<T>];
29
+ export declare function scan<U, T>(collector: (u: U, t: T) => U, state: U, source: IObservable<T>): IObservable<U>;
30
+ export declare function split<T, U1, U2>(splitter: (x: T) => FSharpChoice$2_$union<U1, U2>, source: IObservable<T>): [Observable<U1>, Observable<U2>];
31
+ export declare function subscribe<T>(callback: (x: T) => void, source: IObservable<T>): IDisposable;
32
+ export {};
@@ -0,0 +1,113 @@
1
+ import { Choice_tryValueIfChoice1Of2, Choice_tryValueIfChoice2Of2 } from "./Choice.js";
2
+ import { value } from "./Option.js";
3
+ export class Observer {
4
+ constructor(onNext, onError, onCompleted) {
5
+ this.OnNext = onNext;
6
+ this.OnError = onError || ((_e) => { return; });
7
+ this.OnCompleted = onCompleted || (() => { return; });
8
+ }
9
+ }
10
+ class Observable {
11
+ constructor(subscribe) {
12
+ this.Subscribe = subscribe;
13
+ }
14
+ }
15
+ function protect(f, succeed, fail) {
16
+ try {
17
+ return succeed(f());
18
+ }
19
+ catch (e) {
20
+ fail(e);
21
+ }
22
+ }
23
+ export function add(callback, source) {
24
+ source.Subscribe(new Observer(callback));
25
+ }
26
+ export function choose(chooser, source) {
27
+ return new Observable((observer) => source.Subscribe(new Observer((t) => protect(() => chooser(t), (u) => { if (u != null) {
28
+ observer.OnNext(value(u));
29
+ } }, observer.OnError), observer.OnError, observer.OnCompleted)));
30
+ }
31
+ export function filter(predicate, source) {
32
+ return choose((x) => predicate(x) ? x : void 0, source);
33
+ }
34
+ export function map(mapping, source) {
35
+ return new Observable((observer) => source.Subscribe(new Observer((t) => {
36
+ protect(() => mapping(t), observer.OnNext, observer.OnError);
37
+ }, observer.OnError, observer.OnCompleted)));
38
+ }
39
+ export function merge(source1, source2) {
40
+ return new Observable((observer) => {
41
+ let stopped = false;
42
+ let completed1 = false;
43
+ let completed2 = false;
44
+ const h1 = source1.Subscribe(new Observer((v) => { if (!stopped) {
45
+ observer.OnNext(v);
46
+ } }, (e) => {
47
+ if (!stopped) {
48
+ stopped = true;
49
+ observer.OnError(e);
50
+ }
51
+ }, () => {
52
+ if (!stopped) {
53
+ completed1 = true;
54
+ if (completed2) {
55
+ stopped = true;
56
+ observer.OnCompleted();
57
+ }
58
+ }
59
+ }));
60
+ const h2 = source2.Subscribe(new Observer((v) => { if (!stopped) {
61
+ observer.OnNext(v);
62
+ } }, (e) => {
63
+ if (!stopped) {
64
+ stopped = true;
65
+ observer.OnError(e);
66
+ }
67
+ }, () => {
68
+ if (!stopped) {
69
+ completed2 = true;
70
+ if (completed1) {
71
+ stopped = true;
72
+ observer.OnCompleted();
73
+ }
74
+ }
75
+ }));
76
+ return {
77
+ Dispose() {
78
+ h1.Dispose();
79
+ h2.Dispose();
80
+ },
81
+ };
82
+ });
83
+ }
84
+ export function pairwise(source) {
85
+ return new Observable((observer) => {
86
+ let last;
87
+ return source.Subscribe(new Observer((next) => {
88
+ if (last != null) {
89
+ observer.OnNext([last, next]);
90
+ }
91
+ last = next;
92
+ }, observer.OnError, observer.OnCompleted));
93
+ });
94
+ }
95
+ export function partition(predicate, source) {
96
+ return [filter(predicate, source), filter((x) => !predicate(x), source)];
97
+ }
98
+ export function scan(collector, state, source) {
99
+ return new Observable((observer) => {
100
+ return source.Subscribe(new Observer((t) => {
101
+ protect(() => collector(state, t), (u) => { state = u; observer.OnNext(u); }, observer.OnError);
102
+ }, observer.OnError, observer.OnCompleted));
103
+ });
104
+ }
105
+ export function split(splitter, source) {
106
+ return [
107
+ choose((v) => Choice_tryValueIfChoice1Of2(splitter(v)), source),
108
+ choose((v) => Choice_tryValueIfChoice2Of2(splitter(v)), source)
109
+ ];
110
+ }
111
+ export function subscribe(callback, source) {
112
+ return source.Subscribe(new Observer(callback));
113
+ }
@@ -0,0 +1,28 @@
1
+ export type Nullable<T> = T | null | undefined;
2
+ export type Option<T> = T | Some<T> | undefined;
3
+ export declare class Some<T> {
4
+ value: T;
5
+ constructor(value: T);
6
+ toJSON(): T;
7
+ toString(): string;
8
+ GetHashCode(): number;
9
+ Equals(other: Option<T>): boolean;
10
+ CompareTo(other: Option<T>): number;
11
+ }
12
+ export declare function value<T>(x: Option<T>): T;
13
+ export declare function unwrap<T>(opt: Option<T>): T | undefined;
14
+ export declare function some<T>(x: T): Option<T>;
15
+ export declare function ofNullable<T>(x: Nullable<T>): Option<T>;
16
+ export declare function toNullable<T>(x: Option<T>): Nullable<T>;
17
+ export declare function flatten<T>(x: Option<Option<T>>): T | Some<T> | undefined;
18
+ export declare function toArray<T>(opt: Option<T>): T[];
19
+ export declare function defaultArg<T>(opt: Option<T>, defaultValue: T): T;
20
+ export declare function defaultArgWith<T>(opt: Option<T>, defThunk: () => T): T;
21
+ export declare function orElse<T>(opt: Option<T>, ifNone: Option<T>): Option<T>;
22
+ export declare function orElseWith<T>(opt: Option<T>, ifNoneThunk: () => Option<T>): Option<T>;
23
+ export declare function filter<T>(predicate: (arg: T) => boolean, opt: Option<T>): Option<T>;
24
+ export declare function map<T, U>(mapping: (arg: T) => U, opt: Option<T>): Option<U>;
25
+ export declare function map2<T1, T2, U>(mapping: (arg1: T1, arg2: T2) => Option<U>, opt1: Option<T1>, opt2: Option<T2>): Option<U>;
26
+ export declare function map3<T1, T2, T3, U>(mapping: (arg1: T1, arg2: T2, arg3: T3) => Option<U>, opt1: Option<T1>, opt2: Option<T2>, opt3: Option<T3>): Option<U>;
27
+ export declare function bind<T, U>(binder: (arg: T) => Option<U>, opt: Option<T>): Option<U>;
28
+ export declare function tryOp<T, U>(op: (x: T) => U, arg: T): Option<U>;
@@ -0,0 +1,96 @@
1
+ import { structuralHash, equals, compare } from "./Util.js";
2
+ // Using a class here for better compatibility with TS files importing Some
3
+ export class Some {
4
+ constructor(value) {
5
+ this.value = value;
6
+ }
7
+ toJSON() {
8
+ return this.value;
9
+ }
10
+ // Don't add "Some" for consistency with erased options
11
+ toString() {
12
+ return String(this.value);
13
+ }
14
+ GetHashCode() {
15
+ return structuralHash(this.value);
16
+ }
17
+ Equals(other) {
18
+ if (other == null) {
19
+ return false;
20
+ }
21
+ else {
22
+ return equals(this.value, other instanceof Some ? other.value : other);
23
+ }
24
+ }
25
+ CompareTo(other) {
26
+ if (other == null) {
27
+ return 1;
28
+ }
29
+ else {
30
+ return compare(this.value, other instanceof Some ? other.value : other);
31
+ }
32
+ }
33
+ }
34
+ export function value(x) {
35
+ if (x == null) {
36
+ throw new Error("Option has no value");
37
+ }
38
+ else {
39
+ return x instanceof Some ? x.value : x;
40
+ }
41
+ }
42
+ export function unwrap(opt) {
43
+ return opt instanceof Some ? opt.value : opt;
44
+ }
45
+ export function some(x) {
46
+ return x == null || x instanceof Some ? new Some(x) : x;
47
+ }
48
+ export function ofNullable(x) {
49
+ // This will fail with unit probably, an alternative would be:
50
+ // return x === null ? undefined : (x === undefined ? new Some(x) : x);
51
+ return x == null ? undefined : x;
52
+ }
53
+ export function toNullable(x) {
54
+ return x == null ? null : value(x);
55
+ }
56
+ export function flatten(x) {
57
+ return x == null ? undefined : value(x);
58
+ }
59
+ export function toArray(opt) {
60
+ return (opt == null) ? [] : [value(opt)];
61
+ }
62
+ export function defaultArg(opt, defaultValue) {
63
+ return (opt != null) ? value(opt) : defaultValue;
64
+ }
65
+ export function defaultArgWith(opt, defThunk) {
66
+ return (opt != null) ? value(opt) : defThunk();
67
+ }
68
+ export function orElse(opt, ifNone) {
69
+ return opt == null ? ifNone : opt;
70
+ }
71
+ export function orElseWith(opt, ifNoneThunk) {
72
+ return opt == null ? ifNoneThunk() : opt;
73
+ }
74
+ export function filter(predicate, opt) {
75
+ return (opt != null) ? (predicate(value(opt)) ? opt : undefined) : opt;
76
+ }
77
+ export function map(mapping, opt) {
78
+ return (opt != null) ? some(mapping(value(opt))) : undefined;
79
+ }
80
+ export function map2(mapping, opt1, opt2) {
81
+ return (opt1 != null && opt2 != null) ? mapping(value(opt1), value(opt2)) : undefined;
82
+ }
83
+ export function map3(mapping, opt1, opt2, opt3) {
84
+ return (opt1 != null && opt2 != null && opt3 != null) ? mapping(value(opt1), value(opt2), value(opt3)) : undefined;
85
+ }
86
+ export function bind(binder, opt) {
87
+ return opt != null ? binder(value(opt)) : undefined;
88
+ }
89
+ export function tryOp(op, arg) {
90
+ try {
91
+ return some(op(arg));
92
+ }
93
+ catch {
94
+ return undefined;
95
+ }
96
+ }
@@ -0,0 +1,3 @@
1
+ # fable-library
2
+
3
+ Core library used by F# projects compiled with [Fable](https://fable.io).
@@ -0,0 +1,37 @@
1
+ import { uint8, int32, float64 } from "./Int32.js";
2
+ import { TypeInfo } from "./Reflection.js";
3
+ export interface IRandom {
4
+ Next0(): int32;
5
+ Next1(maxValue: int32): int32;
6
+ Next2(minValue: int32, maxValue: int32): int32;
7
+ NextBytes(buffer: uint8[]): void;
8
+ NextDouble(): float64;
9
+ }
10
+ export declare class NonSeeded implements IRandom {
11
+ constructor();
12
+ Next0(): int32;
13
+ Next1(maxValue: int32): int32;
14
+ Next2(minValue: int32, maxValue: int32): int32;
15
+ NextDouble(): float64;
16
+ NextBytes(buffer: uint8[]): void;
17
+ }
18
+ export declare function NonSeeded_$reflection(): TypeInfo;
19
+ export declare function NonSeeded_$ctor(): NonSeeded;
20
+ export declare class Seeded implements IRandom {
21
+ readonly MBIG: int32;
22
+ inext: int32;
23
+ inextp: int32;
24
+ seedArray: int32[];
25
+ constructor(seed: int32);
26
+ Next0(): int32;
27
+ Next1(maxValue: int32): int32;
28
+ Next2(minValue: int32, maxValue: int32): int32;
29
+ NextDouble(): float64;
30
+ NextBytes(buffer: uint8[]): void;
31
+ }
32
+ export declare function Seeded_$reflection(): TypeInfo;
33
+ export declare function Seeded_$ctor_Z524259A4(seed: int32): Seeded;
34
+ export declare function Seeded__Sample(this$: Seeded): float64;
35
+ export declare function Seeded__GetSampleForLargeRange(this$: Seeded): float64;
36
+ export declare function nonSeeded(): NonSeeded;
37
+ export declare function seeded(seed: int32): Seeded;