@glutinum/cli 0.14.0 → 0.14.1

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 (144) hide show
  1. package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs +89 -0
  2. package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs.js +105 -0
  3. package/dist/fable_modules/Fable.Promise.3.2.1/Fable.Promise.fableproj +25 -0
  4. package/dist/fable_modules/Fable.Promise.3.2.1/Promise.fs +842 -0
  5. package/dist/fable_modules/Fable.Promise.3.2.1/Promise.fs.js +232 -0
  6. package/dist/fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs +31 -0
  7. package/dist/fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs.js +20 -0
  8. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs +235 -0
  9. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs.js +384 -0
  10. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AssemblyInfo.fs +19 -0
  11. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Async.fs +287 -0
  12. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Async.fs.js +128 -0
  13. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOption.fs +127 -0
  14. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionCE.fs +174 -0
  15. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionCE.fs.js +37 -0
  16. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionOp.fs +24 -0
  17. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResult.fs +483 -0
  18. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultCE.fs +201 -0
  19. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultCE.fs.js +18 -0
  20. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOp.fs +24 -0
  21. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs +87 -0
  22. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs.js +26 -0
  23. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionCE.fs +236 -0
  24. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionCE.fs.js +18 -0
  25. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionOp.fs +24 -0
  26. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidation.fs +185 -0
  27. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationCE.fs +186 -0
  28. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationCE.fs.js +18 -0
  29. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationOp.fs +35 -0
  30. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/FsToolkit.ErrorHandling.fableproj +69 -0
  31. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/List.fs +276 -0
  32. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/List.fs.js +364 -0
  33. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Nullness.fs +81 -0
  34. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Option.fs +462 -0
  35. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs +139 -0
  36. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs.js +48 -0
  37. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionOp.fs +21 -0
  38. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs +88 -0
  39. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs.js +30 -0
  40. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs +200 -0
  41. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs.js +18 -0
  42. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidation.fs +34 -0
  43. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs +244 -0
  44. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs.js +18 -0
  45. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Result.fs +731 -0
  46. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Result.fs.js +45 -0
  47. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultCE.fs +140 -0
  48. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultCE.fs.js +23 -0
  49. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOp.fs +45 -0
  50. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOption.fs +201 -0
  51. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOption.fs.js +65 -0
  52. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionCE.fs +135 -0
  53. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionCE.fs.js +18 -0
  54. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionOp.fs +57 -0
  55. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs +503 -0
  56. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs.js +295 -0
  57. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Validation.fs +167 -0
  58. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationCE.fs +142 -0
  59. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationCE.fs.js +18 -0
  60. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationOp.fs +35 -0
  61. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueOption.fs +148 -0
  62. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOption.fs +102 -0
  63. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOptionCE.fs +587 -0
  64. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOptionOp.fs +10 -0
  65. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Debug/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +3 -0
  66. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Debug/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  67. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.fs +3 -0
  68. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/net9.0/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  69. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.fs +3 -0
  70. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.0/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  71. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +3 -0
  72. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  73. package/dist/fable_modules/fable-library-js.5.17.2/Array.js +1348 -0
  74. package/dist/fable_modules/fable-library-js.5.17.2/Async.js +163 -0
  75. package/dist/fable_modules/fable-library-js.5.17.2/AsyncBuilder.js +204 -0
  76. package/dist/fable_modules/fable-library-js.5.17.2/BigInt.js +307 -0
  77. package/dist/fable_modules/fable-library-js.5.17.2/BitConverter.js +138 -0
  78. package/dist/fable_modules/fable-library-js.5.17.2/Boolean.js +22 -0
  79. package/dist/fable_modules/fable-library-js.5.17.2/CHANGELOG.md +348 -0
  80. package/dist/fable_modules/fable-library-js.5.17.2/Char.js +202 -0
  81. package/dist/fable_modules/fable-library-js.5.17.2/Choice.js +184 -0
  82. package/dist/fable_modules/fable-library-js.5.17.2/CollectionUtil.js +182 -0
  83. package/dist/fable_modules/fable-library-js.5.17.2/ConditionalWeakTable.js +21 -0
  84. package/dist/fable_modules/fable-library-js.5.17.2/Date.js +834 -0
  85. package/dist/fable_modules/fable-library-js.5.17.2/DateOffset.js +252 -0
  86. package/dist/fable_modules/fable-library-js.5.17.2/DateOnly.js +124 -0
  87. package/dist/fable_modules/fable-library-js.5.17.2/DateOnlyTemporal.js +146 -0
  88. package/dist/fable_modules/fable-library-js.5.17.2/DateTimeFormat.js +523 -0
  89. package/dist/fable_modules/fable-library-js.5.17.2/DateTimeOffsetTemporal.js +283 -0
  90. package/dist/fable_modules/fable-library-js.5.17.2/DateTimeTemporal.js +243 -0
  91. package/dist/fable_modules/fable-library-js.5.17.2/Decimal.js +238 -0
  92. package/dist/fable_modules/fable-library-js.5.17.2/Directory.js +11 -0
  93. package/dist/fable_modules/fable-library-js.5.17.2/Double.js +53 -0
  94. package/dist/fable_modules/fable-library-js.5.17.2/Encoding.js +185 -0
  95. package/dist/fable_modules/fable-library-js.5.17.2/Environment.js +3 -0
  96. package/dist/fable_modules/fable-library-js.5.17.2/Event.js +102 -0
  97. package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Collections.js +45 -0
  98. package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Core.CompilerServices.js +27 -0
  99. package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Core.js +156 -0
  100. package/dist/fable_modules/fable-library-js.5.17.2/File.js +27 -0
  101. package/dist/fable_modules/fable-library-js.5.17.2/Global.js +29 -0
  102. package/dist/fable_modules/fable-library-js.5.17.2/Guid.js +163 -0
  103. package/dist/fable_modules/fable-library-js.5.17.2/Int32.js +135 -0
  104. package/dist/fable_modules/fable-library-js.5.17.2/List.js +1337 -0
  105. package/dist/fable_modules/fable-library-js.5.17.2/Long.js +38 -0
  106. package/dist/fable_modules/fable-library-js.5.17.2/MailboxProcessor.js +100 -0
  107. package/dist/fable_modules/fable-library-js.5.17.2/Map.js +1400 -0
  108. package/dist/fable_modules/fable-library-js.5.17.2/MapUtil.js +130 -0
  109. package/dist/fable_modules/fable-library-js.5.17.2/MutableMap.js +339 -0
  110. package/dist/fable_modules/fable-library-js.5.17.2/MutableSet.js +233 -0
  111. package/dist/fable_modules/fable-library-js.5.17.2/Native.js +14 -0
  112. package/dist/fable_modules/fable-library-js.5.17.2/Numeric.js +112 -0
  113. package/dist/fable_modules/fable-library-js.5.17.2/Observable.js +115 -0
  114. package/dist/fable_modules/fable-library-js.5.17.2/Option.js +87 -0
  115. package/dist/fable_modules/fable-library-js.5.17.2/Path.js +31 -0
  116. package/dist/fable_modules/fable-library-js.5.17.2/README.md +3 -0
  117. package/dist/fable_modules/fable-library-js.5.17.2/Random.js +172 -0
  118. package/dist/fable_modules/fable-library-js.5.17.2/Range.js +45 -0
  119. package/dist/fable_modules/fable-library-js.5.17.2/Reflection.js +489 -0
  120. package/dist/fable_modules/fable-library-js.5.17.2/RegExp.js +170 -0
  121. package/dist/fable_modules/fable-library-js.5.17.2/Result.js +165 -0
  122. package/dist/fable_modules/fable-library-js.5.17.2/Seq.js +1504 -0
  123. package/dist/fable_modules/fable-library-js.5.17.2/Seq2.js +111 -0
  124. package/dist/fable_modules/fable-library-js.5.17.2/Set.js +1829 -0
  125. package/dist/fable_modules/fable-library-js.5.17.2/String.js +731 -0
  126. package/dist/fable_modules/fable-library-js.5.17.2/System.Collections.Generic.js +333 -0
  127. package/dist/fable_modules/fable-library-js.5.17.2/System.Text.js +200 -0
  128. package/dist/fable_modules/fable-library-js.5.17.2/System.js +289 -0
  129. package/dist/fable_modules/fable-library-js.5.17.2/Task.js +27 -0
  130. package/dist/fable_modules/fable-library-js.5.17.2/TaskBuilder.js +72 -0
  131. package/dist/fable_modules/fable-library-js.5.17.2/TimeOnly.js +122 -0
  132. package/dist/fable_modules/fable-library-js.5.17.2/TimeOnlyTemporal.js +142 -0
  133. package/dist/fable_modules/fable-library-js.5.17.2/TimeSpan.js +180 -0
  134. package/dist/fable_modules/fable-library-js.5.17.2/TimeSpanTemporal.js +259 -0
  135. package/dist/fable_modules/fable-library-js.5.17.2/Timer.js +67 -0
  136. package/dist/fable_modules/fable-library-js.5.17.2/Types.js +198 -0
  137. package/dist/fable_modules/fable-library-js.5.17.2/Unicode.13.0.0.js +4 -0
  138. package/dist/fable_modules/fable-library-js.5.17.2/Uri.js +165 -0
  139. package/dist/fable_modules/fable-library-js.5.17.2/Util.js +807 -0
  140. package/dist/fable_modules/fable-library-js.5.17.2/big.d.ts +338 -0
  141. package/dist/fable_modules/fable-library-js.5.17.2/lib/big.js +829 -0
  142. package/dist/fable_modules/fable-library-js.5.17.2/package.json +24 -0
  143. package/dist/fable_modules/fable-library-js.5.17.2/quotation.js +682 -0
  144. package/package.json +1 -1
@@ -0,0 +1,112 @@
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 isIntegral(x) {
6
+ // Not perfect, because in JS we can't distinguish between 1.0 and 1
7
+ return typeof x === "number" && Number.isInteger(x) || typeof x === "bigint";
8
+ }
9
+ export function compare(x, y) {
10
+ if (typeof x === "number") {
11
+ return x < y ? -1 : (x > y ? 1 : 0);
12
+ }
13
+ else if (typeof x === "bigint") {
14
+ return x < y ? -1 : (x > y ? 1 : 0);
15
+ }
16
+ else {
17
+ return x.CompareTo(y);
18
+ }
19
+ }
20
+ export function multiply(x, y) {
21
+ if (typeof x === "number") {
22
+ return x * y;
23
+ }
24
+ else if (typeof x === "bigint") {
25
+ return x * BigInt(y);
26
+ }
27
+ else {
28
+ return x[symbol]().multiply(y);
29
+ }
30
+ }
31
+ export function divide(x, y) {
32
+ if (typeof x === "number") {
33
+ return x / y;
34
+ }
35
+ else if (typeof x === "bigint") {
36
+ // Keep the fractional part so the caller can round it like .NET does
37
+ return Number(x) / y;
38
+ }
39
+ else {
40
+ return x[symbol]().multiply(1 / y);
41
+ }
42
+ }
43
+ export function toFixed(x, dp) {
44
+ if (typeof x === "number") {
45
+ return x.toFixed(dp);
46
+ }
47
+ else if (typeof x === "bigint") {
48
+ return x.toString();
49
+ }
50
+ else {
51
+ return x[symbol]().toFixed(dp);
52
+ }
53
+ }
54
+ export function toPrecision(x, sd) {
55
+ if (typeof x === "number") {
56
+ return x.toPrecision(sd);
57
+ }
58
+ else if (typeof x === "bigint") {
59
+ return x.toString();
60
+ }
61
+ else {
62
+ return x[symbol]().toPrecision(sd);
63
+ }
64
+ }
65
+ // A bigint can hold more significant digits than a double, so the mantissa is rounded on the
66
+ // decimal digits themselves instead of going through Number
67
+ function bigintToExponential(x, dp) {
68
+ const sign = x < 0n ? "-" : "";
69
+ let digits = (x < 0n ? -x : x).toString();
70
+ if (x === 0n) {
71
+ return sign + (dp ? "0." + "0".repeat(dp) : "0") + "e+0";
72
+ }
73
+ dp = dp ?? digits.length - 1;
74
+ let exponent = digits.length - 1;
75
+ if (digits.length > dp + 1) {
76
+ // .NET rounds the discarded digits away from zero
77
+ const roundUp = digits.charCodeAt(dp + 1) >= 53;
78
+ digits = (BigInt(digits.slice(0, dp + 1)) + (roundUp ? 1n : 0n)).toString();
79
+ if (digits.length > dp + 1) {
80
+ digits = digits.slice(0, dp + 1);
81
+ exponent += 1;
82
+ }
83
+ }
84
+ else {
85
+ digits = digits.padEnd(dp + 1, "0");
86
+ }
87
+ const mantissa = dp > 0 ? digits[0] + "." + digits.slice(1) : digits[0];
88
+ return sign + mantissa + "e+" + exponent;
89
+ }
90
+ export function toExponential(x, dp) {
91
+ if (typeof x === "number") {
92
+ return x.toExponential(dp);
93
+ }
94
+ else if (typeof x === "bigint") {
95
+ return bigintToExponential(x, dp);
96
+ }
97
+ else {
98
+ return x[symbol]().toExponential(dp);
99
+ }
100
+ }
101
+ export function toHex(x) {
102
+ if (typeof x === "number") {
103
+ return (Number(x) >>> 0).toString(16);
104
+ }
105
+ else if (typeof x === "bigint") {
106
+ // TODO: properly handle other bit sizes
107
+ return BigInt.asUintN(64, x).toString(16);
108
+ }
109
+ else {
110
+ return x[symbol]().toHex();
111
+ }
112
+ }
@@ -0,0 +1,115 @@
1
+ import { Choice_tryValueIfChoice1Of2, Choice_tryValueIfChoice2Of2 } from "./Choice.js";
2
+ import { some, 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) ? some(x) : undefined, 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
+ let haveLast = false;
88
+ return source.Subscribe(new Observer((next) => {
89
+ if (haveLast) {
90
+ observer.OnNext([last, next]);
91
+ }
92
+ last = next;
93
+ haveLast = true;
94
+ }, observer.OnError, observer.OnCompleted));
95
+ });
96
+ }
97
+ export function partition(predicate, source) {
98
+ return [filter(predicate, source), filter((x) => !predicate(x), source)];
99
+ }
100
+ export function scan(collector, state, source) {
101
+ return new Observable((observer) => {
102
+ return source.Subscribe(new Observer((t) => {
103
+ protect(() => collector(state, t), (u) => { state = u; observer.OnNext(u); }, observer.OnError);
104
+ }, observer.OnError, observer.OnCompleted));
105
+ });
106
+ }
107
+ export function split(splitter, source) {
108
+ return [
109
+ choose((v) => Choice_tryValueIfChoice1Of2(splitter(v)), source),
110
+ choose((v) => Choice_tryValueIfChoice2Of2(splitter(v)), source)
111
+ ];
112
+ }
113
+ export function subscribe(callback, source) {
114
+ return source.Subscribe(new Observer(callback));
115
+ }
@@ -0,0 +1,87 @@
1
+ import { Exception, 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 nonNullValue(x) {
35
+ if (x == null) {
36
+ throw new Exception("Nullable has no value");
37
+ }
38
+ else {
39
+ return x;
40
+ }
41
+ }
42
+ export function value(x) {
43
+ if (x == null) {
44
+ throw new Exception("Option has no value");
45
+ }
46
+ else {
47
+ return x instanceof Some ? x.value : x;
48
+ }
49
+ }
50
+ export function unwrap(opt) {
51
+ return opt instanceof Some ? opt.value : opt;
52
+ }
53
+ export function some(x) {
54
+ return x == null || x instanceof Some ? new Some(x) : x;
55
+ }
56
+ export function ofNullable(x) {
57
+ // This will fail with unit probably, an alternative would be:
58
+ // return x === null ? undefined : (x === undefined ? new Some(x) : x);
59
+ return x == null ? undefined : x;
60
+ }
61
+ export function toNullable(x) {
62
+ return x == null ? null : value(x);
63
+ }
64
+ export function flatten(x) {
65
+ return x == null ? undefined : value(x);
66
+ }
67
+ export function toArray(opt) {
68
+ return (opt == null) ? [] : [value(opt)];
69
+ }
70
+ export function defaultArg(opt, defaultValue) {
71
+ return (opt != null) ? value(opt) : defaultValue;
72
+ }
73
+ export function orElse(opt, ifNone) {
74
+ return opt == null ? ifNone : opt;
75
+ }
76
+ // Only used by Replacements.Util.fs's curry/uncurry helpers, not by `Option.map` itself.
77
+ export function map(mapping, opt) {
78
+ return (opt != null) ? some(mapping(value(opt))) : undefined;
79
+ }
80
+ export function tryOp(op, arg) {
81
+ try {
82
+ return some(op(arg));
83
+ }
84
+ catch {
85
+ return undefined;
86
+ }
87
+ }
@@ -0,0 +1,31 @@
1
+ // This library doesn't depend on @types/node (to stay browser-compatible),
2
+ // so these Node.js built-in imports can't be type-checked; the exported
3
+ // functions below still declare their own types for callers to rely on.
4
+ // @ts-ignore
5
+ import { basename, extname, join } from "node:path";
6
+ // @ts-ignore
7
+ import { tmpdir } from "node:os";
8
+ // @ts-ignore
9
+ import { writeFileSync } from "node:fs";
10
+ // Mirrors the format of .NET's Path.GetRandomFileName(): 8 random hex chars,
11
+ // a dot, then 3 more random hex chars.
12
+ export function getRandomFileName() {
13
+ const nameBytes = new Uint8Array(4);
14
+ crypto.getRandomValues(nameBytes);
15
+ const name = Array.from(nameBytes, (b) => b.toString(16).padStart(2, "0")).join("");
16
+ const extBytes = new Uint8Array(2);
17
+ crypto.getRandomValues(extBytes);
18
+ const ext = Array.from(extBytes, (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 3);
19
+ return `${name}.${ext}`;
20
+ }
21
+ export function getFileNameWithoutExtension(path) {
22
+ return basename(path, extname(path));
23
+ }
24
+ export function hasExtension(path) {
25
+ return extname(path) !== "";
26
+ }
27
+ export function getTempFileName() {
28
+ const path = join(tmpdir(), getRandomFileName());
29
+ writeFileSync(path, "");
30
+ return path;
31
+ }
@@ -0,0 +1,3 @@
1
+ # fable-library
2
+
3
+ Core library used by F# projects compiled with [Fable](https://fable.io).
@@ -0,0 +1,172 @@
1
+ import { ArgumentNullException_$ctor_Z721C83C5, ArgumentOutOfRangeException_$ctor_Z721C83C5 } from "./System.js";
2
+ import { Operators_IsNull } from "./FSharp.Core.js";
3
+ import { class_type } from "./Reflection.js";
4
+ import { fromFloat64, op_Addition, toInt32_unchecked, toFloat64, compare, fromInt32, toInt64_unchecked } from "./BigInt.js";
5
+ import { item, setItem } from "./Array.js";
6
+ function Native_random() {
7
+ return Math.random();
8
+ }
9
+ function Native_randomNext(minValue, maxValue) {
10
+ if (maxValue < minValue) {
11
+ throw ArgumentOutOfRangeException_$ctor_Z721C83C5("minValue must be less than maxValue");
12
+ }
13
+ return Math.floor(Math.random() * (maxValue - minValue)) + minValue;
14
+ }
15
+ function Native_randomBytes(buffer) {
16
+ if (Operators_IsNull(buffer)) {
17
+ throw ArgumentNullException_$ctor_Z721C83C5("buffer");
18
+ }
19
+ for (let i = 0; i < buffer.length; i += 6) {
20
+ // Pick random 48-bit number. Fill buffer in 2 24-bit chunks to avoid bitwise truncation.
21
+ let r = Math.floor(Math.random() * 281474976710656); // Low 24 bits = chunk 1.
22
+ const rhi = Math.floor(r / 16777216); // High 24 bits shifted via division = chunk 2.
23
+ for (let j = 0; j < 6 && i + j < buffer.length; j++) {
24
+ if (j === 3) {
25
+ r = rhi;
26
+ }
27
+ buffer[i + j] = r & 255;
28
+ r >>>= 8;
29
+ }
30
+ }
31
+ ;
32
+ }
33
+ export class NonSeeded {
34
+ constructor() {
35
+ }
36
+ Next0() {
37
+ return Native_randomNext(0, 2147483647) | 0;
38
+ }
39
+ Next1(maxValue) {
40
+ return Native_randomNext(0, maxValue) | 0;
41
+ }
42
+ Next2(minValue, maxValue) {
43
+ return Native_randomNext(minValue, maxValue) | 0;
44
+ }
45
+ NextDouble() {
46
+ return Native_random();
47
+ }
48
+ NextBytes(buffer) {
49
+ Native_randomBytes(buffer);
50
+ }
51
+ }
52
+ export function NonSeeded_$reflection() {
53
+ return class_type("Random.NonSeeded", undefined, NonSeeded);
54
+ }
55
+ export function NonSeeded_$ctor() {
56
+ return new NonSeeded();
57
+ }
58
+ export class Seeded {
59
+ constructor(seed) {
60
+ this.MBIG = 2147483647;
61
+ this.inext = 0;
62
+ this.inextp = 0;
63
+ this.seedArray = (new Int32Array(56));
64
+ let ii = 0;
65
+ let mj = 0;
66
+ let mk = 0;
67
+ const subtraction = ((seed === -2147483648) ? 2147483647 : Math.abs(seed)) | 0;
68
+ mj = ((161803398 - subtraction) | 0);
69
+ this.seedArray[55] = (mj | 0);
70
+ mk = 1;
71
+ for (let i = 1; i <= 54; i++) {
72
+ ii = (((21 * i) % 55) | 0);
73
+ this.seedArray[ii] = (mk | 0);
74
+ mk = ((mj - mk) | 0);
75
+ if (mk < 0) {
76
+ mk = ((mk + this.MBIG) | 0);
77
+ }
78
+ mj = (item(ii, this.seedArray) | 0);
79
+ }
80
+ for (let k = 1; k <= 4; k++) {
81
+ for (let i_1 = 1; i_1 <= 55; i_1++) {
82
+ this.seedArray[i_1] = ((item(i_1, this.seedArray) - item(1 + ((i_1 + 30) % 55), this.seedArray)) | 0);
83
+ if (item(i_1, this.seedArray) < 0) {
84
+ this.seedArray[i_1] = ((item(i_1, this.seedArray) + this.MBIG) | 0);
85
+ }
86
+ }
87
+ }
88
+ this.inext = 0;
89
+ this.inextp = 21;
90
+ }
91
+ Next0() {
92
+ const this$ = this;
93
+ return Seeded__InternalSample(this$) | 0;
94
+ }
95
+ Next1(maxValue) {
96
+ const this$ = this;
97
+ if (maxValue < 0) {
98
+ throw ArgumentOutOfRangeException_$ctor_Z721C83C5("maxValue must be positive");
99
+ }
100
+ return ~~(Seeded__Sample(this$) * maxValue) | 0;
101
+ }
102
+ Next2(minValue, maxValue) {
103
+ const this$ = this;
104
+ if (minValue > maxValue) {
105
+ throw ArgumentOutOfRangeException_$ctor_Z721C83C5("minValue must be less than maxValue");
106
+ }
107
+ const range = toInt64_unchecked(fromInt32(maxValue - minValue));
108
+ return ((compare(range, toInt64_unchecked(fromInt32(2147483647))) <= 0) ? (~~(Seeded__Sample(this$) * toFloat64(range)) + minValue) : ~~toInt32_unchecked(toInt64_unchecked(op_Addition(toInt64_unchecked(fromFloat64(Seeded__GetSampleForLargeRange(this$) * toFloat64(range))), toInt64_unchecked(fromInt32(minValue)))))) | 0;
109
+ }
110
+ NextDouble() {
111
+ const this$ = this;
112
+ return Seeded__Sample(this$);
113
+ }
114
+ NextBytes(buffer) {
115
+ const this$ = this;
116
+ if (Operators_IsNull(buffer)) {
117
+ throw ArgumentNullException_$ctor_Z721C83C5("buffer");
118
+ }
119
+ for (let i = 0; i <= (buffer.length - 1); i++) {
120
+ setItem(buffer, i, (Seeded__InternalSample(this$) % (~~255 + 1)) & 0xFF);
121
+ }
122
+ }
123
+ }
124
+ export function Seeded_$reflection() {
125
+ return class_type("Random.Seeded", undefined, Seeded);
126
+ }
127
+ export function Seeded_$ctor_Z524259A4(seed) {
128
+ return new Seeded(seed);
129
+ }
130
+ function Seeded__InternalSample(_) {
131
+ let retVal = 0;
132
+ let locINext = _.inext;
133
+ let locINextp = _.inextp;
134
+ locINext = ((locINext + 1) | 0);
135
+ if (locINext >= 56) {
136
+ locINext = 1;
137
+ }
138
+ locINextp = ((locINextp + 1) | 0);
139
+ if (locINextp >= 56) {
140
+ locINextp = 1;
141
+ }
142
+ retVal = ((item(locINext, _.seedArray) - item(locINextp, _.seedArray)) | 0);
143
+ if (retVal === _.MBIG) {
144
+ retVal = ((retVal - 1) | 0);
145
+ }
146
+ if (retVal < 0) {
147
+ retVal = ((retVal + _.MBIG) | 0);
148
+ }
149
+ _.seedArray[locINext] = (retVal | 0);
150
+ _.inext = (locINext | 0);
151
+ _.inextp = (locINextp | 0);
152
+ return retVal | 0;
153
+ }
154
+ export function Seeded__Sample(this$) {
155
+ return Seeded__InternalSample(this$) * (1 / this$.MBIG);
156
+ }
157
+ export function Seeded__GetSampleForLargeRange(this$) {
158
+ let result = Seeded__InternalSample(this$);
159
+ if ((Seeded__InternalSample(this$) % 2) === 0) {
160
+ result = -result;
161
+ }
162
+ let d = result;
163
+ d = (d + (2147483647 - 1));
164
+ d = (d / (2 * ((2147483647 - 1) >>> 0)));
165
+ return d;
166
+ }
167
+ export function nonSeeded() {
168
+ return NonSeeded_$ctor();
169
+ }
170
+ export function seeded(seed) {
171
+ return Seeded_$ctor_Z524259A4(seed);
172
+ }
@@ -0,0 +1,45 @@
1
+ import { Exception, compare } from "./Util.js";
2
+ import { unfold, delay } from "./Seq.js";
3
+ import { toUInt64_unchecked, toInt64_unchecked, op_Addition, fromZero } from "./BigInt.js";
4
+ import { op_Addition as op_Addition_1, fromParts } from "./Decimal.js";
5
+ export function makeRangeStepFunction(step, stop, zero, add) {
6
+ const stepComparedWithZero = compare(step, zero) | 0;
7
+ if (stepComparedWithZero === 0) {
8
+ throw new Exception("The step of a range cannot be zero");
9
+ }
10
+ const stepGreaterThanZero = stepComparedWithZero > 0;
11
+ return (x) => {
12
+ const comparedWithLast = compare(x, stop) | 0;
13
+ return ((stepGreaterThanZero && (comparedWithLast <= 0)) ? true : (!stepGreaterThanZero && (comparedWithLast >= 0))) ? [x, add(x, step)] : undefined;
14
+ };
15
+ }
16
+ export function integralRangeStep(start, step, stop, zero, add) {
17
+ const stepFn = makeRangeStepFunction(step, stop, zero, add);
18
+ return delay(() => unfold(stepFn, start));
19
+ }
20
+ export function rangeBigInt(start, step, stop) {
21
+ return integralRangeStep(start, step, stop, fromZero(), op_Addition);
22
+ }
23
+ export function rangeDecimal(start, step, stop) {
24
+ return integralRangeStep(start, step, stop, fromParts(0, 0, 0, false, 0), op_Addition_1);
25
+ }
26
+ export function rangeDouble(start, step, stop) {
27
+ return integralRangeStep(start, step, stop, 0, (x, y) => (x + y));
28
+ }
29
+ export function rangeInt64(start, step, stop) {
30
+ return integralRangeStep(start, step, stop, 0n, (x, y) => toInt64_unchecked(op_Addition(x, y)));
31
+ }
32
+ export function rangeUInt64(start, step, stop) {
33
+ return integralRangeStep(start, step, stop, 0n, (x, y) => toUInt64_unchecked(op_Addition(x, y)));
34
+ }
35
+ export function rangeChar(start, stop) {
36
+ const intStop = ~~stop.charCodeAt(0) | 0;
37
+ return delay(() => unfold((i) => {
38
+ if (i <= intStop) {
39
+ return [String.fromCharCode(i & 0xFFFF), i + 1];
40
+ }
41
+ else {
42
+ return undefined;
43
+ }
44
+ }, ~~start.charCodeAt(0)));
45
+ }