@fable-org/fable-library-ts 2.0.0-beta.3 → 2.0.0-beta.5
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/Array.ts +1385 -1378
- package/Async.ts +13 -12
- package/AsyncBuilder.ts +10 -11
- package/BigInt.ts +6 -6
- package/BitConverter.ts +3 -3
- package/Boolean.ts +3 -2
- package/CHANGELOG.md +12 -0
- package/Char.ts +38 -35
- package/Choice.ts +326 -301
- package/CollectionUtil.ts +4 -4
- package/Date.ts +67 -62
- package/DateOffset.ts +48 -57
- package/DateOnly.ts +8 -8
- package/Decimal.ts +9 -9
- package/Double.ts +3 -2
- package/Encoding.ts +1 -1
- package/Event.ts +3 -3
- package/FSharp.Collections.ts +53 -34
- package/FSharp.Core.CompilerServices.ts +38 -37
- package/FSharp.Core.ts +186 -185
- package/Global.ts +80 -37
- package/Guid.ts +7 -6
- package/Int32.ts +20 -17
- package/List.ts +1429 -1417
- package/Long.ts +6 -5
- package/MailboxProcessor.ts +8 -7
- package/Map.ts +1550 -1552
- package/MapUtil.ts +5 -5
- package/MutableMap.ts +358 -345
- package/MutableSet.ts +250 -249
- package/Native.ts +19 -11
- package/Numeric.ts +1 -1
- package/Observable.ts +3 -3
- package/Option.ts +10 -4
- package/Random.ts +196 -194
- package/Range.ts +57 -56
- package/Reflection.ts +73 -40
- package/RegExp.ts +5 -3
- package/Result.ts +201 -196
- package/Seq.ts +1517 -1525
- package/Seq2.ts +130 -129
- package/Set.ts +1955 -1955
- package/String.ts +41 -38
- package/System.Collections.Generic.ts +401 -380
- package/System.Text.ts +204 -203
- package/System.ts +366 -0
- package/TimeOnly.ts +10 -10
- package/TimeSpan.ts +11 -11
- package/Timer.ts +2 -2
- package/Types.ts +1 -19
- package/Uri.ts +13 -10
- package/Util.ts +77 -21
- package/package.json +22 -22
- package/tsconfig.json +18 -5
- package/SystemException.ts +0 -7
package/System.ts
ADDED
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
|
|
2
|
+
import { Exception } from "./Util.ts";
|
|
3
|
+
import { class_type, TypeInfo } from "./Reflection.ts";
|
|
4
|
+
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.ts";
|
|
5
|
+
import { isNullOrEmpty } from "./String.ts";
|
|
6
|
+
|
|
7
|
+
export class SystemException extends Exception {
|
|
8
|
+
constructor(message: string) {
|
|
9
|
+
super(message);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function SystemException_$reflection(): TypeInfo {
|
|
14
|
+
return class_type("System.SystemException", undefined, SystemException, class_type("System.Exception"));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function SystemException_$ctor_Z721C83C5(message: string): SystemException {
|
|
18
|
+
return new SystemException(message);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function SystemException_$ctor(): SystemException {
|
|
22
|
+
return SystemException_$ctor_Z721C83C5(SR_Arg_SystemException);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export class ApplicationException extends Exception {
|
|
26
|
+
constructor(message: string) {
|
|
27
|
+
super(message);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function ApplicationException_$reflection(): TypeInfo {
|
|
32
|
+
return class_type("System.ApplicationException", undefined, ApplicationException, class_type("System.Exception"));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function ApplicationException_$ctor_Z721C83C5(message: string): ApplicationException {
|
|
36
|
+
return new ApplicationException(message);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function ApplicationException_$ctor(): ApplicationException {
|
|
40
|
+
return ApplicationException_$ctor_Z721C83C5(SR_Arg_ApplicationException);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class ArithmeticException extends Exception {
|
|
44
|
+
constructor(message: string) {
|
|
45
|
+
super(message);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function ArithmeticException_$reflection(): TypeInfo {
|
|
50
|
+
return class_type("System.ArithmeticException", undefined, ArithmeticException, class_type("System.Exception"));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function ArithmeticException_$ctor_Z721C83C5(message: string): ArithmeticException {
|
|
54
|
+
return new ArithmeticException(message);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function ArithmeticException_$ctor(): ArithmeticException {
|
|
58
|
+
return ArithmeticException_$ctor_Z721C83C5(SR_Arg_ArithmeticException);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export class DivideByZeroException extends Exception {
|
|
62
|
+
constructor(message: string) {
|
|
63
|
+
super(message);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function DivideByZeroException_$reflection(): TypeInfo {
|
|
68
|
+
return class_type("System.DivideByZeroException", undefined, DivideByZeroException, class_type("System.Exception"));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function DivideByZeroException_$ctor_Z721C83C5(message: string): DivideByZeroException {
|
|
72
|
+
return new DivideByZeroException(message);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function DivideByZeroException_$ctor(): DivideByZeroException {
|
|
76
|
+
return DivideByZeroException_$ctor_Z721C83C5(SR_Arg_DivideByZero);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export class FormatException extends Exception {
|
|
80
|
+
constructor(message: string) {
|
|
81
|
+
super(message);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function FormatException_$reflection(): TypeInfo {
|
|
86
|
+
return class_type("System.FormatException", undefined, FormatException, class_type("System.Exception"));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function FormatException_$ctor_Z721C83C5(message: string): FormatException {
|
|
90
|
+
return new FormatException(message);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function FormatException_$ctor(): FormatException {
|
|
94
|
+
return FormatException_$ctor_Z721C83C5(SR_Arg_FormatException);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export class IndexOutOfRangeException extends Exception {
|
|
98
|
+
constructor(message: string) {
|
|
99
|
+
super(message);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function IndexOutOfRangeException_$reflection(): TypeInfo {
|
|
104
|
+
return class_type("System.IndexOutOfRangeException", undefined, IndexOutOfRangeException, class_type("System.Exception"));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function IndexOutOfRangeException_$ctor_Z721C83C5(message: string): IndexOutOfRangeException {
|
|
108
|
+
return new IndexOutOfRangeException(message);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function IndexOutOfRangeException_$ctor(): IndexOutOfRangeException {
|
|
112
|
+
return IndexOutOfRangeException_$ctor_Z721C83C5(SR_Arg_IndexOutOfRangeException);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export class InvalidOperationException extends Exception {
|
|
116
|
+
constructor(message: string) {
|
|
117
|
+
super(message);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function InvalidOperationException_$reflection(): TypeInfo {
|
|
122
|
+
return class_type("System.InvalidOperationException", undefined, InvalidOperationException, class_type("System.Exception"));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function InvalidOperationException_$ctor_Z721C83C5(message: string): InvalidOperationException {
|
|
126
|
+
return new InvalidOperationException(message);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function InvalidOperationException_$ctor(): InvalidOperationException {
|
|
130
|
+
return InvalidOperationException_$ctor_Z721C83C5(SR_Arg_InvalidOperationException);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export class NotFiniteNumberException extends Exception {
|
|
134
|
+
constructor(message: string) {
|
|
135
|
+
super(message);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function NotFiniteNumberException_$reflection(): TypeInfo {
|
|
140
|
+
return class_type("System.NotFiniteNumberException", undefined, NotFiniteNumberException, class_type("System.Exception"));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function NotFiniteNumberException_$ctor_Z721C83C5(message: string): NotFiniteNumberException {
|
|
144
|
+
return new NotFiniteNumberException(message);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function NotFiniteNumberException_$ctor(): NotFiniteNumberException {
|
|
148
|
+
return NotFiniteNumberException_$ctor_Z721C83C5(SR_Arg_NotFiniteNumberException);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export class NotImplementedException extends Exception {
|
|
152
|
+
constructor(message: string) {
|
|
153
|
+
super(message);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function NotImplementedException_$reflection(): TypeInfo {
|
|
158
|
+
return class_type("System.NotImplementedException", undefined, NotImplementedException, class_type("System.Exception"));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function NotImplementedException_$ctor_Z721C83C5(message: string): NotImplementedException {
|
|
162
|
+
return new NotImplementedException(message);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function NotImplementedException_$ctor(): NotImplementedException {
|
|
166
|
+
return NotImplementedException_$ctor_Z721C83C5(SR_Arg_NotImplementedException);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export class NotSupportedException extends Exception {
|
|
170
|
+
constructor(message: string) {
|
|
171
|
+
super(message);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export function NotSupportedException_$reflection(): TypeInfo {
|
|
176
|
+
return class_type("System.NotSupportedException", undefined, NotSupportedException, class_type("System.Exception"));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function NotSupportedException_$ctor_Z721C83C5(message: string): NotSupportedException {
|
|
180
|
+
return new NotSupportedException(message);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export function NotSupportedException_$ctor(): NotSupportedException {
|
|
184
|
+
return NotSupportedException_$ctor_Z721C83C5(SR_Arg_NotSupportedException);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export class NullReferenceException extends Exception {
|
|
188
|
+
constructor(message: string) {
|
|
189
|
+
super(message);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export function NullReferenceException_$reflection(): TypeInfo {
|
|
194
|
+
return class_type("System.NullReferenceException", undefined, NullReferenceException, class_type("System.Exception"));
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export function NullReferenceException_$ctor_Z721C83C5(message: string): NullReferenceException {
|
|
198
|
+
return new NullReferenceException(message);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export function NullReferenceException_$ctor(): NullReferenceException {
|
|
202
|
+
return NullReferenceException_$ctor_Z721C83C5(SR_Arg_NullReferenceException);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export class OutOfMemoryException extends Exception {
|
|
206
|
+
constructor(message: string) {
|
|
207
|
+
super(message);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export function OutOfMemoryException_$reflection(): TypeInfo {
|
|
212
|
+
return class_type("System.OutOfMemoryException", undefined, OutOfMemoryException, class_type("System.Exception"));
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export function OutOfMemoryException_$ctor_Z721C83C5(message: string): OutOfMemoryException {
|
|
216
|
+
return new OutOfMemoryException(message);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export function OutOfMemoryException_$ctor(): OutOfMemoryException {
|
|
220
|
+
return OutOfMemoryException_$ctor_Z721C83C5(SR_Arg_OutOfMemoryException);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export class OverflowException extends Exception {
|
|
224
|
+
constructor(message: string) {
|
|
225
|
+
super(message);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export function OverflowException_$reflection(): TypeInfo {
|
|
230
|
+
return class_type("System.OverflowException", undefined, OverflowException, class_type("System.Exception"));
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export function OverflowException_$ctor_Z721C83C5(message: string): OverflowException {
|
|
234
|
+
return new OverflowException(message);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export function OverflowException_$ctor(): OverflowException {
|
|
238
|
+
return OverflowException_$ctor_Z721C83C5(SR_Arg_OverflowException);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export class RankException extends Exception {
|
|
242
|
+
constructor(message: string) {
|
|
243
|
+
super(message);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export function RankException_$reflection(): TypeInfo {
|
|
248
|
+
return class_type("System.RankException", undefined, RankException, class_type("System.Exception"));
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export function RankException_$ctor_Z721C83C5(message: string): RankException {
|
|
252
|
+
return new RankException(message);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export function RankException_$ctor(): RankException {
|
|
256
|
+
return RankException_$ctor_Z721C83C5(SR_Arg_RankException);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export class StackOverflowException extends Exception {
|
|
260
|
+
constructor(message: string) {
|
|
261
|
+
super(message);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export function StackOverflowException_$reflection(): TypeInfo {
|
|
266
|
+
return class_type("System.StackOverflowException", undefined, StackOverflowException, class_type("System.Exception"));
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export function StackOverflowException_$ctor_Z721C83C5(message: string): StackOverflowException {
|
|
270
|
+
return new StackOverflowException(message);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export function StackOverflowException_$ctor(): StackOverflowException {
|
|
274
|
+
return StackOverflowException_$ctor_Z721C83C5(SR_Arg_StackOverflowException);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export class TimeoutException extends Exception {
|
|
278
|
+
constructor(message: string) {
|
|
279
|
+
super(message);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export function TimeoutException_$reflection(): TypeInfo {
|
|
284
|
+
return class_type("System.TimeoutException", undefined, TimeoutException, class_type("System.Exception"));
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export function TimeoutException_$ctor_Z721C83C5(message: string): TimeoutException {
|
|
288
|
+
return new TimeoutException(message);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export function TimeoutException_$ctor(): TimeoutException {
|
|
292
|
+
return TimeoutException_$ctor_Z721C83C5(SR_Arg_TimeoutException);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export class ArgumentException extends Exception {
|
|
296
|
+
readonly paramName: string;
|
|
297
|
+
constructor(message: string, paramName: string) {
|
|
298
|
+
super(isNullOrEmpty(paramName) ? message : (((message + SR_Arg_ParamName_Name) + paramName) + "\')"));
|
|
299
|
+
this.paramName = paramName;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export function ArgumentException_$reflection(): TypeInfo {
|
|
304
|
+
return class_type("System.ArgumentException", undefined, ArgumentException, class_type("System.Exception"));
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export function ArgumentException_$ctor_Z384F8060(message: string, paramName: string): ArgumentException {
|
|
308
|
+
return new ArgumentException(message, paramName);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export function ArgumentException_$ctor(): ArgumentException {
|
|
312
|
+
return ArgumentException_$ctor_Z384F8060(SR_Arg_ArgumentException, "");
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export function ArgumentException_$ctor_Z721C83C5(message: string): ArgumentException {
|
|
316
|
+
return ArgumentException_$ctor_Z384F8060(message, "");
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export function ArgumentException__get_ParamName(_: ArgumentException): string {
|
|
320
|
+
return _.paramName;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export class ArgumentNullException extends ArgumentException {
|
|
324
|
+
constructor(paramName: string, message: string) {
|
|
325
|
+
super(message, paramName);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export function ArgumentNullException_$reflection(): TypeInfo {
|
|
330
|
+
return class_type("System.ArgumentNullException", undefined, ArgumentNullException, ArgumentException_$reflection());
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export function ArgumentNullException_$ctor_Z384F8060(paramName: string, message: string): ArgumentNullException {
|
|
334
|
+
return new ArgumentNullException(paramName, message);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export function ArgumentNullException_$ctor_Z721C83C5(paramName: string): ArgumentNullException {
|
|
338
|
+
return ArgumentNullException_$ctor_Z384F8060(paramName, SR_ArgumentNull_Generic);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export function ArgumentNullException_$ctor(): ArgumentNullException {
|
|
342
|
+
return ArgumentNullException_$ctor_Z721C83C5("");
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export class ArgumentOutOfRangeException extends ArgumentException {
|
|
346
|
+
constructor(paramName: string, message: string) {
|
|
347
|
+
super(message, paramName);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export function ArgumentOutOfRangeException_$reflection(): TypeInfo {
|
|
352
|
+
return class_type("System.ArgumentOutOfRangeException", undefined, ArgumentOutOfRangeException, ArgumentException_$reflection());
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export function ArgumentOutOfRangeException_$ctor_Z384F8060(paramName: string, message: string): ArgumentOutOfRangeException {
|
|
356
|
+
return new ArgumentOutOfRangeException(paramName, message);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export function ArgumentOutOfRangeException_$ctor_Z721C83C5(paramName: string): ArgumentOutOfRangeException {
|
|
360
|
+
return ArgumentOutOfRangeException_$ctor_Z384F8060(paramName, SR_Arg_ArgumentOutOfRangeException);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export function ArgumentOutOfRangeException_$ctor(): ArgumentOutOfRangeException {
|
|
364
|
+
return ArgumentOutOfRangeException_$ctor_Z721C83C5("");
|
|
365
|
+
}
|
|
366
|
+
|
package/TimeOnly.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { FSharpRef } from "./Types.
|
|
2
|
-
import { hours, minutes, seconds, milliseconds } from "./TimeSpan.
|
|
3
|
-
import {
|
|
1
|
+
import { FSharpRef } from "./Types.ts";
|
|
2
|
+
import { hours, minutes, seconds, milliseconds } from "./TimeSpan.ts";
|
|
3
|
+
import { Exception, DateTimeKind, IDateTime, padWithZeros } from "./Util.ts";
|
|
4
4
|
|
|
5
5
|
const millisecondsPerDay = 86400000;
|
|
6
6
|
|
|
7
7
|
export function create(h: number = 0, m: number = 0, s: number = 0, ms: number = 0) {
|
|
8
8
|
if (h < 0 || m < 0 || s < 0 || ms < 0)
|
|
9
|
-
throw new
|
|
9
|
+
throw new Exception("The parameters describe an unrepresentable TimeOnly.");
|
|
10
10
|
|
|
11
|
-
return h * 3600000 + m *
|
|
11
|
+
return h * 3600000 + m * 60_000 + s * 1000 + ms;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export function fromTicks(ticks: number | bigint) {
|
|
@@ -17,13 +17,13 @@ export function fromTicks(ticks: number | bigint) {
|
|
|
17
17
|
|
|
18
18
|
export function fromTimeSpan(timeSpan: number) {
|
|
19
19
|
if (timeSpan < 0 || timeSpan >= millisecondsPerDay)
|
|
20
|
-
throw new
|
|
20
|
+
throw new Exception("The TimeSpan describes an unrepresentable TimeOnly.");
|
|
21
21
|
|
|
22
22
|
return timeSpan;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export function fromDateTime(d: IDateTime) {
|
|
26
|
-
return d.kind ===
|
|
26
|
+
return d.kind === DateTimeKind.Utc
|
|
27
27
|
? create(d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds())
|
|
28
28
|
: create(d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds());
|
|
29
29
|
}
|
|
@@ -61,7 +61,7 @@ export function addHours(t: number, h: number) {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
export function addMinutes(t: number, m: number) {
|
|
64
|
-
return add(t, m *
|
|
64
|
+
return add(t, m * 60_000);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export function isBetween(t: number, start: number, end: number) {
|
|
@@ -72,7 +72,7 @@ export function isBetween(t: number, start: number, end: number) {
|
|
|
72
72
|
|
|
73
73
|
export function toString(t: number, format = "t", _provider?: any) {
|
|
74
74
|
if (["r", "R", "o", "O", "t", "T"].indexOf(format) === -1) {
|
|
75
|
-
throw new
|
|
75
|
+
throw new Exception("Custom formats are not supported");
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
const base = `${padWithZeros(hours(t), 2)}:${padWithZeros(minutes(t), 2)}`
|
|
@@ -114,7 +114,7 @@ export function parse(str: string) {
|
|
|
114
114
|
return create(h, m, s, Math.trunc(ms));
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
throw new
|
|
117
|
+
throw new Exception(`String '${str}' was not recognized as a valid TimeOnly.`);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
export function tryParse(v: string, defValue: FSharpRef<number>): boolean {
|
package/TimeSpan.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FSharpRef } from "./Types.
|
|
2
|
-
import { comparePrimitives, padLeftAndRightWithZeros, padWithZeros } from "./Util.
|
|
3
|
-
import { toInt64, fromFloat64 } from "./BigInt.
|
|
1
|
+
import { FSharpRef } from "./Types.ts";
|
|
2
|
+
import { Exception, comparePrimitives, padLeftAndRightWithZeros, padWithZeros } from "./Util.ts";
|
|
3
|
+
import { toInt64, fromFloat64 } from "./BigInt.ts";
|
|
4
4
|
|
|
5
5
|
// TimeSpan in runtime just becomes a number representing milliseconds
|
|
6
6
|
export type TimeSpan = number;
|
|
@@ -28,7 +28,7 @@ export function create(d: number = 0, h: number = 0, m: number = 0, s: number =
|
|
|
28
28
|
// d,h,m,s,ms
|
|
29
29
|
break;
|
|
30
30
|
}
|
|
31
|
-
return d * 86400000 + h * 3600000 + m *
|
|
31
|
+
return d * 86400000 + h * 3600000 + m * 60_000 + s * 1000 + ms;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export function fromTicks(ticks: number | bigint) {
|
|
@@ -64,11 +64,11 @@ export function hours(ts: TimeSpan) {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
export function minutes(ts: TimeSpan) {
|
|
67
|
-
return signedRound(ts % 3600000 /
|
|
67
|
+
return signedRound(ts % 3600000 / 60_000);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
export function seconds(ts: TimeSpan) {
|
|
71
|
-
return signedRound(ts %
|
|
71
|
+
return signedRound(ts % 60_000 / 1000);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
export function milliseconds(ts: TimeSpan) {
|
|
@@ -88,7 +88,7 @@ export function totalHours(ts: TimeSpan) {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
export function totalMinutes(ts: TimeSpan) {
|
|
91
|
-
return ts /
|
|
91
|
+
return ts / 60_000;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
export function totalSeconds(ts: TimeSpan) {
|
|
@@ -129,7 +129,7 @@ export function duration(x: number) {
|
|
|
129
129
|
|
|
130
130
|
export function toString(ts: TimeSpan, format = "c", _provider?: any) {
|
|
131
131
|
if (["c", "g", "G"].indexOf(format) === -1) {
|
|
132
|
-
throw new
|
|
132
|
+
throw new Exception("Custom formats are not supported");
|
|
133
133
|
}
|
|
134
134
|
const d = Math.abs(days(ts));
|
|
135
135
|
const h = Math.abs(hours(ts));
|
|
@@ -146,7 +146,7 @@ export function parse(str: string) {
|
|
|
146
146
|
if (firstDot === -1 && firstColon === -1) { // There is only a day ex: 4
|
|
147
147
|
const d = parseInt(str, 0);
|
|
148
148
|
if (isNaN(d)) {
|
|
149
|
-
throw new
|
|
149
|
+
throw new Exception(`String '${str}' was not recognized as a valid TimeSpan.`);
|
|
150
150
|
} else {
|
|
151
151
|
return create(d, 0, 0, 0, 0);
|
|
152
152
|
}
|
|
@@ -178,13 +178,13 @@ export function parse(str: string) {
|
|
|
178
178
|
case 6: ms = +r[8] / 1000; break;
|
|
179
179
|
case 7: ms = +r[8] / 10000; break;
|
|
180
180
|
default:
|
|
181
|
-
throw new
|
|
181
|
+
throw new Exception(`String '${str}' was not recognized as a valid TimeSpan.`);
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
return sign * create(d, h, m, s, ms);
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
-
throw new
|
|
187
|
+
throw new Exception(`String '${str}' was not recognized as a valid TimeSpan.`);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
export function tryParse(v: string, defValue: FSharpRef<number>): boolean {
|
package/Timer.ts
CHANGED
package/Types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IComparable, IEquatable, IHashable, combineHashCodes, compare, compareArrays, equalArrays, equals, sameConstructor, numberHash, structuralHash } from "./Util.
|
|
1
|
+
import { Exception, IComparable, IEquatable, IHashable, combineHashCodes, compare, compareArrays, equalArrays, equals, sameConstructor, numberHash, structuralHash } from "./Util.ts";
|
|
2
2
|
|
|
3
3
|
// This type is only used internally for .ts files in the library
|
|
4
4
|
// F# Result type is in Choice.fs
|
|
@@ -186,24 +186,6 @@ export class FSharpRef<T> {
|
|
|
186
186
|
|
|
187
187
|
// EXCEPTIONS
|
|
188
188
|
|
|
189
|
-
// Exception is intentionally not derived from Error, for performance reasons (see #2160)
|
|
190
|
-
export class Exception {
|
|
191
|
-
constructor(public message?: string) { }
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
export function isException(x: any) {
|
|
195
|
-
return x instanceof Exception || x instanceof Error;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export function isPromise(x: any) {
|
|
199
|
-
return x instanceof Promise;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export function ensureErrorOrException(e: any): any {
|
|
203
|
-
// Exceptionally admitting promises as errors for compatibility with React.suspense (see #3298)
|
|
204
|
-
return (isException(e) || isPromise(e)) ? e : new Error(String(e));
|
|
205
|
-
}
|
|
206
|
-
|
|
207
189
|
export abstract class FSharpException extends Exception
|
|
208
190
|
implements IEquatable<FSharpException>, IComparable<FSharpException> {
|
|
209
191
|
toJSON() { return recordToJSON(this); }
|
package/Uri.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { FSharpRef, Result } from "./Types.
|
|
1
|
+
import { FSharpRef, Result } from "./Types.ts";
|
|
2
|
+
import { Exception } from "./Util.ts";
|
|
2
3
|
|
|
3
|
-
export const
|
|
4
|
-
RelativeOrAbsolute
|
|
5
|
-
Absolute
|
|
6
|
-
Relative
|
|
7
|
-
}
|
|
4
|
+
export const UriKind = {
|
|
5
|
+
RelativeOrAbsolute: 0,
|
|
6
|
+
Absolute: 1,
|
|
7
|
+
Relative: 2,
|
|
8
|
+
} as const;
|
|
9
|
+
|
|
10
|
+
export type UriKind = typeof UriKind[keyof typeof UriKind];
|
|
8
11
|
|
|
9
12
|
type State =
|
|
10
|
-
| { original: string; value: URL; kind: UriKind.Absolute }
|
|
11
|
-
| { original: string; value: string; kind: UriKind.Relative };
|
|
13
|
+
| { original: string; value: URL; kind: typeof UriKind.Absolute }
|
|
14
|
+
| { original: string; value: string; kind: typeof UriKind.Relative };
|
|
12
15
|
|
|
13
16
|
const ok = <T>(value: T): Result<T> => ({
|
|
14
17
|
tag: "ok",
|
|
@@ -104,7 +107,7 @@ export class Uri {
|
|
|
104
107
|
case "ok":
|
|
105
108
|
return result.value;
|
|
106
109
|
case "error":
|
|
107
|
-
throw new
|
|
110
|
+
throw new Exception(result.error);
|
|
108
111
|
default:
|
|
109
112
|
const never: never = result;
|
|
110
113
|
return never;
|
|
@@ -156,7 +159,7 @@ export class Uri {
|
|
|
156
159
|
case UriKind.Absolute:
|
|
157
160
|
return this.uri.value;
|
|
158
161
|
case UriKind.Relative:
|
|
159
|
-
throw new
|
|
162
|
+
throw new Exception("This operation is not supported for a relative URI.");
|
|
160
163
|
default:
|
|
161
164
|
const never: never = this.uri;
|
|
162
165
|
return never;
|