@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/FSharp.Core.ts
CHANGED
|
@@ -1,185 +1,186 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
|
|
1
|
+
|
|
2
|
+
import { Nullable, IDisposable, disposeSafe, defaultOf, Exception, IEqualityComparer, IComparer, structuralHash, equals } from "./Util.ts";
|
|
3
|
+
import { int32 } from "./Int32.ts";
|
|
4
|
+
import { HashIdentity_Structural, ComparisonIdentity_Structural } from "./FSharp.Collections.ts";
|
|
5
|
+
import { nonNullValue, Option } from "./Option.ts";
|
|
6
|
+
import { NullReferenceException_$ctor, ArgumentNullException_$ctor_Z721C83C5 } from "./System.ts";
|
|
7
|
+
import { FSharpChoice$2_$union, FSharpChoice$2_Choice2Of2, FSharpChoice$2_Choice1Of2 } from "./Choice.ts";
|
|
8
|
+
import { StringBuilder__Append_Z721C83C5 } from "./System.Text.ts";
|
|
9
|
+
|
|
10
|
+
export const LanguagePrimitives_GenericEqualityComparer: any = {
|
|
11
|
+
Equals(x: any, y: any): boolean {
|
|
12
|
+
return equals(x, y);
|
|
13
|
+
},
|
|
14
|
+
GetHashCode(x_1: any): int32 {
|
|
15
|
+
return structuralHash(x_1) | 0;
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const LanguagePrimitives_GenericEqualityERComparer: any = {
|
|
20
|
+
Equals(x: any, y: any): boolean {
|
|
21
|
+
return equals(x, y);
|
|
22
|
+
},
|
|
23
|
+
GetHashCode(x_1: any): int32 {
|
|
24
|
+
return structuralHash(x_1) | 0;
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export function LanguagePrimitives_FastGenericComparer<T>(): IComparer<T> {
|
|
29
|
+
return ComparisonIdentity_Structural<T>();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function LanguagePrimitives_FastGenericComparerFromTable<T>(): IComparer<T> {
|
|
33
|
+
return ComparisonIdentity_Structural<T>();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function LanguagePrimitives_FastGenericEqualityComparer<T>(): IEqualityComparer<T> {
|
|
37
|
+
return HashIdentity_Structural<T>();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function LanguagePrimitives_FastGenericEqualityComparerFromTable<T>(): IEqualityComparer<T> {
|
|
41
|
+
return HashIdentity_Structural<T>();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function Operators_Failure(message: string): any {
|
|
45
|
+
return new Exception(message);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function Operators_FailurePattern(exn: Exception): Option<string> {
|
|
49
|
+
return exn.message;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function Operators_NullArg<$a>(argumentName: string): $a {
|
|
53
|
+
throw ArgumentNullException_$ctor_Z721C83C5(argumentName);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function Operators_Using<T extends IDisposable, R>(resource: T, action: ((arg0: T) => R)): R {
|
|
57
|
+
try {
|
|
58
|
+
return action(resource);
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
if (equals(resource, defaultOf())) {
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
let copyOfStruct: T = resource;
|
|
65
|
+
disposeSafe(copyOfStruct);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function Operators_Lock<$a, $b>(_lockObj: $a, action: (() => $b)): $b {
|
|
71
|
+
return action();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function Operators_IsNull<T>(value: T): boolean {
|
|
75
|
+
if (equals(value, defaultOf())) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function Operators_IsNotNull<T>(value: T): boolean {
|
|
84
|
+
if (equals(value, defaultOf())) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function Operators_IsNullV<T extends any>(value: Nullable<T>): boolean {
|
|
93
|
+
return !(value != null);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function Operators_NonNull<T>(value: T): T {
|
|
97
|
+
if (equals(value, defaultOf())) {
|
|
98
|
+
throw NullReferenceException_$ctor();
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
return value;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function Operators_NonNullV<T extends any>(value: Nullable<T>): T {
|
|
106
|
+
if (value != null) {
|
|
107
|
+
return nonNullValue(value);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
throw NullReferenceException_$ctor();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function Operators_NullMatchPattern<T>(value: T): FSharpChoice$2_$union<void, T> {
|
|
115
|
+
if (equals(value, defaultOf())) {
|
|
116
|
+
return FSharpChoice$2_Choice1Of2<void, T>(undefined);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
return FSharpChoice$2_Choice2Of2<void, T>(value);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function Operators_NullValueMatchPattern<T extends any>(value: Nullable<T>): FSharpChoice$2_$union<void, T> {
|
|
124
|
+
if (value != null) {
|
|
125
|
+
return FSharpChoice$2_Choice2Of2<void, T>(nonNullValue(value));
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
return FSharpChoice$2_Choice1Of2<void, T>(undefined);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function Operators_NonNullQuickPattern<T>(value: T): T {
|
|
133
|
+
if (equals(value, defaultOf())) {
|
|
134
|
+
throw NullReferenceException_$ctor();
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
return value;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function Operators_NonNullQuickValuePattern<T extends any>(value: Nullable<T>): T {
|
|
142
|
+
if (value != null) {
|
|
143
|
+
return nonNullValue(value);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
throw NullReferenceException_$ctor();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function Operators_WithNull<T>(value: T): T {
|
|
151
|
+
return value;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function Operators_WithNullV<T extends any>(value: T): T {
|
|
155
|
+
return value;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function Operators_NullV<T extends any>(): Nullable<T> {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export function Operators_NullArgCheck<T>(argumentName: string, value: T): T {
|
|
163
|
+
if (equals(value, defaultOf())) {
|
|
164
|
+
throw ArgumentNullException_$ctor_Z721C83C5(argumentName);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
return value;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function ExtraTopLevelOperators_LazyPattern<$a>(input: any): $a {
|
|
172
|
+
return input.Value;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export function PrintfModule_PrintFormatToStringBuilderThen<$a, $b>(continuation: (() => $a), builder: any, format: any): $b {
|
|
176
|
+
return format.cont((s: string): $a => {
|
|
177
|
+
StringBuilder__Append_Z721C83C5(builder, s);
|
|
178
|
+
return continuation();
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function PrintfModule_PrintFormatToStringBuilder<$a>(builder: any, format: any): $a {
|
|
183
|
+
return PrintfModule_PrintFormatToStringBuilderThen<void, $a>((): void => {
|
|
184
|
+
}, builder, format);
|
|
185
|
+
}
|
|
186
|
+
|
package/Global.ts
CHANGED
|
@@ -1,37 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
|
|
2
|
+
import { int32 } from "./Int32.ts";
|
|
3
|
+
|
|
4
|
+
export interface Fable_Core_IGenericAdder$1<T> {
|
|
5
|
+
Add(arg0: T, arg1: T): T,
|
|
6
|
+
GetZero(): T
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface Fable_Core_IGenericAverager$1<T> {
|
|
10
|
+
Add(arg0: T, arg1: T): T,
|
|
11
|
+
DivideByInt(arg0: T, arg1: int32): T,
|
|
12
|
+
GetZero(): T
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface Fable_Core_Symbol_wellknown {
|
|
16
|
+
get [Symbol.toStringTag](): string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface Fable_Core_IJsonSerializable {
|
|
20
|
+
toJSON(): any
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const SR_indexOutOfBounds = "The index was outside the range of elements in the collection.";
|
|
24
|
+
|
|
25
|
+
export const SR_inputWasEmpty = "Collection was empty.";
|
|
26
|
+
|
|
27
|
+
export const SR_inputMustBeNonNegative = "The input must be non-negative.";
|
|
28
|
+
|
|
29
|
+
export const SR_inputSequenceEmpty = "The input sequence was empty.";
|
|
30
|
+
|
|
31
|
+
export const SR_inputSequenceTooLong = "The input sequence contains more than one element.";
|
|
32
|
+
|
|
33
|
+
export const SR_keyNotFoundAlt = "An index satisfying the predicate was not found in the collection.";
|
|
34
|
+
|
|
35
|
+
export const SR_differentLengths = "The collections had different lengths.";
|
|
36
|
+
|
|
37
|
+
export const SR_notEnoughElements = "The input sequence has an insufficient number of elements.";
|
|
38
|
+
|
|
39
|
+
export const SR_Arg_ApplicationException = "Error in the application.";
|
|
40
|
+
|
|
41
|
+
export const SR_Arg_ArgumentException = "Value does not fall within the expected range.";
|
|
42
|
+
|
|
43
|
+
export const SR_Arg_ArgumentOutOfRangeException = "Specified argument was out of the range of valid values.";
|
|
44
|
+
|
|
45
|
+
export const SR_ArgumentNull_Generic = "Value cannot be null.";
|
|
46
|
+
|
|
47
|
+
export const SR_Arg_ParamName_Name = " (Parameter \'";
|
|
48
|
+
|
|
49
|
+
export const SR_Arg_ArithmeticException = "Overflow or underflow in the arithmetic operation.";
|
|
50
|
+
|
|
51
|
+
export const SR_Arg_DivideByZero = "Attempted to divide by zero.";
|
|
52
|
+
|
|
53
|
+
export const SR_Arg_FormatException = "One of the identified items was in an invalid format.";
|
|
54
|
+
|
|
55
|
+
export const SR_Arg_IndexOutOfRangeException = "Index was outside the bounds of the array.";
|
|
56
|
+
|
|
57
|
+
export const SR_Arg_InvalidOperationException = "Operation is not valid due to the current state of the object.";
|
|
58
|
+
|
|
59
|
+
export const SR_Arg_KeyNotFound = "The given key was not present in the dictionary.";
|
|
60
|
+
|
|
61
|
+
export const SR_Arg_NotFiniteNumberException = "Number encountered was not a finite quantity.";
|
|
62
|
+
|
|
63
|
+
export const SR_Arg_NotImplementedException = "The method or operation is not implemented.";
|
|
64
|
+
|
|
65
|
+
export const SR_Arg_NotSupportedException = "Specified method is not supported.";
|
|
66
|
+
|
|
67
|
+
export const SR_Arg_NullReferenceException = "Object reference not set to an instance of an object.";
|
|
68
|
+
|
|
69
|
+
export const SR_Arg_OutOfMemoryException = "Insufficient memory to continue the execution of the program.";
|
|
70
|
+
|
|
71
|
+
export const SR_Arg_OverflowException = "Arithmetic operation resulted in an overflow.";
|
|
72
|
+
|
|
73
|
+
export const SR_Arg_RankException = "Attempted to operate on an array with the incorrect number of dimensions.";
|
|
74
|
+
|
|
75
|
+
export const SR_Arg_StackOverflowException = "Operation caused a stack overflow.";
|
|
76
|
+
|
|
77
|
+
export const SR_Arg_SystemException = "System error.";
|
|
78
|
+
|
|
79
|
+
export const SR_Arg_TimeoutException = "The operation has timed out.";
|
|
80
|
+
|
package/Guid.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { trim } from "./String.
|
|
2
|
-
import { FSharpRef } from "./Types.
|
|
1
|
+
import { trim } from "./String.ts";
|
|
2
|
+
import { FSharpRef } from "./Types.ts";
|
|
3
|
+
import { Exception } from "./Util.ts";
|
|
3
4
|
|
|
4
5
|
// RFC 4122 compliant. From https://stackoverflow.com/a/13653180/3922220
|
|
5
6
|
// const guidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
@@ -23,7 +24,7 @@ export function toString(str: string, format?: string, _provider?: any) {
|
|
|
23
24
|
case "X":
|
|
24
25
|
return str.replace(guidHexCaptures, "{0x$1,0x$3,0x$5,{0x$6,0x$7,0x$8,0x$9,0x$10,0x$11,0x$12,0x$13}}");
|
|
25
26
|
default:
|
|
26
|
-
throw new
|
|
27
|
+
throw new Exception("Unrecognized Guid print format");
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
else {
|
|
@@ -49,7 +50,7 @@ export function parse(str: string): string {
|
|
|
49
50
|
return hyphenateGuid(wsTrimAndLowered.replace(/[\{\},]|0x/g, ''));
|
|
50
51
|
}
|
|
51
52
|
else {
|
|
52
|
-
throw new
|
|
53
|
+
throw new Exception("Guid should contain 32 digits with 4 dashes: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
|
|
@@ -82,7 +83,7 @@ function initConvertMaps() {
|
|
|
82
83
|
_byteToHex = new Array(256);
|
|
83
84
|
_hexToByte = {};
|
|
84
85
|
for (let i = 0; i < 256; i++) {
|
|
85
|
-
_byteToHex[i] =
|
|
86
|
+
_byteToHex[i] = i.toString(16).padStart(2, '0');
|
|
86
87
|
_hexToByte[_byteToHex[i]] = i;
|
|
87
88
|
}
|
|
88
89
|
_convertMapsInitialized = true;
|
|
@@ -125,7 +126,7 @@ export function guidToArray(s: string): number[] {
|
|
|
125
126
|
/** Convert UUID byte array into a string */
|
|
126
127
|
export function arrayToGuid(buf: ArrayLike<number>) {
|
|
127
128
|
if (buf.length !== 16) {
|
|
128
|
-
throw new
|
|
129
|
+
throw new Exception("Byte array for GUID must be exactly 16 bytes long");
|
|
129
130
|
}
|
|
130
131
|
if (!_convertMapsInitialized) {
|
|
131
132
|
initConvertMaps();
|
package/Int32.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FSharpRef } from "./Types.
|
|
1
|
+
import { FSharpRef } from "./Types.ts";
|
|
2
|
+
import { Exception } from "./Util.ts";
|
|
2
3
|
|
|
3
4
|
export type int8 = number;
|
|
4
5
|
export type uint8 = number;
|
|
@@ -11,18 +12,18 @@ export type float16 = number;
|
|
|
11
12
|
export type float32 = number;
|
|
12
13
|
export type float64 = number;
|
|
13
14
|
|
|
14
|
-
export
|
|
15
|
-
// None
|
|
16
|
-
// AllowLeadingWhite
|
|
17
|
-
// AllowTrailingWhite
|
|
18
|
-
// AllowLeadingSign
|
|
19
|
-
// AllowTrailingSign
|
|
20
|
-
// AllowParentheses
|
|
21
|
-
// AllowDecimalPoint
|
|
22
|
-
// AllowThousands
|
|
23
|
-
// AllowExponent
|
|
24
|
-
// AllowCurrencySymbol
|
|
25
|
-
AllowHexSpecifier
|
|
15
|
+
export const NumberStyles = {
|
|
16
|
+
// None: 0x00000000,
|
|
17
|
+
// AllowLeadingWhite: 0x00000001,
|
|
18
|
+
// AllowTrailingWhite: 0x00000002,
|
|
19
|
+
// AllowLeadingSign: 0x00000004,
|
|
20
|
+
// AllowTrailingSign: 0x00000008,
|
|
21
|
+
// AllowParentheses: 0x00000010,
|
|
22
|
+
// AllowDecimalPoint: 0x00000020,
|
|
23
|
+
// AllowThousands: 0x00000040,
|
|
24
|
+
// AllowExponent: 0x00000080,
|
|
25
|
+
// AllowCurrencySymbol: 0x00000100,
|
|
26
|
+
AllowHexSpecifier: 0x00000200,
|
|
26
27
|
|
|
27
28
|
// Integer = AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign,
|
|
28
29
|
// HexNumber = AllowLeadingWhite | AllowTrailingWhite | AllowHexSpecifier,
|
|
@@ -34,7 +35,9 @@ export enum NumberStyles {
|
|
|
34
35
|
// AllowParentheses | AllowDecimalPoint | AllowThousands | AllowCurrencySymbol,
|
|
35
36
|
// Any = AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign | AllowTrailingSign |
|
|
36
37
|
// AllowParentheses | AllowDecimalPoint | AllowThousands | AllowCurrencySymbol | AllowExponent,
|
|
37
|
-
}
|
|
38
|
+
} as const;
|
|
39
|
+
|
|
40
|
+
export type NumberStyles = typeof NumberStyles[keyof typeof NumberStyles];
|
|
38
41
|
|
|
39
42
|
function validResponse(regexMatch: RegExpExecArray, radix: number) {
|
|
40
43
|
const [/*all*/, sign, prefix, digits] = regexMatch;
|
|
@@ -51,7 +54,7 @@ function getRange(unsigned: boolean, bitsize: number): [number, number] {
|
|
|
51
54
|
case 8: return unsigned ? [0, 255] : [-128, 127];
|
|
52
55
|
case 16: return unsigned ? [0, 65535] : [-32768, 32767];
|
|
53
56
|
case 32: return unsigned ? [0, 4294967295] : [-2147483648, 2147483647];
|
|
54
|
-
default: throw new
|
|
57
|
+
default: throw new Exception("Invalid bit size.");
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
|
|
@@ -62,7 +65,7 @@ function getInvalidDigits(radix: number): RegExp {
|
|
|
62
65
|
case 10: return /[^0-9]/;
|
|
63
66
|
case 16: return /[^0-9a-fA-F]/;
|
|
64
67
|
default:
|
|
65
|
-
throw new
|
|
68
|
+
throw new Exception("Invalid Base.");
|
|
66
69
|
}
|
|
67
70
|
}
|
|
68
71
|
|
|
@@ -118,7 +121,7 @@ export function parse(str: string, style: number, unsigned: boolean, bitsize: nu
|
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
}
|
|
121
|
-
throw new
|
|
124
|
+
throw new Exception(`The input string ${str} was not in a correct format.`);
|
|
122
125
|
}
|
|
123
126
|
|
|
124
127
|
export function tryParse(str: string, style: number, unsigned: boolean, bitsize: number, defValue: FSharpRef<number>): boolean {
|