@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.
Files changed (55) hide show
  1. package/Array.ts +1385 -1378
  2. package/Async.ts +13 -12
  3. package/AsyncBuilder.ts +10 -11
  4. package/BigInt.ts +6 -6
  5. package/BitConverter.ts +3 -3
  6. package/Boolean.ts +3 -2
  7. package/CHANGELOG.md +12 -0
  8. package/Char.ts +38 -35
  9. package/Choice.ts +326 -301
  10. package/CollectionUtil.ts +4 -4
  11. package/Date.ts +67 -62
  12. package/DateOffset.ts +48 -57
  13. package/DateOnly.ts +8 -8
  14. package/Decimal.ts +9 -9
  15. package/Double.ts +3 -2
  16. package/Encoding.ts +1 -1
  17. package/Event.ts +3 -3
  18. package/FSharp.Collections.ts +53 -34
  19. package/FSharp.Core.CompilerServices.ts +38 -37
  20. package/FSharp.Core.ts +186 -185
  21. package/Global.ts +80 -37
  22. package/Guid.ts +7 -6
  23. package/Int32.ts +20 -17
  24. package/List.ts +1429 -1417
  25. package/Long.ts +6 -5
  26. package/MailboxProcessor.ts +8 -7
  27. package/Map.ts +1550 -1552
  28. package/MapUtil.ts +5 -5
  29. package/MutableMap.ts +358 -345
  30. package/MutableSet.ts +250 -249
  31. package/Native.ts +19 -11
  32. package/Numeric.ts +1 -1
  33. package/Observable.ts +3 -3
  34. package/Option.ts +10 -4
  35. package/Random.ts +196 -194
  36. package/Range.ts +57 -56
  37. package/Reflection.ts +73 -40
  38. package/RegExp.ts +5 -3
  39. package/Result.ts +201 -196
  40. package/Seq.ts +1517 -1525
  41. package/Seq2.ts +130 -129
  42. package/Set.ts +1955 -1955
  43. package/String.ts +41 -38
  44. package/System.Collections.Generic.ts +401 -380
  45. package/System.Text.ts +204 -203
  46. package/System.ts +366 -0
  47. package/TimeOnly.ts +10 -10
  48. package/TimeSpan.ts +11 -11
  49. package/Timer.ts +2 -2
  50. package/Types.ts +1 -19
  51. package/Uri.ts +13 -10
  52. package/Util.ts +77 -21
  53. package/package.json +22 -22
  54. package/tsconfig.json +18 -5
  55. package/SystemException.ts +0 -7
package/FSharp.Core.ts CHANGED
@@ -1,185 +1,186 @@
1
- import { IDisposable, disposeSafe, defaultOf, IEqualityComparer, IComparer, structuralHash, equals } from "./Util.js";
2
- import { int32 } from "./Int32.js";
3
- import { HashIdentity_Structural, ComparisonIdentity_Structural } from "./FSharp.Collections.js";
4
- import { value as value_1, Nullable, Option } from "./Option.js";
5
- import { FSharpChoice$2_$union, FSharpChoice$2_Choice2Of2, FSharpChoice$2_Choice1Of2 } from "./Choice.js";
6
- import { concat } from "./String.js";
7
- import { StringBuilder, StringBuilder__Append_Z721C83C5 } from "./System.Text.js";
8
-
9
- export const LanguagePrimitives_GenericEqualityComparer: any = {
10
- "System.Collections.IEqualityComparer.Equals541DA560"(x: any, y: any): boolean {
11
- return equals(x, y);
12
- },
13
- "System.Collections.IEqualityComparer.GetHashCode4E60E31B"(x_1: any): int32 {
14
- return structuralHash(x_1) | 0;
15
- },
16
- };
17
-
18
- export const LanguagePrimitives_GenericEqualityERComparer: any = {
19
- "System.Collections.IEqualityComparer.Equals541DA560"(x: any, y: any): boolean {
20
- return equals(x, y);
21
- },
22
- "System.Collections.IEqualityComparer.GetHashCode4E60E31B"(x_1: any): int32 {
23
- return structuralHash(x_1) | 0;
24
- },
25
- };
26
-
27
- export function LanguagePrimitives_FastGenericComparer<T>(): IComparer<T> {
28
- return ComparisonIdentity_Structural<T>();
29
- }
30
-
31
- export function LanguagePrimitives_FastGenericComparerFromTable<T>(): IComparer<T> {
32
- return ComparisonIdentity_Structural<T>();
33
- }
34
-
35
- export function LanguagePrimitives_FastGenericEqualityComparer<T>(): IEqualityComparer<T> {
36
- return HashIdentity_Structural<T>();
37
- }
38
-
39
- export function LanguagePrimitives_FastGenericEqualityComparerFromTable<T>(): IEqualityComparer<T> {
40
- return HashIdentity_Structural<T>();
41
- }
42
-
43
- export function Operators_Failure(message: string): Error {
44
- return new Error(message);
45
- }
46
-
47
- export function Operators_FailurePattern(exn: Error): Option<string> {
48
- return exn.message;
49
- }
50
-
51
- export function Operators_NullArg<$a>(x: string): $a {
52
- throw new Error(x);
53
- }
54
-
55
- export function Operators_Using<T extends IDisposable, R>(resource: T, action: ((arg0: T) => R)): R {
56
- try {
57
- return action(resource);
58
- }
59
- finally {
60
- if (equals(resource, defaultOf())) {
61
- }
62
- else {
63
- let copyOfStruct: T = resource;
64
- disposeSafe(copyOfStruct);
65
- }
66
- }
67
- }
68
-
69
- export function Operators_Lock<$a, $b>(_lockObj: $a, action: (() => $b)): $b {
70
- return action();
71
- }
72
-
73
- export function Operators_IsNull<T>(value: T): boolean {
74
- if (equals(value, defaultOf())) {
75
- return true;
76
- }
77
- else {
78
- return false;
79
- }
80
- }
81
-
82
- export function Operators_IsNotNull<T>(value: T): boolean {
83
- if (equals(value, defaultOf())) {
84
- return false;
85
- }
86
- else {
87
- return true;
88
- }
89
- }
90
-
91
- export function Operators_IsNullV<T extends any>(value: Nullable<T>): boolean {
92
- return !(value != null);
93
- }
94
-
95
- export function Operators_NonNull<T>(value: T): T {
96
- if (equals(value, defaultOf())) {
97
- throw new Error();
98
- }
99
- else {
100
- return value;
101
- }
102
- }
103
-
104
- export function Operators_NonNullV<T extends any>(value: Nullable<T>): T {
105
- if (value != null) {
106
- return value_1(value);
107
- }
108
- else {
109
- throw new Error();
110
- }
111
- }
112
-
113
- export function Operators_NullMatchPattern<T>(value: T): FSharpChoice$2_$union<void, T> {
114
- if (equals(value, defaultOf())) {
115
- return FSharpChoice$2_Choice1Of2<void, T>(undefined);
116
- }
117
- else {
118
- return FSharpChoice$2_Choice2Of2<void, T>(value);
119
- }
120
- }
121
-
122
- export function Operators_NullValueMatchPattern<T extends any>(value: Nullable<T>): FSharpChoice$2_$union<void, T> {
123
- if (value != null) {
124
- return FSharpChoice$2_Choice2Of2<void, T>(value_1(value));
125
- }
126
- else {
127
- return FSharpChoice$2_Choice1Of2<void, T>(undefined);
128
- }
129
- }
130
-
131
- export function Operators_NonNullQuickPattern<T>(value: T): T {
132
- if (equals(value, defaultOf())) {
133
- throw new Error();
134
- }
135
- else {
136
- return value;
137
- }
138
- }
139
-
140
- export function Operators_NonNullQuickValuePattern<T extends any>(value: Nullable<T>): T {
141
- if (value != null) {
142
- return value_1(value);
143
- }
144
- else {
145
- throw new Error();
146
- }
147
- }
148
-
149
- export function Operators_WithNull<T>(value: T): T {
150
- return value;
151
- }
152
-
153
- export function Operators_WithNullV<T extends any>(value: T): T {
154
- return value;
155
- }
156
-
157
- export function Operators_NullV<T extends any>(): Nullable<T> {
158
- return defaultOf();
159
- }
160
-
161
- export function Operators_NullArgCheck<T>(argumentName: string, value: T): T {
162
- if (equals(value, defaultOf())) {
163
- throw new Error(concat("Value cannot be null. (Parameter \'", argumentName, ..."\')"));
164
- }
165
- else {
166
- return value;
167
- }
168
- }
169
-
170
- export function ExtraTopLevelOperators_LazyPattern<$a>(input: any): $a {
171
- return input.Value;
172
- }
173
-
174
- export function PrintfModule_PrintFormatToStringBuilderThen<$a, $b>(continuation: (() => $a), builder: StringBuilder, format: any): $b {
175
- return format.cont((s: string): $a => {
176
- StringBuilder__Append_Z721C83C5(builder, s);
177
- return continuation();
178
- });
179
- }
180
-
181
- export function PrintfModule_PrintFormatToStringBuilder<$a>(builder: StringBuilder, format: any): $a {
182
- return PrintfModule_PrintFormatToStringBuilderThen<void, $a>((): void => {
183
- }, builder, format);
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
- import { int32 } from "./Int32.js";
2
-
3
- export interface Fable_Core_IGenericAdder$1<T> {
4
- Add(arg0: T, arg1: T): T,
5
- GetZero(): T
6
- }
7
-
8
- export interface Fable_Core_IGenericAverager$1<T> {
9
- Add(arg0: T, arg1: T): T,
10
- DivideByInt(arg0: T, arg1: int32): T,
11
- GetZero(): T
12
- }
13
-
14
- export interface Fable_Core_Symbol_wellknown {
15
- [Symbol.toStringTag]: string
16
- }
17
-
18
- export interface Fable_Core_IJsonSerializable {
19
- toJSON(): any
20
- }
21
-
22
- export const SR_indexOutOfBounds = "The index was outside the range of elements in the collection.";
23
-
24
- export const SR_inputWasEmpty = "Collection was empty.";
25
-
26
- export const SR_inputMustBeNonNegative = "The input must be non-negative.";
27
-
28
- export const SR_inputSequenceEmpty = "The input sequence was empty.";
29
-
30
- export const SR_inputSequenceTooLong = "The input sequence contains more than one element.";
31
-
32
- export const SR_keyNotFoundAlt = "An index satisfying the predicate was not found in the collection.";
33
-
34
- export const SR_differentLengths = "The collections had different lengths.";
35
-
36
- export const SR_notEnoughElements = "The input sequence has an insufficient number of elements.";
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.js";
2
- import { FSharpRef } from "./Types.js";
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 Error("Unrecognized Guid print format");
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 Error("Guid should contain 32 digits with 4 dashes: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");
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] = (i + 0x100).toString(16).substr(1);
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 Error("Byte array for GUID must be exactly 16 bytes long");
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.js";
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 enum NumberStyles {
15
- // None = 0x00000000,
16
- // AllowLeadingWhite = 0x00000001,
17
- // AllowTrailingWhite = 0x00000002,
18
- // AllowLeadingSign = 0x00000004,
19
- // AllowTrailingSign = 0x00000008,
20
- // AllowParentheses = 0x00000010,
21
- // AllowDecimalPoint = 0x00000020,
22
- // AllowThousands = 0x00000040,
23
- // AllowExponent = 0x00000080,
24
- // AllowCurrencySymbol = 0x00000100,
25
- AllowHexSpecifier = 0x00000200,
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 Error("Invalid bit size.");
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 Error("Invalid Base.");
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 Error(`The input string ${str} was not in a correct format.`);
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 {