@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.
- 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 +1 -1
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { defaultOf, Exception } from "./Util.js";
|
|
2
|
+
import { class_type } from "./Reflection.js";
|
|
3
|
+
import { SR_Arg_ArgumentOutOfRangeException, SR_ArgumentNull_Generic, SR_Arg_ArgumentException, SR_Arg_ParamName_Name, SR_Arg_TimeoutException, SR_Arg_StackOverflowException, SR_Arg_RankException, SR_Arg_OverflowException, SR_Arg_OutOfMemoryException, SR_Arg_NullReferenceException, SR_Arg_NotSupportedException, SR_Arg_NotImplementedException, SR_Arg_NotFiniteNumberException, SR_Arg_InvalidOperationException, SR_Arg_IndexOutOfRangeException, SR_Arg_FormatException, SR_Arg_DivideByZero, SR_Arg_ArithmeticException, SR_Arg_ApplicationException, SR_Arg_SystemException } from "./Global.js";
|
|
4
|
+
import { isNullOrEmpty } from "./String.js";
|
|
5
|
+
export class SystemException extends Exception {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export function SystemException_$reflection() {
|
|
11
|
+
return class_type("System.SystemException", undefined, SystemException, class_type("System.Exception"));
|
|
12
|
+
}
|
|
13
|
+
export function SystemException_$ctor_Z721C83C5(message) {
|
|
14
|
+
return new SystemException(message);
|
|
15
|
+
}
|
|
16
|
+
export function SystemException_$ctor() {
|
|
17
|
+
return SystemException_$ctor_Z721C83C5(SR_Arg_SystemException);
|
|
18
|
+
}
|
|
19
|
+
export class ApplicationException extends Exception {
|
|
20
|
+
constructor(message) {
|
|
21
|
+
super(message);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function ApplicationException_$reflection() {
|
|
25
|
+
return class_type("System.ApplicationException", undefined, ApplicationException, class_type("System.Exception"));
|
|
26
|
+
}
|
|
27
|
+
export function ApplicationException_$ctor_Z721C83C5(message) {
|
|
28
|
+
return new ApplicationException(message);
|
|
29
|
+
}
|
|
30
|
+
export function ApplicationException_$ctor() {
|
|
31
|
+
return ApplicationException_$ctor_Z721C83C5(SR_Arg_ApplicationException);
|
|
32
|
+
}
|
|
33
|
+
export class ArithmeticException extends Exception {
|
|
34
|
+
constructor(message) {
|
|
35
|
+
super(message);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function ArithmeticException_$reflection() {
|
|
39
|
+
return class_type("System.ArithmeticException", undefined, ArithmeticException, class_type("System.Exception"));
|
|
40
|
+
}
|
|
41
|
+
export function ArithmeticException_$ctor_Z721C83C5(message) {
|
|
42
|
+
return new ArithmeticException(message);
|
|
43
|
+
}
|
|
44
|
+
export function ArithmeticException_$ctor() {
|
|
45
|
+
return ArithmeticException_$ctor_Z721C83C5(SR_Arg_ArithmeticException);
|
|
46
|
+
}
|
|
47
|
+
export class DivideByZeroException extends Exception {
|
|
48
|
+
constructor(message) {
|
|
49
|
+
super(message);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export function DivideByZeroException_$reflection() {
|
|
53
|
+
return class_type("System.DivideByZeroException", undefined, DivideByZeroException, class_type("System.Exception"));
|
|
54
|
+
}
|
|
55
|
+
export function DivideByZeroException_$ctor_Z721C83C5(message) {
|
|
56
|
+
return new DivideByZeroException(message);
|
|
57
|
+
}
|
|
58
|
+
export function DivideByZeroException_$ctor() {
|
|
59
|
+
return DivideByZeroException_$ctor_Z721C83C5(SR_Arg_DivideByZero);
|
|
60
|
+
}
|
|
61
|
+
export class FormatException extends Exception {
|
|
62
|
+
constructor(message) {
|
|
63
|
+
super(message);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export function FormatException_$reflection() {
|
|
67
|
+
return class_type("System.FormatException", undefined, FormatException, class_type("System.Exception"));
|
|
68
|
+
}
|
|
69
|
+
export function FormatException_$ctor_Z721C83C5(message) {
|
|
70
|
+
return new FormatException(message);
|
|
71
|
+
}
|
|
72
|
+
export function FormatException_$ctor() {
|
|
73
|
+
return FormatException_$ctor_Z721C83C5(SR_Arg_FormatException);
|
|
74
|
+
}
|
|
75
|
+
export class IndexOutOfRangeException extends Exception {
|
|
76
|
+
constructor(message) {
|
|
77
|
+
super(message);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export function IndexOutOfRangeException_$reflection() {
|
|
81
|
+
return class_type("System.IndexOutOfRangeException", undefined, IndexOutOfRangeException, class_type("System.Exception"));
|
|
82
|
+
}
|
|
83
|
+
export function IndexOutOfRangeException_$ctor_Z721C83C5(message) {
|
|
84
|
+
return new IndexOutOfRangeException(message);
|
|
85
|
+
}
|
|
86
|
+
export function IndexOutOfRangeException_$ctor() {
|
|
87
|
+
return IndexOutOfRangeException_$ctor_Z721C83C5(SR_Arg_IndexOutOfRangeException);
|
|
88
|
+
}
|
|
89
|
+
export class InvalidOperationException extends Exception {
|
|
90
|
+
constructor(message) {
|
|
91
|
+
super(message);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export function InvalidOperationException_$reflection() {
|
|
95
|
+
return class_type("System.InvalidOperationException", undefined, InvalidOperationException, class_type("System.Exception"));
|
|
96
|
+
}
|
|
97
|
+
export function InvalidOperationException_$ctor_Z721C83C5(message) {
|
|
98
|
+
return new InvalidOperationException(message);
|
|
99
|
+
}
|
|
100
|
+
export function InvalidOperationException_$ctor() {
|
|
101
|
+
return InvalidOperationException_$ctor_Z721C83C5(SR_Arg_InvalidOperationException);
|
|
102
|
+
}
|
|
103
|
+
export class NotFiniteNumberException extends Exception {
|
|
104
|
+
constructor(message) {
|
|
105
|
+
super(message);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export function NotFiniteNumberException_$reflection() {
|
|
109
|
+
return class_type("System.NotFiniteNumberException", undefined, NotFiniteNumberException, class_type("System.Exception"));
|
|
110
|
+
}
|
|
111
|
+
export function NotFiniteNumberException_$ctor_Z721C83C5(message) {
|
|
112
|
+
return new NotFiniteNumberException(message);
|
|
113
|
+
}
|
|
114
|
+
export function NotFiniteNumberException_$ctor() {
|
|
115
|
+
return NotFiniteNumberException_$ctor_Z721C83C5(SR_Arg_NotFiniteNumberException);
|
|
116
|
+
}
|
|
117
|
+
export class NotImplementedException extends Exception {
|
|
118
|
+
constructor(message) {
|
|
119
|
+
super(message);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
export function NotImplementedException_$reflection() {
|
|
123
|
+
return class_type("System.NotImplementedException", undefined, NotImplementedException, class_type("System.Exception"));
|
|
124
|
+
}
|
|
125
|
+
export function NotImplementedException_$ctor_Z721C83C5(message) {
|
|
126
|
+
return new NotImplementedException(message);
|
|
127
|
+
}
|
|
128
|
+
export function NotImplementedException_$ctor() {
|
|
129
|
+
return NotImplementedException_$ctor_Z721C83C5(SR_Arg_NotImplementedException);
|
|
130
|
+
}
|
|
131
|
+
export class NotSupportedException extends Exception {
|
|
132
|
+
constructor(message) {
|
|
133
|
+
super(message);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
export function NotSupportedException_$reflection() {
|
|
137
|
+
return class_type("System.NotSupportedException", undefined, NotSupportedException, class_type("System.Exception"));
|
|
138
|
+
}
|
|
139
|
+
export function NotSupportedException_$ctor_Z721C83C5(message) {
|
|
140
|
+
return new NotSupportedException(message);
|
|
141
|
+
}
|
|
142
|
+
export function NotSupportedException_$ctor() {
|
|
143
|
+
return NotSupportedException_$ctor_Z721C83C5(SR_Arg_NotSupportedException);
|
|
144
|
+
}
|
|
145
|
+
export class NullReferenceException extends Exception {
|
|
146
|
+
constructor(message) {
|
|
147
|
+
super(message);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
export function NullReferenceException_$reflection() {
|
|
151
|
+
return class_type("System.NullReferenceException", undefined, NullReferenceException, class_type("System.Exception"));
|
|
152
|
+
}
|
|
153
|
+
export function NullReferenceException_$ctor_Z721C83C5(message) {
|
|
154
|
+
return new NullReferenceException(message);
|
|
155
|
+
}
|
|
156
|
+
export function NullReferenceException_$ctor() {
|
|
157
|
+
return NullReferenceException_$ctor_Z721C83C5(SR_Arg_NullReferenceException);
|
|
158
|
+
}
|
|
159
|
+
export class OutOfMemoryException extends Exception {
|
|
160
|
+
constructor(message) {
|
|
161
|
+
super(message);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
export function OutOfMemoryException_$reflection() {
|
|
165
|
+
return class_type("System.OutOfMemoryException", undefined, OutOfMemoryException, class_type("System.Exception"));
|
|
166
|
+
}
|
|
167
|
+
export function OutOfMemoryException_$ctor_Z721C83C5(message) {
|
|
168
|
+
return new OutOfMemoryException(message);
|
|
169
|
+
}
|
|
170
|
+
export function OutOfMemoryException_$ctor() {
|
|
171
|
+
return OutOfMemoryException_$ctor_Z721C83C5(SR_Arg_OutOfMemoryException);
|
|
172
|
+
}
|
|
173
|
+
export class OverflowException extends Exception {
|
|
174
|
+
constructor(message) {
|
|
175
|
+
super(message);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
export function OverflowException_$reflection() {
|
|
179
|
+
return class_type("System.OverflowException", undefined, OverflowException, class_type("System.Exception"));
|
|
180
|
+
}
|
|
181
|
+
export function OverflowException_$ctor_Z721C83C5(message) {
|
|
182
|
+
return new OverflowException(message);
|
|
183
|
+
}
|
|
184
|
+
export function OverflowException_$ctor() {
|
|
185
|
+
return OverflowException_$ctor_Z721C83C5(SR_Arg_OverflowException);
|
|
186
|
+
}
|
|
187
|
+
export class RankException extends Exception {
|
|
188
|
+
constructor(message) {
|
|
189
|
+
super(message);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
export function RankException_$reflection() {
|
|
193
|
+
return class_type("System.RankException", undefined, RankException, class_type("System.Exception"));
|
|
194
|
+
}
|
|
195
|
+
export function RankException_$ctor_Z721C83C5(message) {
|
|
196
|
+
return new RankException(message);
|
|
197
|
+
}
|
|
198
|
+
export function RankException_$ctor() {
|
|
199
|
+
return RankException_$ctor_Z721C83C5(SR_Arg_RankException);
|
|
200
|
+
}
|
|
201
|
+
export class StackOverflowException extends Exception {
|
|
202
|
+
constructor(message) {
|
|
203
|
+
super(message);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
export function StackOverflowException_$reflection() {
|
|
207
|
+
return class_type("System.StackOverflowException", undefined, StackOverflowException, class_type("System.Exception"));
|
|
208
|
+
}
|
|
209
|
+
export function StackOverflowException_$ctor_Z721C83C5(message) {
|
|
210
|
+
return new StackOverflowException(message);
|
|
211
|
+
}
|
|
212
|
+
export function StackOverflowException_$ctor() {
|
|
213
|
+
return StackOverflowException_$ctor_Z721C83C5(SR_Arg_StackOverflowException);
|
|
214
|
+
}
|
|
215
|
+
export class TimeoutException extends Exception {
|
|
216
|
+
constructor(message) {
|
|
217
|
+
super(message);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
export function TimeoutException_$reflection() {
|
|
221
|
+
return class_type("System.TimeoutException", undefined, TimeoutException, class_type("System.Exception"));
|
|
222
|
+
}
|
|
223
|
+
export function TimeoutException_$ctor_Z721C83C5(message) {
|
|
224
|
+
return new TimeoutException(message);
|
|
225
|
+
}
|
|
226
|
+
export function TimeoutException_$ctor() {
|
|
227
|
+
return TimeoutException_$ctor_Z721C83C5(SR_Arg_TimeoutException);
|
|
228
|
+
}
|
|
229
|
+
export class ArgumentException extends Exception {
|
|
230
|
+
constructor(message, paramName, innerException) {
|
|
231
|
+
super(isNullOrEmpty(paramName) ? message : (((message + SR_Arg_ParamName_Name) + paramName) + "\')"), innerException);
|
|
232
|
+
this.paramName = paramName;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
export function ArgumentException_$reflection() {
|
|
236
|
+
return class_type("System.ArgumentException", undefined, ArgumentException, class_type("System.Exception"));
|
|
237
|
+
}
|
|
238
|
+
export function ArgumentException_$ctor_Z60A2B367(message, paramName, innerException) {
|
|
239
|
+
return new ArgumentException(message, paramName, innerException);
|
|
240
|
+
}
|
|
241
|
+
export function ArgumentException_$ctor() {
|
|
242
|
+
return ArgumentException_$ctor_Z60A2B367(SR_Arg_ArgumentException, "", defaultOf());
|
|
243
|
+
}
|
|
244
|
+
export function ArgumentException_$ctor_Z721C83C5(message) {
|
|
245
|
+
return ArgumentException_$ctor_Z60A2B367(message, "", defaultOf());
|
|
246
|
+
}
|
|
247
|
+
export function ArgumentException_$ctor_Z384F8060(message, paramName) {
|
|
248
|
+
return ArgumentException_$ctor_Z60A2B367(message, paramName, defaultOf());
|
|
249
|
+
}
|
|
250
|
+
export function ArgumentException_$ctor_68CE3CA2(message, innerException) {
|
|
251
|
+
return ArgumentException_$ctor_Z60A2B367(message, "", innerException);
|
|
252
|
+
}
|
|
253
|
+
export function ArgumentException__get_ParamName(_) {
|
|
254
|
+
return _.paramName;
|
|
255
|
+
}
|
|
256
|
+
export class ArgumentNullException extends ArgumentException {
|
|
257
|
+
constructor(paramName, message) {
|
|
258
|
+
super(message, paramName, defaultOf());
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
export function ArgumentNullException_$reflection() {
|
|
262
|
+
return class_type("System.ArgumentNullException", undefined, ArgumentNullException, ArgumentException_$reflection());
|
|
263
|
+
}
|
|
264
|
+
export function ArgumentNullException_$ctor_Z384F8060(paramName, message) {
|
|
265
|
+
return new ArgumentNullException(paramName, message);
|
|
266
|
+
}
|
|
267
|
+
export function ArgumentNullException_$ctor_Z721C83C5(paramName) {
|
|
268
|
+
return ArgumentNullException_$ctor_Z384F8060(paramName, SR_ArgumentNull_Generic);
|
|
269
|
+
}
|
|
270
|
+
export function ArgumentNullException_$ctor() {
|
|
271
|
+
return ArgumentNullException_$ctor_Z721C83C5("");
|
|
272
|
+
}
|
|
273
|
+
export class ArgumentOutOfRangeException extends ArgumentException {
|
|
274
|
+
constructor(paramName, message) {
|
|
275
|
+
super(message, paramName, defaultOf());
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
export function ArgumentOutOfRangeException_$reflection() {
|
|
279
|
+
return class_type("System.ArgumentOutOfRangeException", undefined, ArgumentOutOfRangeException, ArgumentException_$reflection());
|
|
280
|
+
}
|
|
281
|
+
export function ArgumentOutOfRangeException_$ctor_Z384F8060(paramName, message) {
|
|
282
|
+
return new ArgumentOutOfRangeException(paramName, message);
|
|
283
|
+
}
|
|
284
|
+
export function ArgumentOutOfRangeException_$ctor_Z721C83C5(paramName) {
|
|
285
|
+
return ArgumentOutOfRangeException_$ctor_Z384F8060(paramName, SR_Arg_ArgumentOutOfRangeException);
|
|
286
|
+
}
|
|
287
|
+
export function ArgumentOutOfRangeException_$ctor() {
|
|
288
|
+
return ArgumentOutOfRangeException_$ctor_Z721C83C5("");
|
|
289
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { OperationCanceledException } from "./AsyncBuilder.js";
|
|
2
|
+
export class TaskCompletionSource {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.task = new Promise((resolve, reject) => {
|
|
5
|
+
this._resolve = resolve;
|
|
6
|
+
this._reject = reject;
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
SetResult(value) { this._resolve(value); }
|
|
10
|
+
SetException(error) { this._reject(error); }
|
|
11
|
+
SetCancelled() { this._reject(new OperationCanceledException()); }
|
|
12
|
+
get_Task() { return this.task; }
|
|
13
|
+
}
|
|
14
|
+
export function fromResult(value) {
|
|
15
|
+
return Promise.resolve(value);
|
|
16
|
+
}
|
|
17
|
+
export function zero() {
|
|
18
|
+
return Promise.resolve();
|
|
19
|
+
}
|
|
20
|
+
// Task<T> = Promise<T> in JS/TS. GetAwaiter/GetResult return the Promise itself;
|
|
21
|
+
// callers should use Async.AwaitTask to extract the value in an async context.
|
|
22
|
+
export function getAwaiter(t) {
|
|
23
|
+
return t;
|
|
24
|
+
}
|
|
25
|
+
export function getResult(t) {
|
|
26
|
+
return t;
|
|
27
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { zero } from "./Task.js";
|
|
2
|
+
export class TaskBuilder {
|
|
3
|
+
Bind(computation, binder) {
|
|
4
|
+
return computation.then(binder);
|
|
5
|
+
}
|
|
6
|
+
Combine(computation1, computation2) {
|
|
7
|
+
return computation1.then(computation2);
|
|
8
|
+
}
|
|
9
|
+
Delay(generator) {
|
|
10
|
+
return generator;
|
|
11
|
+
}
|
|
12
|
+
For(sequence, body) {
|
|
13
|
+
const iter = sequence[Symbol.iterator]();
|
|
14
|
+
let cur = iter.next();
|
|
15
|
+
return this.While(() => !cur.done, this.Delay(() => {
|
|
16
|
+
const res = body(cur.value);
|
|
17
|
+
cur = iter.next();
|
|
18
|
+
return res;
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
Return(value) {
|
|
22
|
+
return Promise.resolve(value);
|
|
23
|
+
}
|
|
24
|
+
ReturnFrom(computation) {
|
|
25
|
+
return computation;
|
|
26
|
+
}
|
|
27
|
+
TryFinally(computation, compensation) {
|
|
28
|
+
try {
|
|
29
|
+
return computation().finally(compensation);
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
compensation();
|
|
33
|
+
return Promise.reject(e);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
TryWith(computation, catchHandler) {
|
|
37
|
+
try {
|
|
38
|
+
return computation().catch(catchHandler);
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
try {
|
|
42
|
+
return catchHandler(e);
|
|
43
|
+
}
|
|
44
|
+
catch (e2) {
|
|
45
|
+
return Promise.reject(e2);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
Using(resource, binder) {
|
|
50
|
+
return this.TryFinally(() => binder(resource), () => resource.Dispose());
|
|
51
|
+
}
|
|
52
|
+
While(guard, computation) {
|
|
53
|
+
return (async () => {
|
|
54
|
+
while (guard()) {
|
|
55
|
+
await computation();
|
|
56
|
+
}
|
|
57
|
+
})();
|
|
58
|
+
}
|
|
59
|
+
Zero() {
|
|
60
|
+
return zero();
|
|
61
|
+
}
|
|
62
|
+
Run(computation) {
|
|
63
|
+
try {
|
|
64
|
+
return computation();
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
return Promise.reject(e);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export const singleton = new TaskBuilder();
|
|
72
|
+
export function task() { return singleton; }
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { hours, minutes, seconds, milliseconds } from "./TimeSpan.js";
|
|
2
|
+
import { Exception, DateTimeKind, padWithZeros } from "./Util.js";
|
|
3
|
+
const millisecondsPerDay = 86400000;
|
|
4
|
+
export function create(h = 0, m = 0, s = 0, ms = 0) {
|
|
5
|
+
if (h < 0 || m < 0 || s < 0 || ms < 0)
|
|
6
|
+
throw new Exception("The parameters describe an unrepresentable TimeOnly.");
|
|
7
|
+
return h * 3600000 + m * 60000 + s * 1000 + ms;
|
|
8
|
+
}
|
|
9
|
+
export function fromTicks(ticks) {
|
|
10
|
+
return Number(BigInt(ticks) / 10000n);
|
|
11
|
+
}
|
|
12
|
+
export function fromTimeSpan(timeSpan) {
|
|
13
|
+
if (timeSpan < 0 || timeSpan >= millisecondsPerDay)
|
|
14
|
+
throw new Exception("The TimeSpan describes an unrepresentable TimeOnly.");
|
|
15
|
+
return timeSpan;
|
|
16
|
+
}
|
|
17
|
+
export function fromDateTime(d) {
|
|
18
|
+
return d.kind === DateTimeKind.Utc
|
|
19
|
+
? create(d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds())
|
|
20
|
+
: create(d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds());
|
|
21
|
+
}
|
|
22
|
+
export function maxValue() {
|
|
23
|
+
// This is "23:59:59.999"
|
|
24
|
+
return millisecondsPerDay - 1;
|
|
25
|
+
}
|
|
26
|
+
export function add(t, ts, wrappedDays) {
|
|
27
|
+
if (wrappedDays === undefined) {
|
|
28
|
+
const t2 = (t + ts) % millisecondsPerDay;
|
|
29
|
+
return t2 < 0 ? millisecondsPerDay + t2 : t2;
|
|
30
|
+
}
|
|
31
|
+
wrappedDays.contents = ts / millisecondsPerDay;
|
|
32
|
+
let newMs = t + ts % millisecondsPerDay;
|
|
33
|
+
if (newMs < 0) {
|
|
34
|
+
wrappedDays.contents--;
|
|
35
|
+
newMs += millisecondsPerDay;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
if (newMs >= millisecondsPerDay) {
|
|
39
|
+
wrappedDays.contents++;
|
|
40
|
+
newMs -= millisecondsPerDay;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return newMs;
|
|
44
|
+
}
|
|
45
|
+
export function addHours(t, h) {
|
|
46
|
+
return add(t, h * 3600000);
|
|
47
|
+
}
|
|
48
|
+
export function addMinutes(t, m) {
|
|
49
|
+
return add(t, m * 60000);
|
|
50
|
+
}
|
|
51
|
+
export function isBetween(t, start, end) {
|
|
52
|
+
return start <= end
|
|
53
|
+
? (start <= t && end > t)
|
|
54
|
+
: (start <= t || end > t);
|
|
55
|
+
}
|
|
56
|
+
export function toString(t, format = "t", _provider) {
|
|
57
|
+
if (["r", "R", "o", "O", "t", "T"].indexOf(format) === -1) {
|
|
58
|
+
throw new Exception("Custom formats are not supported");
|
|
59
|
+
}
|
|
60
|
+
const base = `${padWithZeros(hours(t), 2)}:${padWithZeros(minutes(t), 2)}`;
|
|
61
|
+
if (format === "t")
|
|
62
|
+
return base;
|
|
63
|
+
const s = padWithZeros(seconds(t), 2);
|
|
64
|
+
// We're limited to millisecond precision, so the last 4 digits will always be 0
|
|
65
|
+
return `${base}${format === "o" || format === "O" ? `:${s}.${padWithZeros(milliseconds(t), 3)}0000` : `:${s}`}`;
|
|
66
|
+
}
|
|
67
|
+
export function parse(str) {
|
|
68
|
+
// Allowed format types:
|
|
69
|
+
// hh:mm
|
|
70
|
+
// hh:mm:ss
|
|
71
|
+
// hh:mm:ss.fffffff
|
|
72
|
+
const r = /^\s*([0-1]?\d|2[0-3])\s*:\s*([0-5]?\d)(\s*:\s*([0-5]?\d)(\.(\d+))?)?\s*$/.exec(str);
|
|
73
|
+
if (r != null && r[1] != null && r[2] != null) {
|
|
74
|
+
let ms = 0;
|
|
75
|
+
let s = 0;
|
|
76
|
+
const h = +r[1];
|
|
77
|
+
const m = +r[2];
|
|
78
|
+
if (r[4] != null) {
|
|
79
|
+
s = +r[4];
|
|
80
|
+
}
|
|
81
|
+
if (r[6] != null) {
|
|
82
|
+
// Depending on the number of decimals passed, we need to adapt the numbers
|
|
83
|
+
switch (r[6].length) {
|
|
84
|
+
case 1:
|
|
85
|
+
ms = +r[6] * 100;
|
|
86
|
+
break;
|
|
87
|
+
case 2:
|
|
88
|
+
ms = +r[6] * 10;
|
|
89
|
+
break;
|
|
90
|
+
case 3:
|
|
91
|
+
ms = +r[6];
|
|
92
|
+
break;
|
|
93
|
+
case 4:
|
|
94
|
+
ms = +r[6] / 10;
|
|
95
|
+
break;
|
|
96
|
+
case 5:
|
|
97
|
+
ms = +r[6] / 100;
|
|
98
|
+
break;
|
|
99
|
+
case 6:
|
|
100
|
+
ms = +r[6] / 1000;
|
|
101
|
+
break;
|
|
102
|
+
default:
|
|
103
|
+
ms = +r[6].substring(0, 7) / 10000;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return create(h, m, s, Math.trunc(ms));
|
|
108
|
+
}
|
|
109
|
+
throw new Exception(`String '${str}' was not recognized as a valid TimeOnly.`);
|
|
110
|
+
}
|
|
111
|
+
export function tryParse(v, defValue) {
|
|
112
|
+
try {
|
|
113
|
+
defValue.contents = parse(v);
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
export function op_Subtraction(left, right) {
|
|
121
|
+
return add(left, -right);
|
|
122
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { toInt64, fromFloat64 } from "./BigInt.js";
|
|
2
|
+
import { fromTicks as TimeSpan_fromTicks, totalNanoseconds as TimeSpan_totalNanoseconds } from "./TimeSpanTemporal.js";
|
|
3
|
+
import { Exception } from "./Util.js";
|
|
4
|
+
export const PlainTime = Temporal.PlainTime;
|
|
5
|
+
// The generic equality/comparison/hashing helpers in Util.ts dispatch at runtime
|
|
6
|
+
// on .NET-style Equals/CompareTo/GetHashCode methods. Attach them so TimeOnly
|
|
7
|
+
// also works in generic contexts: records, tuples, erased generics, etc.
|
|
8
|
+
const proto = Temporal.PlainTime.prototype;
|
|
9
|
+
proto.Equals = function (other) { return this.equals(other); };
|
|
10
|
+
proto.CompareTo = function (other) { return Temporal.PlainTime.compare(this, other); };
|
|
11
|
+
proto.GetHashCode = function () { return hash(this); };
|
|
12
|
+
// Lets String.Format format this value without String.ts importing this module (see String.ts)
|
|
13
|
+
proto[Symbol.for("Fable.DateTimeFormattable")] = function (format) { return toString(this, format); };
|
|
14
|
+
const nanosecondsPerDay = 86400000000000;
|
|
15
|
+
const nanosecondsPerDayBig = 86400000000000n;
|
|
16
|
+
function totalNanoseconds(t) {
|
|
17
|
+
return ((t.hour * 60 + t.minute) * 60 + t.second) * 1000000000
|
|
18
|
+
+ t.millisecond * 1000000 + t.microsecond * 1000 + t.nanosecond;
|
|
19
|
+
}
|
|
20
|
+
function fromNanoseconds(n) {
|
|
21
|
+
return new Temporal.PlainTime(Math.floor(n / 3600000000000), Math.floor(n / 60000000000) % 60, Math.floor(n / 1000000000) % 60, Math.floor(n / 1000000) % 1000, Math.floor(n / 1000) % 1000, n % 1000);
|
|
22
|
+
}
|
|
23
|
+
export function create(h = 0, m = 0, s = 0, ms = 0, us = 0) {
|
|
24
|
+
return new Temporal.PlainTime(h, m, s, ms, us);
|
|
25
|
+
}
|
|
26
|
+
export function fromTicks(ticks) {
|
|
27
|
+
return fromNanoseconds(Number(BigInt(ticks) * 100n));
|
|
28
|
+
}
|
|
29
|
+
export function fromTimeSpan(timeSpan) {
|
|
30
|
+
const ns = Number(TimeSpan_totalNanoseconds(timeSpan));
|
|
31
|
+
if (ns < 0 || ns >= nanosecondsPerDay)
|
|
32
|
+
throw new Exception("The TimeSpan describes an unrepresentable TimeOnly.");
|
|
33
|
+
return fromNanoseconds(ns);
|
|
34
|
+
}
|
|
35
|
+
export function fromDateTime(d) {
|
|
36
|
+
// Under the Temporal representation a DateTime is a PlainDateTime (kind-agnostic wall-clock)
|
|
37
|
+
return new Temporal.PlainTime(d.hour, d.minute, d.second, d.millisecond, d.microsecond, d.nanosecond);
|
|
38
|
+
}
|
|
39
|
+
export function minValue() {
|
|
40
|
+
return new Temporal.PlainTime();
|
|
41
|
+
}
|
|
42
|
+
export function maxValue() {
|
|
43
|
+
// This is "23:59:59.9999999" (.NET tick precision)
|
|
44
|
+
return new Temporal.PlainTime(23, 59, 59, 999, 999, 900);
|
|
45
|
+
}
|
|
46
|
+
export function ticks(t) {
|
|
47
|
+
return toInt64(fromFloat64(totalNanoseconds(t) / 100));
|
|
48
|
+
}
|
|
49
|
+
export function toTimeSpan(t) {
|
|
50
|
+
// TimeOnly is tick-precise, so the nanosecond count is always a multiple of 100.
|
|
51
|
+
return TimeSpan_fromTicks(Math.round(totalNanoseconds(t) / 100));
|
|
52
|
+
}
|
|
53
|
+
// Kept in bigint: a TimeOnly itself always fits a float64 exactly (under 2^47 ns),
|
|
54
|
+
// but the amount added does not — a TimeSpan of more than ~104 days already
|
|
55
|
+
// exceeds Number.MAX_SAFE_INTEGER in nanoseconds, and .NET wraps it modulo a day
|
|
56
|
+
// rather than saturating, so the low ticks are the part that must survive.
|
|
57
|
+
function addNanoseconds(t, deltaNs, wrappedDays) {
|
|
58
|
+
const totalNs = BigInt(totalNanoseconds(t)) + deltaNs;
|
|
59
|
+
let days = totalNs / nanosecondsPerDayBig;
|
|
60
|
+
let remainder = totalNs % nanosecondsPerDayBig;
|
|
61
|
+
// BigInt division truncates toward zero; .NET wraps toward the previous day.
|
|
62
|
+
if (remainder < 0n) {
|
|
63
|
+
remainder += nanosecondsPerDayBig;
|
|
64
|
+
days -= 1n;
|
|
65
|
+
}
|
|
66
|
+
if (wrappedDays !== undefined) {
|
|
67
|
+
wrappedDays.contents = Number(days);
|
|
68
|
+
}
|
|
69
|
+
return fromNanoseconds(Number(remainder));
|
|
70
|
+
}
|
|
71
|
+
export function add(t, ts, wrappedDays) {
|
|
72
|
+
return addNanoseconds(t, TimeSpan_totalNanoseconds(ts), wrappedDays);
|
|
73
|
+
}
|
|
74
|
+
export function addHours(t, h) {
|
|
75
|
+
// Scale to ticks first, as .NET does, then widen — `h` hours in nanoseconds
|
|
76
|
+
// overflows the exact float64 range two orders of magnitude sooner.
|
|
77
|
+
return addNanoseconds(t, BigInt(Math.round(h * 36000000000)) * 100n);
|
|
78
|
+
}
|
|
79
|
+
export function addMinutes(t, m) {
|
|
80
|
+
return addNanoseconds(t, BigInt(Math.round(m * 600000000)) * 100n);
|
|
81
|
+
}
|
|
82
|
+
export function isBetween(t, start, end) {
|
|
83
|
+
return Temporal.PlainTime.compare(start, end) <= 0
|
|
84
|
+
? (Temporal.PlainTime.compare(start, t) <= 0 && Temporal.PlainTime.compare(end, t) > 0)
|
|
85
|
+
: (Temporal.PlainTime.compare(start, t) <= 0 || Temporal.PlainTime.compare(end, t) > 0);
|
|
86
|
+
}
|
|
87
|
+
export function equals(x, y) {
|
|
88
|
+
return x.equals(y);
|
|
89
|
+
}
|
|
90
|
+
export function compare(x, y) {
|
|
91
|
+
return Temporal.PlainTime.compare(x, y);
|
|
92
|
+
}
|
|
93
|
+
export function hash(t) {
|
|
94
|
+
return totalNanoseconds(t) % 2147483647;
|
|
95
|
+
}
|
|
96
|
+
export function op_Subtraction(left, right) {
|
|
97
|
+
// Returns the elapsed TimeSpan, wrapping around midnight
|
|
98
|
+
const ns = (totalNanoseconds(left) - totalNanoseconds(right) + nanosecondsPerDay) % nanosecondsPerDay;
|
|
99
|
+
return TimeSpan_fromTicks(Math.round(ns / 100));
|
|
100
|
+
}
|
|
101
|
+
export function toString(t, format = "t", _provider) {
|
|
102
|
+
switch (format) {
|
|
103
|
+
case "t":
|
|
104
|
+
return t.toString({ smallestUnit: "minute" });
|
|
105
|
+
case "r":
|
|
106
|
+
case "R":
|
|
107
|
+
case "T":
|
|
108
|
+
return t.toString({ smallestUnit: "second" });
|
|
109
|
+
case "o":
|
|
110
|
+
case "O":
|
|
111
|
+
// .NET tick precision is 7 fractional digits
|
|
112
|
+
return t.toString({ fractionalSecondDigits: 7 });
|
|
113
|
+
default:
|
|
114
|
+
throw new Exception("Custom formats are not supported");
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
export function parse(str) {
|
|
118
|
+
// Allowed format types:
|
|
119
|
+
// hh:mm
|
|
120
|
+
// hh:mm:ss
|
|
121
|
+
// hh:mm:ss.fffffff
|
|
122
|
+
const r = /^\s*([0-1]?\d|2[0-3])\s*:\s*([0-5]?\d)(\s*:\s*([0-5]?\d)(\.(\d+))?)?\s*$/.exec(str);
|
|
123
|
+
if (r != null && r[1] != null && r[2] != null) {
|
|
124
|
+
const h = +r[1];
|
|
125
|
+
const m = +r[2];
|
|
126
|
+
const s = r[4] != null ? +r[4] : 0;
|
|
127
|
+
// .NET resolves the fraction down to a single tick (7 digits) and truncates
|
|
128
|
+
// anything finer, so the digits are read as ticks rather than milliseconds.
|
|
129
|
+
const subSecondTicks = r[6] != null ? +r[6].padEnd(7, "0").substring(0, 7) : 0;
|
|
130
|
+
return fromNanoseconds(((h * 60 + m) * 60 + s) * 1000000000 + subSecondTicks * 100);
|
|
131
|
+
}
|
|
132
|
+
throw new Exception(`String '${str}' was not recognized as a valid TimeOnly.`);
|
|
133
|
+
}
|
|
134
|
+
export function tryParse(v, defValue) {
|
|
135
|
+
try {
|
|
136
|
+
defValue.contents = parse(v);
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
}
|