@fable-org/fable-library-js 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.js +64 -60
- package/Async.js +8 -7
- package/AsyncBuilder.js +6 -6
- package/BigInt.js +3 -3
- package/Boolean.js +2 -1
- package/CHANGELOG.md +12 -0
- package/Char.js +64 -31
- package/CollectionUtil.js +3 -3
- package/Date.js +50 -46
- package/DateOffset.js +38 -48
- package/DateOnly.js +6 -6
- package/Decimal.js +4 -4
- package/Double.js +2 -1
- package/FSharp.Collections.js +28 -10
- package/FSharp.Core.js +19 -19
- package/Global.js +21 -0
- package/Guid.js +5 -4
- package/Int32.js +17 -17
- package/List.js +74 -63
- package/Long.js +3 -2
- package/MailboxProcessor.js +2 -1
- package/Map.js +39 -42
- package/MapUtil.js +4 -4
- package/MutableMap.js +22 -10
- package/MutableSet.js +3 -3
- package/Native.js +9 -3
- package/Option.js +10 -2
- package/Random.js +13 -12
- package/Range.js +2 -2
- package/Reflection.js +16 -16
- package/RegExp.js +4 -3
- package/Seq.js +38 -46
- package/Set.js +41 -42
- package/String.js +44 -35
- package/System.Collections.Generic.js +22 -6
- package/System.Text.js +8 -8
- package/System.js +283 -0
- package/TimeOnly.js +6 -6
- package/TimeSpan.js +5 -5
- package/Types.js +1 -17
- package/Uri.js +25 -19
- package/Util.js +32 -9
- package/package.json +23 -23
- package/Array.d.ts +0 -123
- package/Async.d.ts +0 -26
- package/AsyncBuilder.d.ts +0 -59
- package/BigInt.d.ts +0 -129
- package/BitConverter.d.ts +0 -27
- package/Boolean.d.ts +0 -3
- package/Char.d.ts +0 -65
- package/Choice.d.ts +0 -121
- package/CollectionUtil.d.ts +0 -7
- package/ConditionalWeakTable.d.ts +0 -9
- package/Date.d.ts +0 -69
- package/DateOffset.d.ts +0 -64
- package/DateOnly.d.ts +0 -18
- package/Decimal.d.ts +0 -63
- package/Double.d.ts +0 -11
- package/Encoding.d.ts +0 -12
- package/Event.d.ts +0 -31
- package/FSharp.Collections.d.ts +0 -7
- package/FSharp.Core.CompilerServices.d.ts +0 -12
- package/FSharp.Core.d.ts +0 -31
- package/Global.d.ts +0 -24
- package/Guid.d.ts +0 -10
- package/Int32.d.ts +0 -28
- package/List.d.ts +0 -143
- package/Long.d.ts +0 -3
- package/MailboxProcessor.d.ts +0 -25
- package/Map.d.ts +0 -178
- package/MapUtil.d.ts +0 -12
- package/MutableMap.d.ts +0 -52
- package/MutableSet.d.ts +0 -39
- package/Native.d.ts +0 -2
- package/Numeric.d.ts +0 -20
- package/Observable.d.ts +0 -32
- package/Option.d.ts +0 -28
- package/Random.d.ts +0 -37
- package/Range.d.ts +0 -12
- package/Reflection.d.ts +0 -119
- package/RegExp.d.ts +0 -10
- package/Result.d.ts +0 -37
- package/Seq.d.ts +0 -165
- package/Seq2.d.ts +0 -18
- package/Set.d.ts +0 -190
- package/String.d.ts +0 -58
- package/System.Collections.Generic.d.ts +0 -79
- package/System.Text.d.ts +0 -39
- package/SystemException.d.ts +0 -5
- package/SystemException.js +0 -5
- package/TimeOnly.d.ts +0 -15
- package/TimeSpan.d.ts +0 -35
- package/Timer.d.ts +0 -19
- package/Types.d.ts +0 -58
- package/Unicode.13.0.0.d.ts +0 -2
- package/Uri.d.ts +0 -31
- package/Util.d.ts +0 -210
- package/lib/big.d.ts +0 -5
package/System.js
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { 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) {
|
|
231
|
+
super(isNullOrEmpty(paramName) ? message : (((message + SR_Arg_ParamName_Name) + paramName) + "\')"));
|
|
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_Z384F8060(message, paramName) {
|
|
239
|
+
return new ArgumentException(message, paramName);
|
|
240
|
+
}
|
|
241
|
+
export function ArgumentException_$ctor() {
|
|
242
|
+
return ArgumentException_$ctor_Z384F8060(SR_Arg_ArgumentException, "");
|
|
243
|
+
}
|
|
244
|
+
export function ArgumentException_$ctor_Z721C83C5(message) {
|
|
245
|
+
return ArgumentException_$ctor_Z384F8060(message, "");
|
|
246
|
+
}
|
|
247
|
+
export function ArgumentException__get_ParamName(_) {
|
|
248
|
+
return _.paramName;
|
|
249
|
+
}
|
|
250
|
+
export class ArgumentNullException extends ArgumentException {
|
|
251
|
+
constructor(paramName, message) {
|
|
252
|
+
super(message, paramName);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
export function ArgumentNullException_$reflection() {
|
|
256
|
+
return class_type("System.ArgumentNullException", undefined, ArgumentNullException, ArgumentException_$reflection());
|
|
257
|
+
}
|
|
258
|
+
export function ArgumentNullException_$ctor_Z384F8060(paramName, message) {
|
|
259
|
+
return new ArgumentNullException(paramName, message);
|
|
260
|
+
}
|
|
261
|
+
export function ArgumentNullException_$ctor_Z721C83C5(paramName) {
|
|
262
|
+
return ArgumentNullException_$ctor_Z384F8060(paramName, SR_ArgumentNull_Generic);
|
|
263
|
+
}
|
|
264
|
+
export function ArgumentNullException_$ctor() {
|
|
265
|
+
return ArgumentNullException_$ctor_Z721C83C5("");
|
|
266
|
+
}
|
|
267
|
+
export class ArgumentOutOfRangeException extends ArgumentException {
|
|
268
|
+
constructor(paramName, message) {
|
|
269
|
+
super(message, paramName);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
export function ArgumentOutOfRangeException_$reflection() {
|
|
273
|
+
return class_type("System.ArgumentOutOfRangeException", undefined, ArgumentOutOfRangeException, ArgumentException_$reflection());
|
|
274
|
+
}
|
|
275
|
+
export function ArgumentOutOfRangeException_$ctor_Z384F8060(paramName, message) {
|
|
276
|
+
return new ArgumentOutOfRangeException(paramName, message);
|
|
277
|
+
}
|
|
278
|
+
export function ArgumentOutOfRangeException_$ctor_Z721C83C5(paramName) {
|
|
279
|
+
return ArgumentOutOfRangeException_$ctor_Z384F8060(paramName, SR_Arg_ArgumentOutOfRangeException);
|
|
280
|
+
}
|
|
281
|
+
export function ArgumentOutOfRangeException_$ctor() {
|
|
282
|
+
return ArgumentOutOfRangeException_$ctor_Z721C83C5("");
|
|
283
|
+
}
|
package/TimeOnly.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { hours, minutes, seconds, milliseconds } from "./TimeSpan.js";
|
|
2
|
-
import { padWithZeros } from "./Util.js";
|
|
2
|
+
import { Exception, DateTimeKind, padWithZeros } from "./Util.js";
|
|
3
3
|
const millisecondsPerDay = 86400000;
|
|
4
4
|
export function create(h = 0, m = 0, s = 0, ms = 0) {
|
|
5
5
|
if (h < 0 || m < 0 || s < 0 || ms < 0)
|
|
6
|
-
throw new
|
|
6
|
+
throw new Exception("The parameters describe an unrepresentable TimeOnly.");
|
|
7
7
|
return h * 3600000 + m * 60000 + s * 1000 + ms;
|
|
8
8
|
}
|
|
9
9
|
export function fromTicks(ticks) {
|
|
@@ -11,11 +11,11 @@ export function fromTicks(ticks) {
|
|
|
11
11
|
}
|
|
12
12
|
export function fromTimeSpan(timeSpan) {
|
|
13
13
|
if (timeSpan < 0 || timeSpan >= millisecondsPerDay)
|
|
14
|
-
throw new
|
|
14
|
+
throw new Exception("The TimeSpan describes an unrepresentable TimeOnly.");
|
|
15
15
|
return timeSpan;
|
|
16
16
|
}
|
|
17
17
|
export function fromDateTime(d) {
|
|
18
|
-
return d.kind ===
|
|
18
|
+
return d.kind === DateTimeKind.Utc
|
|
19
19
|
? create(d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds())
|
|
20
20
|
: create(d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds());
|
|
21
21
|
}
|
|
@@ -55,7 +55,7 @@ export function isBetween(t, start, end) {
|
|
|
55
55
|
}
|
|
56
56
|
export function toString(t, format = "t", _provider) {
|
|
57
57
|
if (["r", "R", "o", "O", "t", "T"].indexOf(format) === -1) {
|
|
58
|
-
throw new
|
|
58
|
+
throw new Exception("Custom formats are not supported");
|
|
59
59
|
}
|
|
60
60
|
const base = `${padWithZeros(hours(t), 2)}:${padWithZeros(minutes(t), 2)}`;
|
|
61
61
|
if (format === "t")
|
|
@@ -106,7 +106,7 @@ export function parse(str) {
|
|
|
106
106
|
}
|
|
107
107
|
return create(h, m, s, Math.trunc(ms));
|
|
108
108
|
}
|
|
109
|
-
throw new
|
|
109
|
+
throw new Exception(`String '${str}' was not recognized as a valid TimeOnly.`);
|
|
110
110
|
}
|
|
111
111
|
export function tryParse(v, defValue) {
|
|
112
112
|
try {
|
package/TimeSpan.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { comparePrimitives, padLeftAndRightWithZeros, padWithZeros } from "./Util.js";
|
|
1
|
+
import { Exception, comparePrimitives, padLeftAndRightWithZeros, padWithZeros } from "./Util.js";
|
|
2
2
|
import { toInt64, fromFloat64 } from "./BigInt.js";
|
|
3
3
|
/**
|
|
4
4
|
* Calls:
|
|
@@ -98,7 +98,7 @@ export function duration(x) {
|
|
|
98
98
|
}
|
|
99
99
|
export function toString(ts, format = "c", _provider) {
|
|
100
100
|
if (["c", "g", "G"].indexOf(format) === -1) {
|
|
101
|
-
throw new
|
|
101
|
+
throw new Exception("Custom formats are not supported");
|
|
102
102
|
}
|
|
103
103
|
const d = Math.abs(days(ts));
|
|
104
104
|
const h = Math.abs(hours(ts));
|
|
@@ -114,7 +114,7 @@ export function parse(str) {
|
|
|
114
114
|
if (firstDot === -1 && firstColon === -1) { // There is only a day ex: 4
|
|
115
115
|
const d = parseInt(str, 0);
|
|
116
116
|
if (isNaN(d)) {
|
|
117
|
-
throw new
|
|
117
|
+
throw new Exception(`String '${str}' was not recognized as a valid TimeSpan.`);
|
|
118
118
|
}
|
|
119
119
|
else {
|
|
120
120
|
return create(d, 0, 0, 0, 0);
|
|
@@ -161,13 +161,13 @@ export function parse(str) {
|
|
|
161
161
|
ms = +r[8] / 10000;
|
|
162
162
|
break;
|
|
163
163
|
default:
|
|
164
|
-
throw new
|
|
164
|
+
throw new Exception(`String '${str}' was not recognized as a valid TimeSpan.`);
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
return sign * create(d, h, m, s, ms);
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
throw new
|
|
170
|
+
throw new Exception(`String '${str}' was not recognized as a valid TimeSpan.`);
|
|
171
171
|
}
|
|
172
172
|
export function tryParse(v, defValue) {
|
|
173
173
|
try {
|
package/Types.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { combineHashCodes, compare, compareArrays, equalArrays, equals, sameConstructor, numberHash, structuralHash } from "./Util.js";
|
|
1
|
+
import { Exception, combineHashCodes, compare, compareArrays, equalArrays, equals, sameConstructor, numberHash, structuralHash } from "./Util.js";
|
|
2
2
|
export function seqToString(self) {
|
|
3
3
|
let count = 0;
|
|
4
4
|
let str = "[";
|
|
@@ -172,22 +172,6 @@ export class FSharpRef {
|
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
// EXCEPTIONS
|
|
175
|
-
// Exception is intentionally not derived from Error, for performance reasons (see #2160)
|
|
176
|
-
export class Exception {
|
|
177
|
-
constructor(message) {
|
|
178
|
-
this.message = message;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
export function isException(x) {
|
|
182
|
-
return x instanceof Exception || x instanceof Error;
|
|
183
|
-
}
|
|
184
|
-
export function isPromise(x) {
|
|
185
|
-
return x instanceof Promise;
|
|
186
|
-
}
|
|
187
|
-
export function ensureErrorOrException(e) {
|
|
188
|
-
// Exceptionally admitting promises as errors for compatibility with React.suspense (see #3298)
|
|
189
|
-
return (isException(e) || isPromise(e)) ? e : new Error(String(e));
|
|
190
|
-
}
|
|
191
175
|
export class FSharpException extends Exception {
|
|
192
176
|
toJSON() { return recordToJSON(this); }
|
|
193
177
|
toString() { return recordToString(this); }
|
package/Uri.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { Exception } from "./Util.js";
|
|
2
|
+
export const UriKind = {
|
|
3
|
+
RelativeOrAbsolute: 0,
|
|
4
|
+
Absolute: 1,
|
|
5
|
+
Relative: 2,
|
|
6
|
+
};
|
|
1
7
|
const ok = (value) => ({
|
|
2
8
|
tag: "ok",
|
|
3
9
|
value,
|
|
@@ -18,41 +24,41 @@ export class Uri {
|
|
|
18
24
|
}
|
|
19
25
|
static tryCreateWithKind(uri, kind) {
|
|
20
26
|
switch (kind) {
|
|
21
|
-
case
|
|
27
|
+
case UriKind.Absolute:
|
|
22
28
|
return Uri.isAbsoluteUri(uri)
|
|
23
29
|
? ok(new Uri({ original: uri, value: new URL(uri), kind }))
|
|
24
30
|
: error("Invalid URI: The format of the URI could not be determined.");
|
|
25
|
-
case
|
|
31
|
+
case UriKind.Relative:
|
|
26
32
|
return Uri.isAbsoluteUri(uri)
|
|
27
33
|
? error("URI is not a relative path.")
|
|
28
34
|
: ok(new Uri({ original: uri, value: uri, kind }));
|
|
29
|
-
case
|
|
35
|
+
case UriKind.RelativeOrAbsolute:
|
|
30
36
|
return Uri.isAbsoluteUri(uri)
|
|
31
|
-
? ok(new Uri({ original: uri, value: new URL(uri), kind:
|
|
32
|
-
: ok(new Uri({ original: uri, value: uri, kind:
|
|
37
|
+
? ok(new Uri({ original: uri, value: new URL(uri), kind: UriKind.Absolute }))
|
|
38
|
+
: ok(new Uri({ original: uri, value: uri, kind: UriKind.Relative }));
|
|
33
39
|
default:
|
|
34
40
|
const never = kind;
|
|
35
41
|
return never;
|
|
36
42
|
}
|
|
37
43
|
}
|
|
38
44
|
static tryCreateWithBase(baseUri, relativeUri) {
|
|
39
|
-
return baseUri.uri.kind !==
|
|
45
|
+
return baseUri.uri.kind !== UriKind.Absolute
|
|
40
46
|
? error("Base URI should have Absolute kind")
|
|
41
47
|
: typeof relativeUri === "string"
|
|
42
48
|
? ok(new Uri({
|
|
43
49
|
original: new URL(relativeUri, baseUri.uri.value).toString(),
|
|
44
50
|
value: new URL(relativeUri, baseUri.uri.value),
|
|
45
|
-
kind:
|
|
51
|
+
kind: UriKind.Absolute,
|
|
46
52
|
}))
|
|
47
|
-
: relativeUri.uri.kind ===
|
|
53
|
+
: relativeUri.uri.kind === UriKind.Relative
|
|
48
54
|
? ok(new Uri({
|
|
49
55
|
original: new URL(relativeUri.uri.value, baseUri.uri.value).toString(),
|
|
50
56
|
value: new URL(relativeUri.uri.value, baseUri.uri.value),
|
|
51
|
-
kind:
|
|
57
|
+
kind: UriKind.Absolute,
|
|
52
58
|
}))
|
|
53
59
|
: ok(baseUri);
|
|
54
60
|
}
|
|
55
|
-
static tryCreateImpl(value, kindOrUri =
|
|
61
|
+
static tryCreateImpl(value, kindOrUri = UriKind.Absolute) {
|
|
56
62
|
return typeof value === "string"
|
|
57
63
|
? typeof kindOrUri !== "number"
|
|
58
64
|
? error("Kind must be specified when the baseUri is a string.")
|
|
@@ -61,19 +67,19 @@ export class Uri {
|
|
|
61
67
|
? error("Kind should not be specified when the baseUri is an absolute Uri.")
|
|
62
68
|
: Uri.tryCreateWithBase(value, kindOrUri);
|
|
63
69
|
}
|
|
64
|
-
static create(value, kindOrUri =
|
|
70
|
+
static create(value, kindOrUri = UriKind.Absolute) {
|
|
65
71
|
const result = Uri.tryCreateImpl(value, kindOrUri);
|
|
66
72
|
switch (result.tag) {
|
|
67
73
|
case "ok":
|
|
68
74
|
return result.value;
|
|
69
75
|
case "error":
|
|
70
|
-
throw new
|
|
76
|
+
throw new Exception(result.error);
|
|
71
77
|
default:
|
|
72
78
|
const never = result;
|
|
73
79
|
return never;
|
|
74
80
|
}
|
|
75
81
|
}
|
|
76
|
-
static tryCreate(value, kindOrUri =
|
|
82
|
+
static tryCreate(value, kindOrUri = UriKind.Absolute, out) {
|
|
77
83
|
const result = Uri.tryCreateImpl(value, kindOrUri);
|
|
78
84
|
switch (result.tag) {
|
|
79
85
|
case "ok":
|
|
@@ -88,9 +94,9 @@ export class Uri {
|
|
|
88
94
|
}
|
|
89
95
|
toString() {
|
|
90
96
|
switch (this.uri.kind) {
|
|
91
|
-
case
|
|
97
|
+
case UriKind.Absolute:
|
|
92
98
|
return decodeURIComponent(this.asUrl().toString());
|
|
93
|
-
case
|
|
99
|
+
case UriKind.Relative:
|
|
94
100
|
return this.uri.value;
|
|
95
101
|
default:
|
|
96
102
|
const never = this.uri;
|
|
@@ -99,17 +105,17 @@ export class Uri {
|
|
|
99
105
|
}
|
|
100
106
|
asUrl() {
|
|
101
107
|
switch (this.uri.kind) {
|
|
102
|
-
case
|
|
108
|
+
case UriKind.Absolute:
|
|
103
109
|
return this.uri.value;
|
|
104
|
-
case
|
|
105
|
-
throw new
|
|
110
|
+
case UriKind.Relative:
|
|
111
|
+
throw new Exception("This operation is not supported for a relative URI.");
|
|
106
112
|
default:
|
|
107
113
|
const never = this.uri;
|
|
108
114
|
return never;
|
|
109
115
|
}
|
|
110
116
|
}
|
|
111
117
|
get isAbsoluteUri() {
|
|
112
|
-
return this.uri.kind ===
|
|
118
|
+
return this.uri.kind === UriKind.Absolute;
|
|
113
119
|
}
|
|
114
120
|
get absoluteUri() {
|
|
115
121
|
return this.asUrl().href;
|
package/Util.js
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
|
+
// Don't change, this corresponds to DateTimeKind.Kind enum values in .NET
|
|
2
|
+
export const DateTimeKind = {
|
|
3
|
+
Unspecified: 0,
|
|
4
|
+
Utc: 1,
|
|
5
|
+
Local: 2,
|
|
6
|
+
};
|
|
7
|
+
// Exception is intentionally not derived from Error, for performance reasons (see #2160)
|
|
8
|
+
export class Exception {
|
|
9
|
+
constructor(msg) {
|
|
10
|
+
this.message = msg ?? "";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function isException(x) {
|
|
14
|
+
return x instanceof Exception || x instanceof Error;
|
|
15
|
+
}
|
|
16
|
+
export function isPromise(x) {
|
|
17
|
+
return x instanceof Promise;
|
|
18
|
+
}
|
|
19
|
+
export function ensureErrorOrException(e) {
|
|
20
|
+
// Exceptionally admitting promises as errors for compatibility with React.suspense (see #3298)
|
|
21
|
+
return (isException(e) || isPromise(e)) ? e : new Exception(String(e));
|
|
22
|
+
}
|
|
1
23
|
export function isArrayLike(x) {
|
|
2
24
|
return Array.isArray(x) || ArrayBuffer.isView(x);
|
|
3
25
|
}
|
|
26
|
+
export function isMutableArray(x) {
|
|
27
|
+
return Array.isArray(x) || ArrayBuffer.isView(x);
|
|
28
|
+
}
|
|
4
29
|
export function isIterable(x) {
|
|
5
30
|
return x != null && typeof x === "object" && Symbol.iterator in x;
|
|
6
31
|
}
|
|
@@ -34,9 +59,7 @@ export function sameConstructor(x, y) {
|
|
|
34
59
|
return Object.getPrototypeOf(x)?.constructor === Object.getPrototypeOf(y)?.constructor;
|
|
35
60
|
}
|
|
36
61
|
export class Enumerable {
|
|
37
|
-
constructor(en) {
|
|
38
|
-
this.en = en;
|
|
39
|
-
}
|
|
62
|
+
constructor(en) { this.en = en; }
|
|
40
63
|
GetEnumerator() { return this.en; }
|
|
41
64
|
"System.Collections.IEnumerable.GetEnumerator"() { return this.en; }
|
|
42
65
|
[Symbol.iterator]() {
|
|
@@ -50,8 +73,8 @@ export class Enumerable {
|
|
|
50
73
|
}
|
|
51
74
|
export class Enumerator {
|
|
52
75
|
constructor(iter) {
|
|
53
|
-
this.iter = iter;
|
|
54
76
|
this.current = defaultOf();
|
|
77
|
+
this.iter = iter;
|
|
55
78
|
}
|
|
56
79
|
["System.Collections.Generic.IEnumerator`1.get_Current"]() {
|
|
57
80
|
return this.current;
|
|
@@ -65,7 +88,7 @@ export class Enumerator {
|
|
|
65
88
|
return !cur.done;
|
|
66
89
|
}
|
|
67
90
|
["System.Collections.IEnumerator.Reset"]() {
|
|
68
|
-
throw new
|
|
91
|
+
throw new Exception("JS iterators cannot be reset");
|
|
69
92
|
}
|
|
70
93
|
Dispose() {
|
|
71
94
|
return;
|
|
@@ -124,7 +147,7 @@ export function comparerFromEqualityComparer(comparer) {
|
|
|
124
147
|
}
|
|
125
148
|
export function assertEqual(actual, expected, msg) {
|
|
126
149
|
if (!equals(actual, expected)) {
|
|
127
|
-
throw Object.assign(new
|
|
150
|
+
throw Object.assign(new Exception(msg || `Expected: ${expected} - Actual: ${actual}`), {
|
|
128
151
|
actual,
|
|
129
152
|
expected,
|
|
130
153
|
});
|
|
@@ -132,7 +155,7 @@ export function assertEqual(actual, expected, msg) {
|
|
|
132
155
|
}
|
|
133
156
|
export function assertNotEqual(actual, expected, msg) {
|
|
134
157
|
if (equals(actual, expected)) {
|
|
135
|
-
throw Object.assign(new
|
|
158
|
+
throw Object.assign(new Exception(msg || `Expected: ${expected} - Actual: ${actual}`), {
|
|
136
159
|
actual,
|
|
137
160
|
expected,
|
|
138
161
|
});
|
|
@@ -167,7 +190,7 @@ export function dateOffset(date) {
|
|
|
167
190
|
const date1 = date;
|
|
168
191
|
return typeof date1.offset === "number"
|
|
169
192
|
? date1.offset
|
|
170
|
-
: (date.kind ===
|
|
193
|
+
: (date.kind === DateTimeKind.Utc
|
|
171
194
|
? 0 : date.getTimezoneOffset() * -60000);
|
|
172
195
|
}
|
|
173
196
|
export function int16ToString(i, radix) {
|
|
@@ -333,7 +356,7 @@ function equalObjects(x, y) {
|
|
|
333
356
|
}
|
|
334
357
|
return true;
|
|
335
358
|
}
|
|
336
|
-
export function
|
|
359
|
+
export function physicalEquals(x, y) {
|
|
337
360
|
return x === y;
|
|
338
361
|
}
|
|
339
362
|
export function equals(x, y) {
|
package/package.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
2
|
+
"sideEffects": false,
|
|
3
|
+
"private": false,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"name": "@fable-org/fable-library-js",
|
|
6
|
+
"version": "2.0.0-beta.5",
|
|
7
|
+
"description": "Core library used by F# projects compiled with fable.io",
|
|
8
|
+
"author": "Fable Contributors",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/fable-compiler/Fable.git"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/fable-compiler/Fable/issues"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://fable.io",
|
|
18
|
+
"keywords": [
|
|
19
|
+
"fable",
|
|
20
|
+
"fable-compiler",
|
|
21
|
+
"fsharp",
|
|
22
|
+
"F#"
|
|
23
|
+
]
|
|
24
|
+
}
|