@fable-org/fable-library-ts 2.0.0-beta.4 → 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 +253 -247
- 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 +8 -0
- package/Char.ts +38 -35
- package/Choice.ts +36 -12
- 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 +31 -13
- package/FSharp.Core.CompilerServices.ts +4 -4
- package/FSharp.Core.ts +34 -34
- package/Global.ts +44 -2
- package/Guid.ts +7 -6
- package/Int32.ts +20 -17
- package/List.ts +57 -56
- package/Long.ts +6 -5
- package/MailboxProcessor.ts +8 -7
- package/Map.ts +67 -65
- package/MapUtil.ts +5 -5
- package/MutableMap.ts +32 -20
- package/MutableSet.ts +12 -12
- package/Native.ts +3 -3
- package/Numeric.ts +1 -1
- package/Observable.ts +3 -3
- package/Option.ts +3 -3
- package/Random.ts +34 -34
- package/Range.ts +7 -7
- package/Reflection.ts +73 -40
- package/RegExp.ts +5 -3
- package/Result.ts +31 -27
- package/Seq.ts +56 -54
- package/Seq2.ts +14 -14
- package/Set.ts +81 -80
- package/String.ts +41 -38
- package/System.Collections.Generic.ts +45 -25
- package/System.Text.ts +12 -12
- 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 +74 -26
- package/package.json +1 -1
- package/tsconfig.json +18 -5
- package/SystemException.ts +0 -7
package/Decimal.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import Decimal, { BigSource } from "./lib/big.js";
|
|
2
|
-
import { Numeric, symbol } from "./Numeric.
|
|
3
|
-
import { FSharpRef } from "./Types.
|
|
4
|
-
import { combineHashCodes } from "./Util.
|
|
5
|
-
import { int8, uint8, int16, uint16, int32, uint32, float16, float32, float64 } from "./Int32.
|
|
6
|
-
import { fromDecimal, int64, uint64, int128, uint128, nativeint, unativeint } from "./BigInt.
|
|
7
|
-
import * as bigInt from "./BigInt.
|
|
2
|
+
import { Numeric, symbol } from "./Numeric.ts";
|
|
3
|
+
import { FSharpRef } from "./Types.ts";
|
|
4
|
+
import { Exception, combineHashCodes } from "./Util.ts";
|
|
5
|
+
import { int8, uint8, int16, uint16, int32, uint32, float16, float32, float64 } from "./Int32.ts";
|
|
6
|
+
import { fromDecimal, int64, uint64, int128, uint128, nativeint, unativeint } from "./BigInt.ts";
|
|
7
|
+
import * as bigInt from "./BigInt.ts";
|
|
8
8
|
|
|
9
9
|
Decimal.prototype.GetHashCode = function () {
|
|
10
10
|
return combineHashCodes([this.s, this.e].concat(this.c))
|
|
@@ -138,7 +138,7 @@ export function parse(str: string): Decimal {
|
|
|
138
138
|
if (tryParse(str, defValue)) {
|
|
139
139
|
return defValue.contents;
|
|
140
140
|
} else {
|
|
141
|
-
throw new
|
|
141
|
+
throw new Exception(`The input string ${str} was not in a correct format.`);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
|
|
@@ -149,7 +149,7 @@ export function toNumber(x: Decimal): number {
|
|
|
149
149
|
export function toChar(x: Decimal): string {
|
|
150
150
|
const n = toNumber(x);
|
|
151
151
|
if (n < 0 || n > 65535 || isNaN(n)) {
|
|
152
|
-
throw new
|
|
152
|
+
throw new Exception("Value was either too large or too small for a character.");
|
|
153
153
|
}
|
|
154
154
|
return String.fromCharCode(n);
|
|
155
155
|
}
|
|
@@ -263,7 +263,7 @@ export function getBits(d: Decimal) {
|
|
|
263
263
|
// export function makeRangeStepFunction(step: Decimal, last: Decimal) {
|
|
264
264
|
// const stepComparedWithZero = step.cmp(get_Zero);
|
|
265
265
|
// if (stepComparedWithZero === 0) {
|
|
266
|
-
// throw new
|
|
266
|
+
// throw new Exception("The step of a range cannot be zero");
|
|
267
267
|
// }
|
|
268
268
|
// const stepGreaterThanZero = stepComparedWithZero > 0;
|
|
269
269
|
// return (x: Decimal) => {
|
package/Double.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 function tryParse(str: string, defValue: FSharpRef<number>): boolean {
|
|
4
5
|
// TODO: test if value is valid and in range
|
|
@@ -17,7 +18,7 @@ export function parse(str: string): number {
|
|
|
17
18
|
if (tryParse(str, defValue)) {
|
|
18
19
|
return defValue.contents;
|
|
19
20
|
} else {
|
|
20
|
-
throw new
|
|
21
|
+
throw new Exception(`The input string ${str} was not in a correct format.`);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
|
package/Encoding.ts
CHANGED
package/Event.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IObservable, subscribe } from "./Observable.
|
|
2
|
-
import { Option, some, value } from "./Option.
|
|
3
|
-
import { FSharpChoice$2_$union, Choice_tryValueIfChoice1Of2, Choice_tryValueIfChoice2Of2 } from "./Choice.
|
|
1
|
+
import { IObservable, subscribe } from "./Observable.ts";
|
|
2
|
+
import { Option, some, value } from "./Option.ts";
|
|
3
|
+
import { FSharpChoice$2_$union, Choice_tryValueIfChoice1Of2, Choice_tryValueIfChoice2Of2 } from "./Choice.ts";
|
|
4
4
|
|
|
5
5
|
export type Handler<T> = (sender: any, x: T) => void;
|
|
6
6
|
|
package/FSharp.Collections.ts
CHANGED
|
@@ -1,35 +1,53 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { int32 } from "./Int32.ts";
|
|
3
|
+
import { compare, IComparer, physicalHash, equals as equals_1, structuralHash, IEqualityComparer } from "./Util.ts";
|
|
4
4
|
|
|
5
|
-
export function HashIdentity_FromFunctions<T>(
|
|
5
|
+
export function HashIdentity_FromFunctions<T>(hasher: ((arg0: T) => int32), equals: ((arg0: T, arg1: T) => boolean)): IEqualityComparer<T> {
|
|
6
6
|
return {
|
|
7
|
-
|
|
8
|
-
return
|
|
7
|
+
GetHashCode(x: T): int32 {
|
|
8
|
+
return hasher(x) | 0;
|
|
9
9
|
},
|
|
10
|
-
|
|
11
|
-
return
|
|
10
|
+
Equals(x_1: T, y: T): boolean {
|
|
11
|
+
return (x_1 == null) ? (y == null) : ((y == null) ? false : equals(x_1, y));
|
|
12
12
|
},
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export function HashIdentity_Structural<T>(): IEqualityComparer<T> {
|
|
17
|
-
return
|
|
17
|
+
return {
|
|
18
|
+
GetHashCode(x: T): int32 {
|
|
19
|
+
return structuralHash(x) | 0;
|
|
20
|
+
},
|
|
21
|
+
Equals(x_1: T, y: T): boolean {
|
|
22
|
+
return equals_1(x_1, y);
|
|
23
|
+
},
|
|
24
|
+
};
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
export function HashIdentity_Reference<T>(): IEqualityComparer<T> {
|
|
21
|
-
return
|
|
28
|
+
return {
|
|
29
|
+
GetHashCode(x: T): int32 {
|
|
30
|
+
return physicalHash(x) | 0;
|
|
31
|
+
},
|
|
32
|
+
Equals(x_1: T, y: T): boolean {
|
|
33
|
+
return equals_1(x_1, y);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
22
36
|
}
|
|
23
37
|
|
|
24
|
-
export function ComparisonIdentity_FromFunction<T>(comparer: ((arg0:
|
|
38
|
+
export function ComparisonIdentity_FromFunction<T>(comparer: ((arg0: T, arg1: T) => int32)): IComparer<T> {
|
|
25
39
|
return {
|
|
26
|
-
Compare(x:
|
|
27
|
-
return comparer(x, y) | 0;
|
|
40
|
+
Compare(x: T, y: T): int32 {
|
|
41
|
+
return ((x == null) ? ((y == null) ? 0 : -1) : ((y == null) ? 1 : comparer(x, y))) | 0;
|
|
28
42
|
},
|
|
29
43
|
};
|
|
30
44
|
}
|
|
31
45
|
|
|
32
46
|
export function ComparisonIdentity_Structural<T>(): IComparer<T> {
|
|
33
|
-
return
|
|
47
|
+
return {
|
|
48
|
+
Compare(x: T, y: T): int32 {
|
|
49
|
+
return compare(x, y) | 0;
|
|
50
|
+
},
|
|
51
|
+
};
|
|
34
52
|
}
|
|
35
53
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
import { class_type, TypeInfo } from "./Reflection.
|
|
3
|
-
import { addRangeInPlace } from "./Array.
|
|
4
|
-
import { toList } from "./Seq.
|
|
5
|
-
import { FSharpList } from "./List.
|
|
2
|
+
import { class_type, TypeInfo } from "./Reflection.ts";
|
|
3
|
+
import { addRangeInPlace } from "./Array.ts";
|
|
4
|
+
import { toList } from "./Seq.ts";
|
|
5
|
+
import { FSharpList } from "./List.ts";
|
|
6
6
|
|
|
7
7
|
export class ListCollector$1<T> {
|
|
8
8
|
readonly collector: T[];
|
package/FSharp.Core.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
|
|
2
|
-
import { IDisposable, disposeSafe, IEqualityComparer, IComparer, structuralHash,
|
|
3
|
-
import { int32 } from "./Int32.
|
|
4
|
-
import { HashIdentity_Structural, ComparisonIdentity_Structural } from "./FSharp.Collections.
|
|
5
|
-
import { nonNullValue, Option } from "./Option.
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { StringBuilder__Append_Z721C83C5 } from "./System.Text.
|
|
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
9
|
|
|
10
10
|
export const LanguagePrimitives_GenericEqualityComparer: any = {
|
|
11
|
-
|
|
12
|
-
return
|
|
11
|
+
Equals(x: any, y: any): boolean {
|
|
12
|
+
return equals(x, y);
|
|
13
13
|
},
|
|
14
|
-
|
|
14
|
+
GetHashCode(x_1: any): int32 {
|
|
15
15
|
return structuralHash(x_1) | 0;
|
|
16
16
|
},
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export const LanguagePrimitives_GenericEqualityERComparer: any = {
|
|
20
|
-
|
|
21
|
-
return
|
|
20
|
+
Equals(x: any, y: any): boolean {
|
|
21
|
+
return equals(x, y);
|
|
22
22
|
},
|
|
23
|
-
|
|
23
|
+
GetHashCode(x_1: any): int32 {
|
|
24
24
|
return structuralHash(x_1) | 0;
|
|
25
25
|
},
|
|
26
26
|
};
|
|
@@ -41,16 +41,16 @@ export function LanguagePrimitives_FastGenericEqualityComparerFromTable<T>(): IE
|
|
|
41
41
|
return HashIdentity_Structural<T>();
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export function Operators_Failure(message: string):
|
|
45
|
-
return new
|
|
44
|
+
export function Operators_Failure(message: string): any {
|
|
45
|
+
return new Exception(message);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export function Operators_FailurePattern(exn:
|
|
48
|
+
export function Operators_FailurePattern(exn: Exception): Option<string> {
|
|
49
49
|
return exn.message;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
export function Operators_NullArg<$a>(
|
|
53
|
-
throw
|
|
52
|
+
export function Operators_NullArg<$a>(argumentName: string): $a {
|
|
53
|
+
throw ArgumentNullException_$ctor_Z721C83C5(argumentName);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
export function Operators_Using<T extends IDisposable, R>(resource: T, action: ((arg0: T) => R)): R {
|
|
@@ -58,7 +58,7 @@ export function Operators_Using<T extends IDisposable, R>(resource: T, action: (
|
|
|
58
58
|
return action(resource);
|
|
59
59
|
}
|
|
60
60
|
finally {
|
|
61
|
-
if (resource
|
|
61
|
+
if (equals(resource, defaultOf())) {
|
|
62
62
|
}
|
|
63
63
|
else {
|
|
64
64
|
let copyOfStruct: T = resource;
|
|
@@ -72,7 +72,7 @@ export function Operators_Lock<$a, $b>(_lockObj: $a, action: (() => $b)): $b {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
export function Operators_IsNull<T>(value: T): boolean {
|
|
75
|
-
if (value
|
|
75
|
+
if (equals(value, defaultOf())) {
|
|
76
76
|
return true;
|
|
77
77
|
}
|
|
78
78
|
else {
|
|
@@ -81,7 +81,7 @@ export function Operators_IsNull<T>(value: T): boolean {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
export function Operators_IsNotNull<T>(value: T): boolean {
|
|
84
|
-
if (value
|
|
84
|
+
if (equals(value, defaultOf())) {
|
|
85
85
|
return false;
|
|
86
86
|
}
|
|
87
87
|
else {
|
|
@@ -93,9 +93,9 @@ export function Operators_IsNullV<T extends any>(value: Nullable<T>): boolean {
|
|
|
93
93
|
return !(value != null);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
export function Operators_NonNull<T>(value:
|
|
97
|
-
if (value
|
|
98
|
-
throw
|
|
96
|
+
export function Operators_NonNull<T>(value: T): T {
|
|
97
|
+
if (equals(value, defaultOf())) {
|
|
98
|
+
throw NullReferenceException_$ctor();
|
|
99
99
|
}
|
|
100
100
|
else {
|
|
101
101
|
return value;
|
|
@@ -107,12 +107,12 @@ export function Operators_NonNullV<T extends any>(value: Nullable<T>): T {
|
|
|
107
107
|
return nonNullValue(value);
|
|
108
108
|
}
|
|
109
109
|
else {
|
|
110
|
-
throw
|
|
110
|
+
throw NullReferenceException_$ctor();
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
export function Operators_NullMatchPattern<T>(value:
|
|
115
|
-
if (value
|
|
114
|
+
export function Operators_NullMatchPattern<T>(value: T): FSharpChoice$2_$union<void, T> {
|
|
115
|
+
if (equals(value, defaultOf())) {
|
|
116
116
|
return FSharpChoice$2_Choice1Of2<void, T>(undefined);
|
|
117
117
|
}
|
|
118
118
|
else {
|
|
@@ -129,9 +129,9 @@ export function Operators_NullValueMatchPattern<T extends any>(value: Nullable<T
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
export function Operators_NonNullQuickPattern<T>(value:
|
|
133
|
-
if (value
|
|
134
|
-
throw
|
|
132
|
+
export function Operators_NonNullQuickPattern<T>(value: T): T {
|
|
133
|
+
if (equals(value, defaultOf())) {
|
|
134
|
+
throw NullReferenceException_$ctor();
|
|
135
135
|
}
|
|
136
136
|
else {
|
|
137
137
|
return value;
|
|
@@ -143,7 +143,7 @@ export function Operators_NonNullQuickValuePattern<T extends any>(value: Nullabl
|
|
|
143
143
|
return nonNullValue(value);
|
|
144
144
|
}
|
|
145
145
|
else {
|
|
146
|
-
throw
|
|
146
|
+
throw NullReferenceException_$ctor();
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
|
|
@@ -159,9 +159,9 @@ export function Operators_NullV<T extends any>(): Nullable<T> {
|
|
|
159
159
|
return null;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
export function Operators_NullArgCheck<T>(argumentName: string, value:
|
|
163
|
-
if (value
|
|
164
|
-
throw
|
|
162
|
+
export function Operators_NullArgCheck<T>(argumentName: string, value: T): T {
|
|
163
|
+
if (equals(value, defaultOf())) {
|
|
164
|
+
throw ArgumentNullException_$ctor_Z721C83C5(argumentName);
|
|
165
165
|
}
|
|
166
166
|
else {
|
|
167
167
|
return value;
|
package/Global.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { int32 } from "./Int32.
|
|
2
|
+
import { int32 } from "./Int32.ts";
|
|
3
3
|
|
|
4
4
|
export interface Fable_Core_IGenericAdder$1<T> {
|
|
5
5
|
Add(arg0: T, arg1: T): T,
|
|
@@ -13,7 +13,7 @@ export interface Fable_Core_IGenericAverager$1<T> {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export interface Fable_Core_Symbol_wellknown {
|
|
16
|
-
[Symbol.toStringTag]: string
|
|
16
|
+
get [Symbol.toStringTag](): string
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export interface Fable_Core_IJsonSerializable {
|
|
@@ -36,3 +36,45 @@ export const SR_differentLengths = "The collections had different lengths.";
|
|
|
36
36
|
|
|
37
37
|
export const SR_notEnoughElements = "The input sequence has an insufficient number of elements.";
|
|
38
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 {
|