@glutinum/cli 0.14.0 → 1.0.0-beta.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.
- package/dist/Glutinum.Converter/FsharpAST.js +38 -4
- package/dist/Glutinum.Converter/Generate.js +15 -7
- package/dist/Glutinum.Converter/GlueAST.js +45 -36
- package/dist/Glutinum.Converter/Hosting.js +918 -0
- package/dist/Glutinum.Converter/Merge.js +218 -82
- package/dist/Glutinum.Converter/Packages.js +44 -8
- package/dist/Glutinum.Converter/Printer.js +77 -49
- package/dist/Glutinum.Converter/Read.js +8 -8
- package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +7 -7
- package/dist/Glutinum.Converter/Reader/Declaration.js +26 -26
- package/dist/Glutinum.Converter/Reader/Documentation.js +37 -36
- package/dist/Glutinum.Converter/Reader/ExportAssignment.js +5 -5
- package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +31 -19
- package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +6 -7
- package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +36 -29
- package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +3 -3
- package/dist/Glutinum.Converter/Reader/MappedTypeNode.js +82 -4
- package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js +3 -3
- package/dist/Glutinum.Converter/Reader/Node.js +20 -20
- package/dist/Glutinum.Converter/Reader/Parameters.js +7 -7
- package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js +5 -5
- package/dist/Glutinum.Converter/Reader/TypeNode.js +291 -232
- package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +8 -8
- package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +108 -40
- package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +2 -2
- package/dist/Glutinum.Converter/Reader/Types.js +6 -6
- package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +7 -6
- package/dist/Glutinum.Converter/Reader/Utils.js +106 -56
- package/dist/Glutinum.Converter/Transform.js +2057 -700
- package/dist/Glutinum.Converter/TypeScript.Extensions.js +194 -202
- package/dist/Glutinum.Converter/Utils/Naming.js +7 -0
- package/dist/Glutinum.Converter/Utils/String.js +2 -2
- package/dist/Program.js +38 -26
- package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs +89 -0
- package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs.js +105 -0
- package/dist/fable_modules/Fable.Promise.3.2.1/Fable.Promise.fableproj +25 -0
- package/dist/fable_modules/Fable.Promise.3.2.1/Promise.fs +842 -0
- package/dist/fable_modules/Fable.Promise.3.2.1/Promise.fs.js +232 -0
- package/dist/fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs +31 -0
- package/dist/fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs.js +20 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs +235 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs.js +384 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AssemblyInfo.fs +19 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Async.fs +287 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Async.fs.js +128 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOption.fs +127 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionCE.fs +174 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionCE.fs.js +37 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionOp.fs +24 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResult.fs +483 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultCE.fs +201 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultCE.fs.js +18 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOp.fs +24 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs +87 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs.js +26 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionCE.fs +236 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionCE.fs.js +18 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionOp.fs +24 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidation.fs +185 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationCE.fs +186 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationCE.fs.js +18 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationOp.fs +35 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/FsToolkit.ErrorHandling.fableproj +69 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/List.fs +276 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/List.fs.js +364 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Nullness.fs +81 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Option.fs +462 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs +139 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs.js +48 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionOp.fs +21 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs +88 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs.js +30 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs +200 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs.js +18 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidation.fs +34 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs +244 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs.js +18 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Result.fs +731 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Result.fs.js +45 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultCE.fs +140 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultCE.fs.js +23 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOp.fs +45 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOption.fs +201 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOption.fs.js +65 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionCE.fs +135 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionCE.fs.js +18 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionOp.fs +57 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs +503 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs.js +295 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Validation.fs +167 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationCE.fs +142 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationCE.fs.js +18 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationOp.fs +35 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueOption.fs +148 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOption.fs +102 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOptionCE.fs +587 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOptionOp.fs +10 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Debug/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +3 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Debug/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.fs +3 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/net9.0/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.fs +3 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.0/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +3 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Array.js +1348 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Async.js +163 -0
- package/dist/fable_modules/fable-library-js.5.17.2/AsyncBuilder.js +204 -0
- package/dist/fable_modules/fable-library-js.5.17.2/BigInt.js +307 -0
- package/dist/fable_modules/fable-library-js.5.17.2/BitConverter.js +138 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Boolean.js +22 -0
- package/dist/fable_modules/fable-library-js.5.17.2/CHANGELOG.md +348 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Char.js +202 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Choice.js +184 -0
- package/dist/fable_modules/fable-library-js.5.17.2/CollectionUtil.js +182 -0
- package/dist/fable_modules/fable-library-js.5.17.2/ConditionalWeakTable.js +21 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Date.js +834 -0
- package/dist/fable_modules/fable-library-js.5.17.2/DateOffset.js +252 -0
- package/dist/fable_modules/fable-library-js.5.17.2/DateOnly.js +124 -0
- package/dist/fable_modules/fable-library-js.5.17.2/DateOnlyTemporal.js +146 -0
- package/dist/fable_modules/fable-library-js.5.17.2/DateTimeFormat.js +523 -0
- package/dist/fable_modules/fable-library-js.5.17.2/DateTimeOffsetTemporal.js +283 -0
- package/dist/fable_modules/fable-library-js.5.17.2/DateTimeTemporal.js +243 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Decimal.js +238 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Directory.js +11 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Double.js +53 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Encoding.js +185 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Environment.js +3 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Event.js +102 -0
- package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Collections.js +45 -0
- package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Core.CompilerServices.js +27 -0
- package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Core.js +156 -0
- package/dist/fable_modules/fable-library-js.5.17.2/File.js +27 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Global.js +29 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Guid.js +163 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Int32.js +135 -0
- package/dist/fable_modules/fable-library-js.5.17.2/List.js +1337 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Long.js +38 -0
- package/dist/fable_modules/fable-library-js.5.17.2/MailboxProcessor.js +100 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Map.js +1400 -0
- package/dist/fable_modules/fable-library-js.5.17.2/MapUtil.js +130 -0
- package/dist/fable_modules/fable-library-js.5.17.2/MutableMap.js +339 -0
- package/dist/fable_modules/fable-library-js.5.17.2/MutableSet.js +233 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Native.js +14 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Numeric.js +112 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Observable.js +115 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Option.js +87 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Path.js +31 -0
- package/dist/fable_modules/fable-library-js.5.17.2/README.md +3 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Random.js +172 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Range.js +45 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Reflection.js +489 -0
- package/dist/fable_modules/fable-library-js.5.17.2/RegExp.js +170 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Result.js +165 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Seq.js +1504 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Seq2.js +111 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Set.js +1829 -0
- package/dist/fable_modules/fable-library-js.5.17.2/String.js +731 -0
- package/dist/fable_modules/fable-library-js.5.17.2/System.Collections.Generic.js +333 -0
- package/dist/fable_modules/fable-library-js.5.17.2/System.Text.js +200 -0
- package/dist/fable_modules/fable-library-js.5.17.2/System.js +289 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Task.js +27 -0
- package/dist/fable_modules/fable-library-js.5.17.2/TaskBuilder.js +72 -0
- package/dist/fable_modules/fable-library-js.5.17.2/TimeOnly.js +122 -0
- package/dist/fable_modules/fable-library-js.5.17.2/TimeOnlyTemporal.js +142 -0
- package/dist/fable_modules/fable-library-js.5.17.2/TimeSpan.js +180 -0
- package/dist/fable_modules/fable-library-js.5.17.2/TimeSpanTemporal.js +259 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Timer.js +67 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Types.js +198 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Unicode.13.0.0.js +4 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Uri.js +165 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Util.js +807 -0
- package/dist/fable_modules/fable-library-js.5.17.2/big.d.ts +338 -0
- package/dist/fable_modules/fable-library-js.5.17.2/lib/big.js +829 -0
- package/dist/fable_modules/fable-library-js.5.17.2/package.json +24 -0
- package/dist/fable_modules/fable-library-js.5.17.2/quotation.js +682 -0
- package/package.json +2 -2
- package/dist/Glutinum.Converter/TypeScript.js +0 -12
- package/src/Glutinum.Converter/js/bootstrap.js +0 -123
- package/src/Glutinum.Converter/js/host.js +0 -144
- package/src/Glutinum.Converter/js/npm.js +0 -137
- package/src/Glutinum.Converter/js/resolve.js +0 -402
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import Decimal from "./lib/big.js";
|
|
2
|
+
import { symbol } from "./Numeric.js";
|
|
3
|
+
import { FSharpRef } from "./Types.js";
|
|
4
|
+
import { Exception, combineHashCodes } from "./Util.js";
|
|
5
|
+
import { fromDecimal } from "./BigInt.js";
|
|
6
|
+
import * as bigInt from "./BigInt.js";
|
|
7
|
+
Decimal.prototype.GetHashCode = function () {
|
|
8
|
+
return combineHashCodes([this.s, this.e].concat(this.c));
|
|
9
|
+
};
|
|
10
|
+
Decimal.prototype.Equals = function (x) {
|
|
11
|
+
return !this.cmp(x);
|
|
12
|
+
};
|
|
13
|
+
Decimal.prototype.CompareTo = function (x) {
|
|
14
|
+
return this.cmp(x);
|
|
15
|
+
};
|
|
16
|
+
Decimal.prototype[symbol] = function () {
|
|
17
|
+
const _this = this;
|
|
18
|
+
return {
|
|
19
|
+
multiply: (y) => _this.mul(y),
|
|
20
|
+
toPrecision: (sd) => _this.toPrecision(sd),
|
|
21
|
+
toExponential: (dp) => _this.toExponential(dp),
|
|
22
|
+
toFixed: (dp) => _this.toFixed(dp),
|
|
23
|
+
toHex: () => (Number(_this) >>> 0).toString(16),
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export default Decimal;
|
|
27
|
+
export const get_Zero = new Decimal(0);
|
|
28
|
+
export const get_One = new Decimal(1);
|
|
29
|
+
export const get_MinusOne = new Decimal(-1);
|
|
30
|
+
export const get_MaxValue = new Decimal("79228162514264337593543950335");
|
|
31
|
+
export const get_MinValue = new Decimal("-79228162514264337593543950335");
|
|
32
|
+
export function compare(x, y) {
|
|
33
|
+
return x.cmp(y);
|
|
34
|
+
}
|
|
35
|
+
export function equals(x, y) {
|
|
36
|
+
return !x.cmp(y);
|
|
37
|
+
}
|
|
38
|
+
export function abs(x) { return x.abs(); }
|
|
39
|
+
export function sign(x) { return x.lt(get_Zero) ? -1 : x.gt(get_Zero) ? 1 : 0; }
|
|
40
|
+
export function max(x, y) { return x.gt(y) ? x : y; }
|
|
41
|
+
export function min(x, y) { return x.lt(y) ? x : y; }
|
|
42
|
+
export function maxMagnitude(x, y) { return abs(x).gt(abs(y)) ? x : y; }
|
|
43
|
+
export function minMagnitude(x, y) { return abs(x).lt(abs(y)) ? x : y; }
|
|
44
|
+
export function clamp(x, min, max) {
|
|
45
|
+
return x.lt(min) ? min : x.gt(max) ? max : x;
|
|
46
|
+
}
|
|
47
|
+
export function round(x, digits = 0) {
|
|
48
|
+
return x.round(digits, 2 /* ROUND_HALF_EVEN */);
|
|
49
|
+
}
|
|
50
|
+
export function truncate(x) {
|
|
51
|
+
return x.round(0, 0 /* ROUND_DOWN */);
|
|
52
|
+
}
|
|
53
|
+
export function ceiling(x) {
|
|
54
|
+
return x.round(0, x.cmp(0) >= 0 ? 3 /* ROUND_UP */ : 0 /* ROUND_DOWN */);
|
|
55
|
+
}
|
|
56
|
+
export function floor(x) {
|
|
57
|
+
return x.round(0, x.cmp(0) >= 0 ? 0 /* ROUND_DOWN */ : 3 /* ROUND_UP */);
|
|
58
|
+
}
|
|
59
|
+
export function pow(x, n) {
|
|
60
|
+
return x.pow(n);
|
|
61
|
+
}
|
|
62
|
+
export function sqrt(x) {
|
|
63
|
+
return x.sqrt();
|
|
64
|
+
}
|
|
65
|
+
export function op_Addition(x, y) {
|
|
66
|
+
return x.add(y);
|
|
67
|
+
}
|
|
68
|
+
export function op_Subtraction(x, y) {
|
|
69
|
+
return x.sub(y);
|
|
70
|
+
}
|
|
71
|
+
export function op_Multiply(x, y) {
|
|
72
|
+
return x.mul(y);
|
|
73
|
+
}
|
|
74
|
+
export function op_Division(x, y) {
|
|
75
|
+
return x.div(y);
|
|
76
|
+
}
|
|
77
|
+
export function op_Modulus(x, y) {
|
|
78
|
+
return x.mod(y);
|
|
79
|
+
}
|
|
80
|
+
export function op_UnaryNegation(x) {
|
|
81
|
+
const x2 = new Decimal(x);
|
|
82
|
+
x2.s = -x2.s || 0;
|
|
83
|
+
return x2;
|
|
84
|
+
}
|
|
85
|
+
export function op_UnaryPlus(x) {
|
|
86
|
+
return x;
|
|
87
|
+
}
|
|
88
|
+
export const add = op_Addition;
|
|
89
|
+
export const subtract = op_Subtraction;
|
|
90
|
+
export const multiply = op_Multiply;
|
|
91
|
+
export const divide = op_Division;
|
|
92
|
+
export const remainder = op_Modulus;
|
|
93
|
+
export const negate = op_UnaryNegation;
|
|
94
|
+
export function toString(x) {
|
|
95
|
+
return x.toString();
|
|
96
|
+
}
|
|
97
|
+
export function tryParse(str, defValue) {
|
|
98
|
+
try {
|
|
99
|
+
defValue.contents = new Decimal(str.trim());
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export function parse(str) {
|
|
107
|
+
const defValue = new FSharpRef(get_Zero);
|
|
108
|
+
if (tryParse(str, defValue)) {
|
|
109
|
+
return defValue.contents;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
throw new Exception(`The input string ${str} was not in a correct format.`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
export function toNumber(x) {
|
|
116
|
+
return +x;
|
|
117
|
+
}
|
|
118
|
+
export function toChar(x) {
|
|
119
|
+
const n = toNumber(x);
|
|
120
|
+
if (n < 0 || n > 65535 || isNaN(n)) {
|
|
121
|
+
throw new Exception("Value was either too large or too small for a character.");
|
|
122
|
+
}
|
|
123
|
+
return String.fromCharCode(n);
|
|
124
|
+
}
|
|
125
|
+
export function toInt8(x) { return bigInt.toInt8(fromDecimal(x)); }
|
|
126
|
+
export function toUInt8(x) { return bigInt.toUInt8(fromDecimal(x)); }
|
|
127
|
+
export function toInt16(x) { return bigInt.toInt16(fromDecimal(x)); }
|
|
128
|
+
export function toUInt16(x) { return bigInt.toUInt16(fromDecimal(x)); }
|
|
129
|
+
export function toInt32(x) { return bigInt.toInt32(fromDecimal(x)); }
|
|
130
|
+
export function toUInt32(x) { return bigInt.toUInt32(fromDecimal(x)); }
|
|
131
|
+
export function toInt64(x) { return bigInt.toInt64(fromDecimal(x)); }
|
|
132
|
+
export function toUInt64(x) { return bigInt.toUInt64(fromDecimal(x)); }
|
|
133
|
+
export function toInt128(x) { return bigInt.toInt128(fromDecimal(x)); }
|
|
134
|
+
export function toUInt128(x) { return bigInt.toUInt128(fromDecimal(x)); }
|
|
135
|
+
export function toNativeInt(x) { return bigInt.toNativeInt(fromDecimal(x)); }
|
|
136
|
+
export function toUNativeInt(x) { return bigInt.toUNativeInt(fromDecimal(x)); }
|
|
137
|
+
export function toFloat16(x) { return toNumber(x); }
|
|
138
|
+
export function toFloat32(x) { return toNumber(x); }
|
|
139
|
+
export function toFloat64(x) { return toNumber(x); }
|
|
140
|
+
function decimalToHex(dec, bitSize) {
|
|
141
|
+
const hex = new Uint8Array(bitSize / 4 | 0);
|
|
142
|
+
let hexCount = 1;
|
|
143
|
+
for (let d = 0; d < dec.length; d++) {
|
|
144
|
+
let value = dec[d];
|
|
145
|
+
for (let i = 0; i < hexCount; i++) {
|
|
146
|
+
const digit = hex[i] * 10 + value | 0;
|
|
147
|
+
hex[i] = digit & 0xF;
|
|
148
|
+
value = digit >> 4;
|
|
149
|
+
}
|
|
150
|
+
if (value !== 0) {
|
|
151
|
+
hex[hexCount++] = value;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return hex.slice(0, hexCount); // digits in reverse order
|
|
155
|
+
}
|
|
156
|
+
function hexToDecimal(hex, bitSize) {
|
|
157
|
+
const dec = new Uint8Array(bitSize * 301 / 1000 + 1 | 0);
|
|
158
|
+
let decCount = 1;
|
|
159
|
+
for (let d = hex.length - 1; d >= 0; d--) {
|
|
160
|
+
let carry = hex[d];
|
|
161
|
+
for (let i = 0; i < decCount; i++) {
|
|
162
|
+
const val = dec[i] * 16 + carry | 0;
|
|
163
|
+
dec[i] = (val % 10) | 0;
|
|
164
|
+
carry = (val / 10) | 0;
|
|
165
|
+
}
|
|
166
|
+
while (carry > 0) {
|
|
167
|
+
dec[decCount++] = (carry % 10) | 0;
|
|
168
|
+
carry = (carry / 10) | 0;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return dec.slice(0, decCount); // digits in reverse order
|
|
172
|
+
}
|
|
173
|
+
function setInt32Bits(hexDigits, bits, offset) {
|
|
174
|
+
for (let i = 0; i < 8; i++) {
|
|
175
|
+
hexDigits[offset + i] = (bits >> (i * 4)) & 0xF;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function getInt32Bits(hexDigits, offset) {
|
|
179
|
+
let bits = 0;
|
|
180
|
+
for (let i = 0; i < 8; i++) {
|
|
181
|
+
bits = bits | (hexDigits[offset + i] << (i * 4));
|
|
182
|
+
}
|
|
183
|
+
return bits;
|
|
184
|
+
}
|
|
185
|
+
export function fromIntArray(bits) {
|
|
186
|
+
return fromInts(bits[0], bits[1], bits[2], bits[3]);
|
|
187
|
+
}
|
|
188
|
+
export function fromInts(low, mid, high, signExp) {
|
|
189
|
+
const isNegative = signExp < 0;
|
|
190
|
+
const scale = (signExp >> 16) & 0x7F;
|
|
191
|
+
return fromParts(low, mid, high, isNegative, scale);
|
|
192
|
+
}
|
|
193
|
+
export function fromParts(low, mid, high, isNegative, scale) {
|
|
194
|
+
const bitSize = 96;
|
|
195
|
+
const hexDigits = new Uint8Array(bitSize / 4);
|
|
196
|
+
setInt32Bits(hexDigits, low, 0);
|
|
197
|
+
setInt32Bits(hexDigits, mid, 8);
|
|
198
|
+
setInt32Bits(hexDigits, high, 16);
|
|
199
|
+
const decDigits = hexToDecimal(hexDigits, bitSize);
|
|
200
|
+
scale = scale & 0x7F;
|
|
201
|
+
const big = new Decimal(0);
|
|
202
|
+
big.c = Array.from(decDigits.reverse());
|
|
203
|
+
big.e = decDigits.length - scale - 1;
|
|
204
|
+
big.s = isNegative ? -1 : 1;
|
|
205
|
+
const d = new Decimal(big);
|
|
206
|
+
return d;
|
|
207
|
+
}
|
|
208
|
+
export function getBits(d) {
|
|
209
|
+
const bitSize = 96;
|
|
210
|
+
const decStr = d.toString();
|
|
211
|
+
const absStr = decStr[0] === "-" ? decStr.slice(1) : decStr;
|
|
212
|
+
const dotPos = absStr.indexOf(".");
|
|
213
|
+
const scale = dotPos < 0 ? 0 : absStr.length - dotPos - 1;
|
|
214
|
+
const mantissaStr = absStr.replace(".", "");
|
|
215
|
+
const decDigits = Uint8Array.from(mantissaStr, ch => ch.charCodeAt(0) - 48);
|
|
216
|
+
const hexDigits = decimalToHex(decDigits, bitSize);
|
|
217
|
+
const low = getInt32Bits(hexDigits, 0);
|
|
218
|
+
const mid = getInt32Bits(hexDigits, 8);
|
|
219
|
+
const high = getInt32Bits(hexDigits, 16);
|
|
220
|
+
const signExp = ((scale & 0x7F) << 16) | (d.s < 0 ? 0x80000000 : 0);
|
|
221
|
+
return [low, mid, high, signExp];
|
|
222
|
+
}
|
|
223
|
+
// export function makeRangeStepFunction(step: Decimal, last: Decimal) {
|
|
224
|
+
// const stepComparedWithZero = step.cmp(get_Zero);
|
|
225
|
+
// if (stepComparedWithZero === 0) {
|
|
226
|
+
// throw new Exception("The step of a range cannot be zero");
|
|
227
|
+
// }
|
|
228
|
+
// const stepGreaterThanZero = stepComparedWithZero > 0;
|
|
229
|
+
// return (x: Decimal) => {
|
|
230
|
+
// const comparedWithLast = x.cmp(last);
|
|
231
|
+
// if ((stepGreaterThanZero && comparedWithLast <= 0)
|
|
232
|
+
// || (!stepGreaterThanZero && comparedWithLast >= 0)) {
|
|
233
|
+
// return [x, op_Addition(x, step)];
|
|
234
|
+
// } else {
|
|
235
|
+
// return undefined;
|
|
236
|
+
// }
|
|
237
|
+
// };
|
|
238
|
+
// }
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This library doesn't depend on @types/node (to stay browser-compatible),
|
|
2
|
+
// so this Node.js built-in import 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 { existsSync, mkdirSync, statSync } from "node:fs";
|
|
6
|
+
export function exists(path) {
|
|
7
|
+
return existsSync(path) && statSync(path).isDirectory();
|
|
8
|
+
}
|
|
9
|
+
export function createDirectory(path) {
|
|
10
|
+
mkdirSync(path, { recursive: true });
|
|
11
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { FSharpRef } from "./Types.js";
|
|
2
|
+
import { Exception } from "./Util.js";
|
|
3
|
+
export function tryParse(str, defValue) {
|
|
4
|
+
// TODO: test if value is valid and in range
|
|
5
|
+
if (str != null && /\S/.test(str)) {
|
|
6
|
+
const v = +str.replace("_", "");
|
|
7
|
+
if (!Number.isNaN(v)) {
|
|
8
|
+
defValue.contents = v;
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
export function parse(str) {
|
|
15
|
+
const defValue = new FSharpRef(0);
|
|
16
|
+
if (tryParse(str, defValue)) {
|
|
17
|
+
return defValue.contents;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
throw new Exception(`The input string ${str} was not in a correct format.`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// JS Number.isFinite function evals false for NaN
|
|
24
|
+
export function isPositiveInfinity(x) {
|
|
25
|
+
return x === Number.POSITIVE_INFINITY;
|
|
26
|
+
}
|
|
27
|
+
export function isNegativeInfinity(x) {
|
|
28
|
+
return x === Number.NEGATIVE_INFINITY;
|
|
29
|
+
}
|
|
30
|
+
export function isInfinity(x) {
|
|
31
|
+
return x === Number.POSITIVE_INFINITY || x === Number.NEGATIVE_INFINITY;
|
|
32
|
+
}
|
|
33
|
+
export function max(x, y) {
|
|
34
|
+
return Math.max(x, y);
|
|
35
|
+
}
|
|
36
|
+
export function min(x, y) {
|
|
37
|
+
return Math.min(x, y);
|
|
38
|
+
}
|
|
39
|
+
export function maxMagnitude(x, y) {
|
|
40
|
+
if (Number.isNaN(x) || Number.isNaN(y)) {
|
|
41
|
+
return NaN;
|
|
42
|
+
}
|
|
43
|
+
return Math.abs(x) > Math.abs(y) ? x : y;
|
|
44
|
+
}
|
|
45
|
+
export function minMagnitude(x, y) {
|
|
46
|
+
if (Number.isNaN(x) || Number.isNaN(y)) {
|
|
47
|
+
return NaN;
|
|
48
|
+
}
|
|
49
|
+
return Math.abs(x) < Math.abs(y) ? x : y;
|
|
50
|
+
}
|
|
51
|
+
export function clamp(x, min, max) {
|
|
52
|
+
return x < min ? min : x > max ? max : x;
|
|
53
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
const littleEndian = true;
|
|
2
|
+
function utf16le_encode(str) {
|
|
3
|
+
const bytes = new Uint8Array(str.length * 2);
|
|
4
|
+
const view = new DataView(bytes.buffer);
|
|
5
|
+
for (let i = 0; i < str.length; i++) {
|
|
6
|
+
const code = str.charCodeAt(i);
|
|
7
|
+
view.setUint16(i * 2, code, littleEndian);
|
|
8
|
+
}
|
|
9
|
+
return bytes;
|
|
10
|
+
}
|
|
11
|
+
function utf16le_decode(bytes) {
|
|
12
|
+
const array = ArrayBuffer.isView(bytes) ? bytes : Uint8Array.from(bytes);
|
|
13
|
+
const view = new DataView(array.buffer, array.byteOffset, array.byteLength);
|
|
14
|
+
const chars = new Array(view.byteLength / 2);
|
|
15
|
+
for (let i = 0; i < chars.length; i++) {
|
|
16
|
+
const code = view.getUint16(i * 2, littleEndian);
|
|
17
|
+
chars[i] = String.fromCharCode(code);
|
|
18
|
+
}
|
|
19
|
+
return chars.join("");
|
|
20
|
+
}
|
|
21
|
+
function utf8_encode(str) {
|
|
22
|
+
let pos = 0;
|
|
23
|
+
let buf = new Uint8Array(str.length * 3);
|
|
24
|
+
for (let i = 0; i < str.length; i++) {
|
|
25
|
+
let code = str.charCodeAt(i);
|
|
26
|
+
if (code >= 0xD800 && code <= 0xDBFF) {
|
|
27
|
+
const nextCode = (i < str.length) ? str.charCodeAt(i + 1) : 0;
|
|
28
|
+
if (nextCode >= 0xDC00 && nextCode <= 0xDFFF) {
|
|
29
|
+
i += 1;
|
|
30
|
+
code = (code - 0xD800) * 0x400 + nextCode - 0xDC00 + 0x10000;
|
|
31
|
+
if (code > 0xFFFF) {
|
|
32
|
+
buf[pos++] = (0x1E << 3) | (code >>> 18);
|
|
33
|
+
buf[pos++] = (0x2 << 6) | ((code >>> 12) & 0x3F);
|
|
34
|
+
buf[pos++] = (0x2 << 6) | ((code >>> 6) & 0x3F);
|
|
35
|
+
buf[pos++] = (0x2 << 6) | (code & 0x3F);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
buf[pos++] = 0xEF;
|
|
40
|
+
buf[pos++] = 0xBF;
|
|
41
|
+
buf[pos++] = 0xBD;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else if (code <= 0x007F) {
|
|
45
|
+
buf[pos++] = (0x0 << 7) | code;
|
|
46
|
+
}
|
|
47
|
+
else if (code <= 0x07FF) {
|
|
48
|
+
buf[pos++] = (0x6 << 5) | (code >>> 6);
|
|
49
|
+
buf[pos++] = (0x2 << 6) | (code & 0x3F);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
buf[pos++] = (0xE << 4) | (code >>> 12);
|
|
53
|
+
buf[pos++] = (0x2 << 6) | ((code >>> 6) & 0x3F);
|
|
54
|
+
buf[pos++] = (0x2 << 6) | (code & 0x3F);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
buf = new Uint8Array(buf.buffer.slice(0, pos));
|
|
58
|
+
return buf;
|
|
59
|
+
}
|
|
60
|
+
function utf8_decode(bytes) {
|
|
61
|
+
let pos = 0;
|
|
62
|
+
const decodeUtf8 = () => {
|
|
63
|
+
const i1 = bytes[pos++];
|
|
64
|
+
if ((i1 & 0x80) === 0) {
|
|
65
|
+
return i1;
|
|
66
|
+
}
|
|
67
|
+
else if ((i1 & 0xE0) === 0xC0) {
|
|
68
|
+
const i2 = bytes[pos++];
|
|
69
|
+
return ((i1 & 0x1F) << 6) | (i2 & 0x3F);
|
|
70
|
+
}
|
|
71
|
+
else if ((i1 & 0xF0) === 0xE0) {
|
|
72
|
+
const i2 = bytes[pos++];
|
|
73
|
+
const i3 = bytes[pos++];
|
|
74
|
+
return ((i1 & 0x0F) << 12) | ((i2 & 0x3F) << 6) | (i3 & 0x3F);
|
|
75
|
+
}
|
|
76
|
+
else if ((i1 & 0xF8) === 0xF0) {
|
|
77
|
+
const i2 = bytes[pos++];
|
|
78
|
+
const i3 = bytes[pos++];
|
|
79
|
+
const i4 = bytes[pos++];
|
|
80
|
+
return ((i1 & 0x07) << 18) | ((i2 & 0x3F) << 12) | ((i3 & 0x3F) << 6) | (i4 & 0x3F);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
throw new RangeError("Invalid UTF8 byte: " + i1);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const chars = new Array();
|
|
87
|
+
while (pos < bytes.length) {
|
|
88
|
+
const code = decodeUtf8();
|
|
89
|
+
chars.push(String.fromCodePoint(code));
|
|
90
|
+
}
|
|
91
|
+
return chars.join("");
|
|
92
|
+
}
|
|
93
|
+
class UTF16LE {
|
|
94
|
+
getBytes(str, index, count) {
|
|
95
|
+
str = Array.isArray(str) ? str.join("") : str;
|
|
96
|
+
if (index != null && count != null) {
|
|
97
|
+
str = str.substring(index, index + count);
|
|
98
|
+
}
|
|
99
|
+
else if (index != null) {
|
|
100
|
+
str = str.substring(index);
|
|
101
|
+
}
|
|
102
|
+
// Allow to compile for Browser environment without @types/node being installed
|
|
103
|
+
// See https://github.com/fable-compiler/Fable/issues/4368
|
|
104
|
+
const g = globalThis;
|
|
105
|
+
if (typeof g.Buffer !== "undefined") {
|
|
106
|
+
const bytes = g.Buffer.from(str, "utf16le");
|
|
107
|
+
return new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
return utf16le_encode(str); // polyfill
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
getString(bytes, index, count) {
|
|
114
|
+
const array = ArrayBuffer.isView(bytes) ? bytes : Uint8Array.from(bytes);
|
|
115
|
+
let buffer = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
|
|
116
|
+
if (index != null && count != null) {
|
|
117
|
+
buffer = buffer.subarray(index, index + count);
|
|
118
|
+
}
|
|
119
|
+
else if (index != null) {
|
|
120
|
+
buffer = buffer.subarray(index);
|
|
121
|
+
}
|
|
122
|
+
// Allow to compile for Browser environment without @types/node being installed
|
|
123
|
+
// See https://github.com/fable-compiler/Fable/issues/4368
|
|
124
|
+
const g = globalThis;
|
|
125
|
+
if (typeof TextDecoder !== "undefined") {
|
|
126
|
+
return new TextDecoder("utf-16le").decode(buffer);
|
|
127
|
+
}
|
|
128
|
+
else if (typeof g.Buffer !== "undefined") {
|
|
129
|
+
return g.Buffer.from(buffer).toString("utf16le");
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
return utf16le_decode(buffer); // polyfill
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
class UTF8 {
|
|
137
|
+
getBytes(str, index, count) {
|
|
138
|
+
str = Array.isArray(str) ? str.join("") : str;
|
|
139
|
+
if (index != null && count != null) {
|
|
140
|
+
str = str.substring(index, index + count);
|
|
141
|
+
}
|
|
142
|
+
else if (index != null) {
|
|
143
|
+
str = str.substring(index);
|
|
144
|
+
}
|
|
145
|
+
// Allow to compile for Browser environment without @types/node being installed
|
|
146
|
+
// See https://github.com/fable-compiler/Fable/issues/4368
|
|
147
|
+
const g = globalThis;
|
|
148
|
+
if (typeof TextEncoder !== "undefined") {
|
|
149
|
+
return new TextEncoder().encode(str);
|
|
150
|
+
}
|
|
151
|
+
else if (typeof g.Buffer !== "undefined") {
|
|
152
|
+
const bytes = g.Buffer.from(str, "utf8");
|
|
153
|
+
return new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
return utf8_encode(str); // polyfill
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
getString(bytes, index, count) {
|
|
160
|
+
const array = ArrayBuffer.isView(bytes) ? bytes : Uint8Array.from(bytes);
|
|
161
|
+
let buffer = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
|
|
162
|
+
if (index != null && count != null) {
|
|
163
|
+
buffer = buffer.subarray(index, index + count);
|
|
164
|
+
}
|
|
165
|
+
else if (index != null) {
|
|
166
|
+
buffer = buffer.subarray(index);
|
|
167
|
+
}
|
|
168
|
+
// Allow to compile for Browser environment without @types/node being installed
|
|
169
|
+
// See https://github.com/fable-compiler/Fable/issues/4368
|
|
170
|
+
const g = globalThis;
|
|
171
|
+
if (typeof TextDecoder !== "undefined") {
|
|
172
|
+
return new TextDecoder().decode(buffer);
|
|
173
|
+
}
|
|
174
|
+
else if (typeof g.Buffer !== "undefined") {
|
|
175
|
+
return g.Buffer.from(buffer).toString("utf8");
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
return utf8_decode(buffer); // polyfill
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const _UTF16 = new UTF16LE();
|
|
183
|
+
const _UTF8 = new UTF8();
|
|
184
|
+
export function get_Unicode() { return _UTF16; }
|
|
185
|
+
export function get_UTF8() { return _UTF8; }
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { subscribe } from "./Observable.js";
|
|
2
|
+
import { some, value } from "./Option.js";
|
|
3
|
+
import { Choice_tryValueIfChoice1Of2, Choice_tryValueIfChoice2Of2 } from "./Choice.js";
|
|
4
|
+
export class Event$2 {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.delegates = [];
|
|
7
|
+
}
|
|
8
|
+
_add(d) {
|
|
9
|
+
this.delegates.push(d);
|
|
10
|
+
}
|
|
11
|
+
_remove(d) {
|
|
12
|
+
const index = this.delegates.indexOf(d);
|
|
13
|
+
if (index > -1) {
|
|
14
|
+
this.delegates.splice(index, 1);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
get Publish() {
|
|
18
|
+
return createEvent(h => { this._add(h); }, h => { this._remove(h); });
|
|
19
|
+
}
|
|
20
|
+
Trigger(senderOrValue, valueOrUndefined) {
|
|
21
|
+
// Disambiguate the overloads by arity, not by value: a two-argument call may
|
|
22
|
+
// legitimately pass `undefined` as the event value (e.g. unit events).
|
|
23
|
+
let sender = null;
|
|
24
|
+
let value;
|
|
25
|
+
if (arguments.length <= 1) {
|
|
26
|
+
value = senderOrValue;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
sender = senderOrValue;
|
|
30
|
+
value = valueOrUndefined;
|
|
31
|
+
}
|
|
32
|
+
this.delegates.forEach(f => { f(sender, value); });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export class Event extends Event$2 {
|
|
36
|
+
}
|
|
37
|
+
export function add(callback, sourceEvent) {
|
|
38
|
+
subscribe(callback, sourceEvent);
|
|
39
|
+
}
|
|
40
|
+
export function choose(chooser, sourceEvent) {
|
|
41
|
+
const ev = new Event();
|
|
42
|
+
add((t) => {
|
|
43
|
+
const u = chooser(t);
|
|
44
|
+
if (u != null) {
|
|
45
|
+
ev.Trigger(value(u));
|
|
46
|
+
}
|
|
47
|
+
}, sourceEvent);
|
|
48
|
+
return ev.Publish;
|
|
49
|
+
}
|
|
50
|
+
export function filter(predicate, sourceEvent) {
|
|
51
|
+
return choose((x) => predicate(x) ? some(x) : undefined, sourceEvent);
|
|
52
|
+
}
|
|
53
|
+
export function map(mapping, sourceEvent) {
|
|
54
|
+
const ev = new Event();
|
|
55
|
+
add((t) => ev.Trigger(mapping(t)), sourceEvent);
|
|
56
|
+
return ev.Publish;
|
|
57
|
+
}
|
|
58
|
+
export function merge(event1, event2) {
|
|
59
|
+
const ev = new Event();
|
|
60
|
+
const fn = (x) => ev.Trigger(x);
|
|
61
|
+
add(fn, event1);
|
|
62
|
+
add(fn, event2);
|
|
63
|
+
return ev.Publish;
|
|
64
|
+
}
|
|
65
|
+
export function pairwise(sourceEvent) {
|
|
66
|
+
const ev = new Event();
|
|
67
|
+
let last;
|
|
68
|
+
let haveLast = false;
|
|
69
|
+
add((next) => {
|
|
70
|
+
if (haveLast) {
|
|
71
|
+
ev.Trigger([last, next]);
|
|
72
|
+
}
|
|
73
|
+
last = next;
|
|
74
|
+
haveLast = true;
|
|
75
|
+
}, sourceEvent);
|
|
76
|
+
return ev.Publish;
|
|
77
|
+
}
|
|
78
|
+
export function partition(predicate, sourceEvent) {
|
|
79
|
+
return [filter(predicate, sourceEvent), filter((x) => !predicate(x), sourceEvent)];
|
|
80
|
+
}
|
|
81
|
+
export function scan(collector, state, sourceEvent) {
|
|
82
|
+
return map((t) => state = collector(state, t), sourceEvent);
|
|
83
|
+
}
|
|
84
|
+
export function split(splitter, sourceEvent) {
|
|
85
|
+
return [
|
|
86
|
+
choose((v) => Choice_tryValueIfChoice1Of2(splitter(v)), sourceEvent),
|
|
87
|
+
choose((v) => Choice_tryValueIfChoice2Of2(splitter(v)), sourceEvent),
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
export function createEvent(addHandler, removeHandler) {
|
|
91
|
+
return {
|
|
92
|
+
AddHandler(h) { addHandler(h); },
|
|
93
|
+
RemoveHandler(h) { removeHandler(h); },
|
|
94
|
+
Subscribe(r) {
|
|
95
|
+
const h = ((_, args) => r.OnNext(args));
|
|
96
|
+
addHandler(h);
|
|
97
|
+
return {
|
|
98
|
+
Dispose() { removeHandler(h); }
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { compare, physicalHash, equals as equals_1, structuralHash } from "./Util.js";
|
|
2
|
+
export function HashIdentity_FromFunctions(hasher, equals) {
|
|
3
|
+
return {
|
|
4
|
+
GetHashCode(x) {
|
|
5
|
+
return hasher(x) | 0;
|
|
6
|
+
},
|
|
7
|
+
Equals(x_1, y) {
|
|
8
|
+
return (x_1 == null) ? (y == null) : ((y == null) ? false : equals(x_1, y));
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export function HashIdentity_Structural() {
|
|
13
|
+
return {
|
|
14
|
+
GetHashCode(x) {
|
|
15
|
+
return structuralHash(x) | 0;
|
|
16
|
+
},
|
|
17
|
+
Equals(x_1, y) {
|
|
18
|
+
return equals_1(x_1, y);
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function HashIdentity_Reference() {
|
|
23
|
+
return {
|
|
24
|
+
GetHashCode(x) {
|
|
25
|
+
return physicalHash(x) | 0;
|
|
26
|
+
},
|
|
27
|
+
Equals(x_1, y) {
|
|
28
|
+
return equals_1(x_1, y);
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function ComparisonIdentity_FromFunction(comparer) {
|
|
33
|
+
return {
|
|
34
|
+
Compare(x, y) {
|
|
35
|
+
return ((x == null) ? ((y == null) ? 0 : -1) : ((y == null) ? 1 : comparer(x, y))) | 0;
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export function ComparisonIdentity_Structural() {
|
|
40
|
+
return {
|
|
41
|
+
Compare(x, y) {
|
|
42
|
+
return compare(x, y) | 0;
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { class_type } from "./Reflection.js";
|
|
2
|
+
import { addRangeInPlace } from "./Array.js";
|
|
3
|
+
import { toList } from "./Seq.js";
|
|
4
|
+
export class ListCollector$1 {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.collector = [];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export function ListCollector$1_$reflection(gen0) {
|
|
10
|
+
return class_type("Microsoft.FSharp.Core.CompilerServices.ListCollector`1", [gen0], ListCollector$1);
|
|
11
|
+
}
|
|
12
|
+
export function ListCollector$1_$ctor() {
|
|
13
|
+
return new ListCollector$1();
|
|
14
|
+
}
|
|
15
|
+
export function ListCollector$1__Add_2B595(this$, value) {
|
|
16
|
+
void (this$.collector.push(value));
|
|
17
|
+
}
|
|
18
|
+
export function ListCollector$1__AddMany_BB573A(this$, values) {
|
|
19
|
+
addRangeInPlace(values, this$.collector);
|
|
20
|
+
}
|
|
21
|
+
export function ListCollector$1__AddManyAndClose_BB573A(this$, values) {
|
|
22
|
+
addRangeInPlace(values, this$.collector);
|
|
23
|
+
return toList(this$.collector);
|
|
24
|
+
}
|
|
25
|
+
export function ListCollector$1__Close(this$) {
|
|
26
|
+
return toList(this$.collector);
|
|
27
|
+
}
|