@glutinum/cli 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/README.md +169 -1
  2. package/dist/Glutinum.Converter/FsharpAST.js +152 -20
  3. package/dist/Glutinum.Converter/FsharpAST.js.map +1 -1
  4. package/dist/Glutinum.Converter/Generate.js +17 -5
  5. package/dist/Glutinum.Converter/Generate.js.map +1 -1
  6. package/dist/Glutinum.Converter/GlueAST.js +97 -17
  7. package/dist/Glutinum.Converter/GlueAST.js.map +1 -1
  8. package/dist/Glutinum.Converter/Log.js +9 -5
  9. package/dist/Glutinum.Converter/Log.js.map +1 -1
  10. package/dist/Glutinum.Converter/Printer.js +486 -132
  11. package/dist/Glutinum.Converter/Printer.js.map +1 -1
  12. package/dist/Glutinum.Converter/Read.js +8 -5
  13. package/dist/Glutinum.Converter/Read.js.map +1 -1
  14. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +14 -6
  15. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js.map +1 -1
  16. package/dist/Glutinum.Converter/Reader/Declaration.js +50 -0
  17. package/dist/Glutinum.Converter/Reader/Declaration.js.map +1 -0
  18. package/dist/Glutinum.Converter/Reader/Documentation.js +119 -0
  19. package/dist/Glutinum.Converter/Reader/Documentation.js.map +1 -0
  20. package/dist/Glutinum.Converter/Reader/EnumDeclaration.js +13 -11
  21. package/dist/Glutinum.Converter/Reader/EnumDeclaration.js.map +1 -1
  22. package/dist/Glutinum.Converter/Reader/ExportAssignment.js +42 -0
  23. package/dist/Glutinum.Converter/Reader/ExportAssignment.js.map +1 -0
  24. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +15 -5
  25. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js.map +1 -1
  26. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +4 -2
  27. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js.map +1 -1
  28. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +3 -3
  29. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js.map +1 -1
  30. package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js +3 -3
  31. package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js.map +1 -1
  32. package/dist/Glutinum.Converter/Reader/Node.js +24 -10
  33. package/dist/Glutinum.Converter/Reader/Node.js.map +1 -1
  34. package/dist/Glutinum.Converter/Reader/Parameters.js +3 -3
  35. package/dist/Glutinum.Converter/Reader/Parameters.js.map +1 -1
  36. package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js +5 -5
  37. package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js.map +1 -1
  38. package/dist/Glutinum.Converter/Reader/TypeNode.js +151 -18
  39. package/dist/Glutinum.Converter/Reader/TypeNode.js.map +1 -1
  40. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +29 -20
  41. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js.map +1 -1
  42. package/dist/Glutinum.Converter/Reader/TypeParameters.js +2 -2
  43. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +102 -77
  44. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js.map +1 -1
  45. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +17 -11
  46. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js.map +1 -1
  47. package/dist/Glutinum.Converter/Reader/Utils.js +80 -5
  48. package/dist/Glutinum.Converter/Reader/Utils.js.map +1 -1
  49. package/dist/Glutinum.Converter/Reader/VariableStatement.js +14 -7
  50. package/dist/Glutinum.Converter/Reader/VariableStatement.js.map +1 -1
  51. package/dist/Glutinum.Converter/Transform.js +559 -193
  52. package/dist/Glutinum.Converter/Transform.js.map +1 -1
  53. package/dist/Glutinum.Converter/TypeScript.js +1 -1
  54. package/dist/Glutinum.Converter/Utils/Keywords.js +3 -3
  55. package/dist/Glutinum.Converter/Utils/List.js +62 -0
  56. package/dist/Glutinum.Converter/Utils/List.js.map +1 -0
  57. package/dist/Glutinum.Converter/Utils/Naming.js +73 -6
  58. package/dist/Glutinum.Converter/Utils/Naming.js.map +1 -1
  59. package/dist/Glutinum.Converter/Utils/String.js +6 -1
  60. package/dist/Glutinum.Converter/Utils/String.js.map +1 -1
  61. package/dist/Program.js +9 -10
  62. package/dist/Program.js.map +1 -1
  63. package/package.json +22 -3
  64. package/dist/Glutinum.Converter/Reader/NamedDeclaration.js +0 -34
  65. package/dist/Glutinum.Converter/Reader/NamedDeclaration.js.map +0 -1
  66. package/dist/Glutinum.Converter/Reader/Types.js +0 -16
  67. package/dist/Glutinum.Converter/Reader/Types.js.map +0 -1
  68. package/dist/fable_modules/fable-library.4.5.0/Array.d.ts +0 -120
  69. package/dist/fable_modules/fable-library.4.5.0/Array.js +0 -1204
  70. package/dist/fable_modules/fable-library.4.5.0/Async.d.ts +0 -32
  71. package/dist/fable_modules/fable-library.4.5.0/Async.js +0 -158
  72. package/dist/fable_modules/fable-library.4.5.0/AsyncBuilder.d.ts +0 -59
  73. package/dist/fable_modules/fable-library.4.5.0/AsyncBuilder.js +0 -183
  74. package/dist/fable_modules/fable-library.4.5.0/BigInt.d.ts +0 -115
  75. package/dist/fable_modules/fable-library.4.5.0/BigInt.js +0 -282
  76. package/dist/fable_modules/fable-library.4.5.0/BitConverter.d.ts +0 -27
  77. package/dist/fable_modules/fable-library.4.5.0/BitConverter.js +0 -138
  78. package/dist/fable_modules/fable-library.4.5.0/Boolean.d.ts +0 -3
  79. package/dist/fable_modules/fable-library.4.5.0/Boolean.js +0 -21
  80. package/dist/fable_modules/fable-library.4.5.0/CHANGELOG.md +0 -11
  81. package/dist/fable_modules/fable-library.4.5.0/Char.d.ts +0 -65
  82. package/dist/fable_modules/fable-library.4.5.0/Char.js +0 -169
  83. package/dist/fable_modules/fable-library.4.5.0/Choice.d.ts +0 -138
  84. package/dist/fable_modules/fable-library.4.5.0/Choice.js +0 -227
  85. package/dist/fable_modules/fable-library.4.5.0/Date.d.ts +0 -70
  86. package/dist/fable_modules/fable-library.4.5.0/Date.js +0 -451
  87. package/dist/fable_modules/fable-library.4.5.0/DateOffset.d.ts +0 -63
  88. package/dist/fable_modules/fable-library.4.5.0/DateOffset.js +0 -268
  89. package/dist/fable_modules/fable-library.4.5.0/DateOnly.d.ts +0 -18
  90. package/dist/fable_modules/fable-library.4.5.0/DateOnly.js +0 -124
  91. package/dist/fable_modules/fable-library.4.5.0/Decimal.d.ts +0 -45
  92. package/dist/fable_modules/fable-library.4.5.0/Decimal.js +0 -212
  93. package/dist/fable_modules/fable-library.4.5.0/Double.d.ts +0 -11
  94. package/dist/fable_modules/fable-library.4.5.0/Double.js +0 -46
  95. package/dist/fable_modules/fable-library.4.5.0/Encoding.d.ts +0 -12
  96. package/dist/fable_modules/fable-library.4.5.0/Encoding.js +0 -173
  97. package/dist/fable_modules/fable-library.4.5.0/Event.d.ts +0 -31
  98. package/dist/fable_modules/fable-library.4.5.0/Event.js +0 -93
  99. package/dist/fable_modules/fable-library.4.5.0/FSharp.Collections.d.ts +0 -7
  100. package/dist/fable_modules/fable-library.4.5.0/FSharp.Collections.js +0 -27
  101. package/dist/fable_modules/fable-library.4.5.0/FSharp.Core.d.ts +0 -17
  102. package/dist/fable_modules/fable-library.4.5.0/FSharp.Core.js +0 -69
  103. package/dist/fable_modules/fable-library.4.5.0/Global.d.ts +0 -24
  104. package/dist/fable_modules/fable-library.4.5.0/Global.js +0 -8
  105. package/dist/fable_modules/fable-library.4.5.0/Guid.d.ts +0 -10
  106. package/dist/fable_modules/fable-library.4.5.0/Guid.js +0 -142
  107. package/dist/fable_modules/fable-library.4.5.0/Int32.d.ts +0 -28
  108. package/dist/fable_modules/fable-library.4.5.0/Int32.js +0 -135
  109. package/dist/fable_modules/fable-library.4.5.0/List.d.ts +0 -143
  110. package/dist/fable_modules/fable-library.4.5.0/List.js +0 -1273
  111. package/dist/fable_modules/fable-library.4.5.0/Long.d.ts +0 -3
  112. package/dist/fable_modules/fable-library.4.5.0/Long.js +0 -46
  113. package/dist/fable_modules/fable-library.4.5.0/MailboxProcessor.d.ts +0 -25
  114. package/dist/fable_modules/fable-library.4.5.0/MailboxProcessor.js +0 -93
  115. package/dist/fable_modules/fable-library.4.5.0/Map.d.ts +0 -178
  116. package/dist/fable_modules/fable-library.4.5.0/Map.js +0 -1396
  117. package/dist/fable_modules/fable-library.4.5.0/MapUtil.d.ts +0 -10
  118. package/dist/fable_modules/fable-library.4.5.0/MapUtil.js +0 -112
  119. package/dist/fable_modules/fable-library.4.5.0/MutableMap.d.ts +0 -52
  120. package/dist/fable_modules/fable-library.4.5.0/MutableMap.js +0 -326
  121. package/dist/fable_modules/fable-library.4.5.0/MutableSet.d.ts +0 -39
  122. package/dist/fable_modules/fable-library.4.5.0/MutableSet.js +0 -232
  123. package/dist/fable_modules/fable-library.4.5.0/Native.d.ts +0 -2
  124. package/dist/fable_modules/fable-library.4.5.0/Native.js +0 -8
  125. package/dist/fable_modules/fable-library.4.5.0/Numeric.d.ts +0 -19
  126. package/dist/fable_modules/fable-library.4.5.0/Numeric.js +0 -71
  127. package/dist/fable_modules/fable-library.4.5.0/Observable.d.ts +0 -32
  128. package/dist/fable_modules/fable-library.4.5.0/Observable.js +0 -113
  129. package/dist/fable_modules/fable-library.4.5.0/Option.d.ts +0 -28
  130. package/dist/fable_modules/fable-library.4.5.0/Option.js +0 -96
  131. package/dist/fable_modules/fable-library.4.5.0/README.md +0 -3
  132. package/dist/fable_modules/fable-library.4.5.0/Random.d.ts +0 -37
  133. package/dist/fable_modules/fable-library.4.5.0/Random.js +0 -170
  134. package/dist/fable_modules/fable-library.4.5.0/Range.d.ts +0 -12
  135. package/dist/fable_modules/fable-library.4.5.0/Range.js +0 -45
  136. package/dist/fable_modules/fable-library.4.5.0/Reflection.d.ts +0 -119
  137. package/dist/fable_modules/fable-library.4.5.0/Reflection.js +0 -461
  138. package/dist/fable_modules/fable-library.4.5.0/RegExp.d.ts +0 -10
  139. package/dist/fable_modules/fable-library.4.5.0/RegExp.js +0 -132
  140. package/dist/fable_modules/fable-library.4.5.0/Seq.d.ts +0 -165
  141. package/dist/fable_modules/fable-library.4.5.0/Seq.js +0 -1379
  142. package/dist/fable_modules/fable-library.4.5.0/Seq2.d.ts +0 -18
  143. package/dist/fable_modules/fable-library.4.5.0/Seq2.js +0 -111
  144. package/dist/fable_modules/fable-library.4.5.0/Set.d.ts +0 -190
  145. package/dist/fable_modules/fable-library.4.5.0/Set.js +0 -1789
  146. package/dist/fable_modules/fable-library.4.5.0/String.d.ts +0 -49
  147. package/dist/fable_modules/fable-library.4.5.0/String.js +0 -540
  148. package/dist/fable_modules/fable-library.4.5.0/System.Collections.Generic.d.ts +0 -71
  149. package/dist/fable_modules/fable-library.4.5.0/System.Collections.Generic.js +0 -307
  150. package/dist/fable_modules/fable-library.4.5.0/System.Text.d.ts +0 -30
  151. package/dist/fable_modules/fable-library.4.5.0/System.Text.js +0 -110
  152. package/dist/fable_modules/fable-library.4.5.0/SystemException.d.ts +0 -5
  153. package/dist/fable_modules/fable-library.4.5.0/SystemException.js +0 -5
  154. package/dist/fable_modules/fable-library.4.5.0/TimeOnly.d.ts +0 -15
  155. package/dist/fable_modules/fable-library.4.5.0/TimeOnly.js +0 -122
  156. package/dist/fable_modules/fable-library.4.5.0/TimeSpan.d.ts +0 -34
  157. package/dist/fable_modules/fable-library.4.5.0/TimeSpan.js +0 -177
  158. package/dist/fable_modules/fable-library.4.5.0/Timer.d.ts +0 -19
  159. package/dist/fable_modules/fable-library.4.5.0/Timer.js +0 -67
  160. package/dist/fable_modules/fable-library.4.5.0/Types.d.ts +0 -58
  161. package/dist/fable_modules/fable-library.4.5.0/Types.js +0 -208
  162. package/dist/fable_modules/fable-library.4.5.0/Unicode.13.0.0.d.ts +0 -2
  163. package/dist/fable_modules/fable-library.4.5.0/Unicode.13.0.0.js +0 -4
  164. package/dist/fable_modules/fable-library.4.5.0/Uri.d.ts +0 -29
  165. package/dist/fable_modules/fable-library.4.5.0/Uri.js +0 -142
  166. package/dist/fable_modules/fable-library.4.5.0/Util.d.ts +0 -207
  167. package/dist/fable_modules/fable-library.4.5.0/Util.js +0 -781
  168. package/dist/fable_modules/fable-library.4.5.0/lib/big.d.ts +0 -5
  169. package/dist/fable_modules/fable-library.4.5.0/lib/big.js +0 -826
  170. package/dist/fable_modules/fable-library.4.5.0/package.json +0 -23
  171. package/dist/fable_modules/project_cracked.json +0 -1
@@ -1,232 +0,0 @@
1
- import { disposeSafe, defaultOf, toIterator, getEnumerator } from "./Util.js";
2
- import { iterate, map, iterateIndexed, concat } from "./Seq.js";
3
- import { some } from "./Option.js";
4
- import { FSharpRef } from "./Types.js";
5
- import { class_type } from "./Reflection.js";
6
- import { getItemFromDict, tryGetValue } from "./MapUtil.js";
7
- export class HashSet {
8
- constructor(items, comparer) {
9
- const this$ = new FSharpRef(defaultOf());
10
- this.comparer = comparer;
11
- this$.contents = this;
12
- this.hashMap = (new Map([]));
13
- this["init@9"] = 1;
14
- const enumerator = getEnumerator(items);
15
- try {
16
- while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
17
- const item = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
18
- HashSet__Add_2B595(this$.contents, item);
19
- }
20
- }
21
- finally {
22
- disposeSafe(enumerator);
23
- }
24
- }
25
- get [Symbol.toStringTag]() {
26
- return "HashSet";
27
- }
28
- toJSON() {
29
- const this$ = this;
30
- return Array.from(this$);
31
- }
32
- "System.Collections.IEnumerable.GetEnumerator"() {
33
- const this$ = this;
34
- return getEnumerator(this$);
35
- }
36
- GetEnumerator() {
37
- const this$ = this;
38
- return getEnumerator(concat(this$.hashMap.values()));
39
- }
40
- [Symbol.iterator]() {
41
- return toIterator(getEnumerator(this));
42
- }
43
- "System.Collections.Generic.ICollection`1.Add2B595"(item) {
44
- const this$ = this;
45
- HashSet__Add_2B595(this$, item);
46
- }
47
- "System.Collections.Generic.ICollection`1.Clear"() {
48
- const this$ = this;
49
- HashSet__Clear(this$);
50
- }
51
- "System.Collections.Generic.ICollection`1.Contains2B595"(item) {
52
- const this$ = this;
53
- return HashSet__Contains_2B595(this$, item);
54
- }
55
- "System.Collections.Generic.ICollection`1.CopyToZ3B4C077E"(array, arrayIndex) {
56
- const this$ = this;
57
- iterateIndexed((i, e) => {
58
- array[arrayIndex + i] = e;
59
- }, this$);
60
- }
61
- "System.Collections.Generic.ICollection`1.get_Count"() {
62
- const this$ = this;
63
- return HashSet__get_Count(this$) | 0;
64
- }
65
- "System.Collections.Generic.ICollection`1.get_IsReadOnly"() {
66
- return false;
67
- }
68
- "System.Collections.Generic.ICollection`1.Remove2B595"(item) {
69
- const this$ = this;
70
- return HashSet__Remove_2B595(this$, item);
71
- }
72
- get size() {
73
- const this$ = this;
74
- return HashSet__get_Count(this$) | 0;
75
- }
76
- add(k) {
77
- const this$ = this;
78
- HashSet__Add_2B595(this$, k);
79
- return this$;
80
- }
81
- clear() {
82
- const this$ = this;
83
- HashSet__Clear(this$);
84
- }
85
- delete(k) {
86
- const this$ = this;
87
- return HashSet__Remove_2B595(this$, k);
88
- }
89
- has(k) {
90
- const this$ = this;
91
- return HashSet__Contains_2B595(this$, k);
92
- }
93
- keys() {
94
- const this$ = this;
95
- return map((x) => x, this$);
96
- }
97
- values() {
98
- const this$ = this;
99
- return map((x) => x, this$);
100
- }
101
- entries() {
102
- const this$ = this;
103
- return map((v) => [v, v], this$);
104
- }
105
- forEach(f, thisArg) {
106
- const this$ = this;
107
- iterate((x) => {
108
- f(x, x, this$);
109
- }, this$);
110
- }
111
- }
112
- export function HashSet_$reflection(gen0) {
113
- return class_type("Fable.Collections.HashSet", [gen0], HashSet);
114
- }
115
- export function HashSet_$ctor_Z6150332D(items, comparer) {
116
- return new HashSet(items, comparer);
117
- }
118
- function HashSet__TryFindIndex_2B595(this$, k) {
119
- const h = this$.comparer.GetHashCode(k) | 0;
120
- let matchValue;
121
- let outArg = defaultOf();
122
- matchValue = [tryGetValue(this$.hashMap, h, new FSharpRef(() => outArg, (v) => {
123
- outArg = v;
124
- })), outArg];
125
- if (matchValue[0]) {
126
- return [true, h, matchValue[1].findIndex((v_1) => this$.comparer.Equals(k, v_1))];
127
- }
128
- else {
129
- return [false, h, -1];
130
- }
131
- }
132
- function HashSet__TryFind_2B595(this$, k) {
133
- const matchValue = HashSet__TryFindIndex_2B595(this$, k);
134
- let matchResult;
135
- if (matchValue[0]) {
136
- if (matchValue[2] > -1) {
137
- matchResult = 0;
138
- }
139
- else {
140
- matchResult = 1;
141
- }
142
- }
143
- else {
144
- matchResult = 1;
145
- }
146
- switch (matchResult) {
147
- case 0:
148
- return some(getItemFromDict(this$.hashMap, matchValue[1])[matchValue[2]]);
149
- default:
150
- return void 0;
151
- }
152
- }
153
- export function HashSet__get_Comparer(this$) {
154
- return this$.comparer;
155
- }
156
- export function HashSet__Clear(this$) {
157
- this$.hashMap.clear();
158
- }
159
- export function HashSet__get_Count(this$) {
160
- let count = 0;
161
- let enumerator = getEnumerator(this$.hashMap.values());
162
- try {
163
- while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
164
- const items = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
165
- count = ((count + items.length) | 0);
166
- }
167
- }
168
- finally {
169
- disposeSafe(enumerator);
170
- }
171
- return count | 0;
172
- }
173
- export function HashSet__Add_2B595(this$, k) {
174
- const matchValue = HashSet__TryFindIndex_2B595(this$, k);
175
- if (matchValue[0]) {
176
- if (matchValue[2] > -1) {
177
- return false;
178
- }
179
- else {
180
- const value = void (getItemFromDict(this$.hashMap, matchValue[1]).push(k));
181
- return true;
182
- }
183
- }
184
- else {
185
- this$.hashMap.set(matchValue[1], [k]);
186
- return true;
187
- }
188
- }
189
- export function HashSet__Contains_2B595(this$, k) {
190
- const matchValue = HashSet__TryFindIndex_2B595(this$, k);
191
- let matchResult;
192
- if (matchValue[0]) {
193
- if (matchValue[2] > -1) {
194
- matchResult = 0;
195
- }
196
- else {
197
- matchResult = 1;
198
- }
199
- }
200
- else {
201
- matchResult = 1;
202
- }
203
- switch (matchResult) {
204
- case 0:
205
- return true;
206
- default:
207
- return false;
208
- }
209
- }
210
- export function HashSet__Remove_2B595(this$, k) {
211
- const matchValue = HashSet__TryFindIndex_2B595(this$, k);
212
- let matchResult;
213
- if (matchValue[0]) {
214
- if (matchValue[2] > -1) {
215
- matchResult = 0;
216
- }
217
- else {
218
- matchResult = 1;
219
- }
220
- }
221
- else {
222
- matchResult = 1;
223
- }
224
- switch (matchResult) {
225
- case 0: {
226
- getItemFromDict(this$.hashMap, matchValue[1]).splice(matchValue[2], 1);
227
- return true;
228
- }
229
- default:
230
- return false;
231
- }
232
- }
@@ -1,2 +0,0 @@
1
- import { int32 } from "./Int32.js";
2
- export declare function Helpers_allocateArrayFromCons<T>(cons: any, len: int32): T[];
@@ -1,8 +0,0 @@
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
- }
@@ -1,19 +0,0 @@
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;
@@ -1,71 +0,0 @@
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
- }
@@ -1,32 +0,0 @@
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 {};
@@ -1,113 +0,0 @@
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
- }
@@ -1,28 +0,0 @@
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>;
@@ -1,96 +0,0 @@
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
- }
@@ -1,3 +0,0 @@
1
- # fable-library
2
-
3
- Core library used by F# projects compiled with [Fable](https://fable.io).
@@ -1,37 +0,0 @@
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;