@magnusopera/fscript 0.87.2 → 0.90.0
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/README.md +15 -0
- package/dist/FScript.Language/Ast.js +2 -2
- package/dist/FScript.Language/BuiltinFunctions.js +81 -69
- package/dist/FScript.Language/BuiltinSignatures.js +9 -8
- package/dist/FScript.Language/BuiltinTypes.js +1 -1
- package/dist/FScript.Language/Error.js +2 -2
- package/dist/FScript.Language/Eval.js +176 -127
- package/dist/FScript.Language/Execution.js +8 -7
- package/dist/FScript.Language/ExportSignatures.js +5 -5
- package/dist/FScript.Language/HostInterop.js +41 -11
- package/dist/FScript.Language/IncludeResolver.js +15 -19
- package/dist/FScript.Language/Interactive.js +9 -9
- package/dist/FScript.Language/Lexer.js +39 -39
- package/dist/FScript.Language/Parser.js +17 -17
- package/dist/FScript.Language/Pretty.js +5 -5
- package/dist/FScript.Language/Span.js +2 -2
- package/dist/FScript.Language/SupportCollections.js +2871 -0
- package/dist/FScript.Language/SupportLibrary.js +1998 -0
- package/dist/FScript.Language/TaskFunctions.js +51 -7
- package/dist/FScript.Language/TaskSharingAnalysis.js +310 -129
- package/dist/FScript.Language/Token.js +2 -2
- package/dist/FScript.Language/TypeInfer.js +21 -25
- package/dist/FScript.Language/Types.js +9 -9
- package/dist/FScript.Language/Value.js +11 -8
- package/dist/Library.js +54 -28
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Array.js +325 -198
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/BigInt.js +18 -6
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/CHANGELOG.md +64 -1
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Date.js +1 -1
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Decimal.js +33 -47
- package/dist/fable_modules/fable-library-js.5.27.0/Double.js +78 -0
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/FSharp.Core.js +7 -1
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Global.js +1 -1
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Int32.js +10 -1
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/List.js +230 -157
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Long.js +7 -2
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Map.js +46 -39
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/MutableMap.js +76 -96
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/MutableSet.js +58 -80
- package/dist/fable_modules/fable-library-js.5.27.0/NumberStyles.js +56 -0
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Numeric.js +72 -4
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Random.js +26 -17
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Range.js +4 -3
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Reflection.js +7 -1
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/RegExp.js +3 -2
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Seq.js +149 -70
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Seq2.js +4 -8
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Set.js +66 -59
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/String.js +160 -39
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/System.Collections.Generic.js +3 -2
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/System.Text.js +10 -10
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/System.js +5 -5
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/TimeOnly.js +1 -1
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Types.js +28 -10
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Util.js +151 -54
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/package.json +1 -1
- package/dist/fable_modules/project_cracked.json +1 -1
- package/package.json +1 -1
- package/dist/fable_modules/fable-library-js.5.24.0/Double.js +0 -53
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Async.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/AsyncBuilder.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/BitConverter.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Boolean.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Char.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Choice.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/CollectionUtil.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/ConditionalWeakTable.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/DateOffset.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/DateOnly.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/DateOnlyTemporal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/DateTimeFormat.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/DateTimeOffsetTemporal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/DateTimeTemporal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Directory.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Encoding.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Environment.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Event.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/FSharp.Collections.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/FSharp.Core.CompilerServices.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/File.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Guid.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/MailboxProcessor.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/MapUtil.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Native.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Observable.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Option.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Path.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/README.md +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Result.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Stopwatch.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Task.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/TaskBuilder.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/TimeOnlyTemporal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/TimeSpan.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/TimeSpanTemporal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Timer.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Unicode.13.0.0.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Uri.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/big.d.ts +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/lib/big.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/quotation.js +0 -0
package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/MutableSet.js
RENAMED
|
@@ -4,13 +4,14 @@ import { item as item_1, setItem } from "./Array.js";
|
|
|
4
4
|
import { some } from "./Option.js";
|
|
5
5
|
import { FSharpRef } from "./Types.js";
|
|
6
6
|
import { class_type } from "./Reflection.js";
|
|
7
|
-
import { getItemFromDict
|
|
7
|
+
import { getItemFromDict } from "./MapUtil.js";
|
|
8
8
|
export class HashSet {
|
|
9
9
|
constructor(items, comparer) {
|
|
10
10
|
const this$ = new FSharpRef(defaultOf());
|
|
11
11
|
this.comparer = comparer;
|
|
12
12
|
this$.contents = this;
|
|
13
13
|
this.hashMap = (new Map([]));
|
|
14
|
+
this.count = 0;
|
|
14
15
|
this["init@9"] = 1;
|
|
15
16
|
const enumerator = getEnumerator(items);
|
|
16
17
|
try {
|
|
@@ -116,39 +117,39 @@ export function HashSet_$reflection(gen0) {
|
|
|
116
117
|
export function HashSet_$ctor_Z6150332D(items, comparer) {
|
|
117
118
|
return new HashSet(items, comparer);
|
|
118
119
|
}
|
|
119
|
-
function
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
let outArg = defaultOf();
|
|
123
|
-
matchValue = [tryGetValue(this$.hashMap, h, new FSharpRef(() => outArg, (v) => {
|
|
124
|
-
outArg = v;
|
|
125
|
-
})), outArg];
|
|
126
|
-
if (matchValue[0]) {
|
|
127
|
-
return [true, h, matchValue[1].findIndex((v_1) => this$.comparer.Equals(k, v_1))];
|
|
120
|
+
function HashSet__TryFindBucket_Z524259A4(this$, h) {
|
|
121
|
+
if (this$.hashMap.has(h)) {
|
|
122
|
+
return getItemFromDict(this$.hashMap, h);
|
|
128
123
|
}
|
|
129
124
|
else {
|
|
130
|
-
return
|
|
125
|
+
return undefined;
|
|
131
126
|
}
|
|
132
127
|
}
|
|
133
|
-
function
|
|
134
|
-
|
|
135
|
-
let
|
|
136
|
-
|
|
137
|
-
if (
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
matchResult = 1;
|
|
128
|
+
function HashSet__FindIndex_Z142BBCA7(this$, k, bucket) {
|
|
129
|
+
let i = 0;
|
|
130
|
+
let found = -1;
|
|
131
|
+
while ((found < 0) && (i < bucket.length)) {
|
|
132
|
+
if (this$.comparer.Equals(k, item_1(i, bucket))) {
|
|
133
|
+
found = (i | 0);
|
|
142
134
|
}
|
|
135
|
+
i = ((i + 1) | 0);
|
|
143
136
|
}
|
|
144
|
-
|
|
145
|
-
|
|
137
|
+
return found | 0;
|
|
138
|
+
}
|
|
139
|
+
function HashSet__TryFind_2B595(this$, k) {
|
|
140
|
+
const matchValue = HashSet__TryFindBucket_Z524259A4(this$, this$.comparer.GetHashCode(k));
|
|
141
|
+
if (matchValue == null) {
|
|
142
|
+
return undefined;
|
|
146
143
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
144
|
+
else {
|
|
145
|
+
const bucket = matchValue;
|
|
146
|
+
const i = HashSet__FindIndex_Z142BBCA7(this$, k, bucket) | 0;
|
|
147
|
+
if (i > -1) {
|
|
148
|
+
return some(item_1(i, bucket));
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
151
|
return undefined;
|
|
152
|
+
}
|
|
152
153
|
}
|
|
153
154
|
}
|
|
154
155
|
export function HashSet__get_Comparer(this$) {
|
|
@@ -156,82 +157,59 @@ export function HashSet__get_Comparer(this$) {
|
|
|
156
157
|
}
|
|
157
158
|
export function HashSet__Clear(this$) {
|
|
158
159
|
this$.hashMap.clear();
|
|
160
|
+
this$.count = 0;
|
|
159
161
|
}
|
|
160
162
|
export function HashSet__get_Count(this$) {
|
|
161
|
-
|
|
162
|
-
let enumerator = getEnumerator(this$.hashMap.values());
|
|
163
|
-
try {
|
|
164
|
-
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
165
|
-
const items = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
166
|
-
count = ((count + items.length) | 0);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
finally {
|
|
170
|
-
disposeSafe(enumerator);
|
|
171
|
-
}
|
|
172
|
-
return count | 0;
|
|
163
|
+
return this$.count | 0;
|
|
173
164
|
}
|
|
174
165
|
export function HashSet__Add_2B595(this$, k) {
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
166
|
+
const h = this$.comparer.GetHashCode(k) | 0;
|
|
167
|
+
const matchValue = HashSet__TryFindBucket_Z524259A4(this$, h);
|
|
168
|
+
if (matchValue == null) {
|
|
169
|
+
this$.hashMap.set(h, [k]);
|
|
170
|
+
this$.count = ((this$.count + 1) | 0);
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
const bucket = matchValue;
|
|
175
|
+
if (HashSet__FindIndex_Z142BBCA7(this$, k, bucket) > -1) {
|
|
178
176
|
return false;
|
|
179
177
|
}
|
|
180
178
|
else {
|
|
181
|
-
void (
|
|
179
|
+
void (bucket.push(k));
|
|
180
|
+
this$.count = ((this$.count + 1) | 0);
|
|
182
181
|
return true;
|
|
183
182
|
}
|
|
184
183
|
}
|
|
185
|
-
else {
|
|
186
|
-
this$.hashMap.set(matchValue[1], [k]);
|
|
187
|
-
return true;
|
|
188
|
-
}
|
|
189
184
|
}
|
|
190
185
|
export function HashSet__Contains_2B595(this$, k) {
|
|
191
|
-
const matchValue =
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (matchValue[2] > -1) {
|
|
195
|
-
matchResult = 0;
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
matchResult = 1;
|
|
199
|
-
}
|
|
186
|
+
const matchValue = HashSet__TryFindBucket_Z524259A4(this$, this$.comparer.GetHashCode(k));
|
|
187
|
+
if (matchValue == null) {
|
|
188
|
+
return false;
|
|
200
189
|
}
|
|
201
190
|
else {
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
switch (matchResult) {
|
|
205
|
-
case 0:
|
|
206
|
-
return true;
|
|
207
|
-
default:
|
|
208
|
-
return false;
|
|
191
|
+
return HashSet__FindIndex_Z142BBCA7(this$, k, matchValue) > -1;
|
|
209
192
|
}
|
|
210
193
|
}
|
|
211
194
|
export function HashSet__Remove_2B595(this$, k) {
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
if (matchValue
|
|
215
|
-
|
|
216
|
-
matchResult = 0;
|
|
217
|
-
}
|
|
218
|
-
else {
|
|
219
|
-
matchResult = 1;
|
|
220
|
-
}
|
|
195
|
+
const h = this$.comparer.GetHashCode(k) | 0;
|
|
196
|
+
const matchValue = HashSet__TryFindBucket_Z524259A4(this$, h);
|
|
197
|
+
if (matchValue == null) {
|
|
198
|
+
return false;
|
|
221
199
|
}
|
|
222
200
|
else {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
this$.hashMap.delete(h_1);
|
|
201
|
+
const bucket = matchValue;
|
|
202
|
+
const i = HashSet__FindIndex_Z142BBCA7(this$, k, bucket) | 0;
|
|
203
|
+
if (i > -1) {
|
|
204
|
+
bucket.splice(i, 1);
|
|
205
|
+
this$.count = ((this$.count - 1) | 0);
|
|
206
|
+
if (bucket.length === 0) {
|
|
207
|
+
this$.hashMap.delete(h);
|
|
231
208
|
}
|
|
232
209
|
return true;
|
|
233
210
|
}
|
|
234
|
-
|
|
211
|
+
else {
|
|
235
212
|
return false;
|
|
213
|
+
}
|
|
236
214
|
}
|
|
237
215
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Exception } from "./Util.js";
|
|
2
|
+
export const NumberStyles = {
|
|
3
|
+
None: 0,
|
|
4
|
+
AllowLeadingWhite: 1,
|
|
5
|
+
AllowTrailingWhite: 2,
|
|
6
|
+
AllowLeadingSign: 4,
|
|
7
|
+
AllowTrailingSign: 8,
|
|
8
|
+
AllowParentheses: 16,
|
|
9
|
+
AllowDecimalPoint: 32,
|
|
10
|
+
AllowThousands: 64,
|
|
11
|
+
AllowExponent: 128,
|
|
12
|
+
AllowHexSpecifier: 512,
|
|
13
|
+
Integer: 7,
|
|
14
|
+
Number: 111,
|
|
15
|
+
Float: 167,
|
|
16
|
+
};
|
|
17
|
+
// The digits of a number string once white space, sign and parentheses are stripped.
|
|
18
|
+
// .NET allows group separators anywhere after the first digit of the integral part, even repeated.
|
|
19
|
+
function digitsPattern(style) {
|
|
20
|
+
const integral = style & NumberStyles.AllowThousands ? "\\d+(?:,\\d*)*" : "\\d+";
|
|
21
|
+
const point = style & NumberStyles.AllowDecimalPoint ? "(?:\\.\\d*)?" : "";
|
|
22
|
+
const leadingPoint = style & NumberStyles.AllowDecimalPoint ? "|\\.\\d+" : "";
|
|
23
|
+
const exponent = style & NumberStyles.AllowExponent ? "(?:[eE][+-]?\\d+)?" : "";
|
|
24
|
+
return new RegExp(`^(?:${integral}${point}${leadingPoint})${exponent}$`);
|
|
25
|
+
}
|
|
26
|
+
// Returns undefined when the string does not have the format allowed by the style
|
|
27
|
+
export function splitNumber(str, style) {
|
|
28
|
+
if (style & NumberStyles.AllowHexSpecifier) {
|
|
29
|
+
throw new Exception("The number style AllowHexSpecifier is not supported on floating point data types.");
|
|
30
|
+
}
|
|
31
|
+
// .NET ignores trailing NULs and its white space is only [\t\n\v\f\r ]
|
|
32
|
+
let s = str.replace(/\0+$/, "");
|
|
33
|
+
if (style & NumberStyles.AllowLeadingWhite) {
|
|
34
|
+
s = s.replace(/^[\t-\r ]+/, "");
|
|
35
|
+
}
|
|
36
|
+
if (style & NumberStyles.AllowTrailingWhite) {
|
|
37
|
+
s = s.replace(/[\t-\r ]+$/, "");
|
|
38
|
+
}
|
|
39
|
+
let negative = false;
|
|
40
|
+
if (style & NumberStyles.AllowParentheses && s.startsWith("(") && s.endsWith(")")) {
|
|
41
|
+
s = s.slice(1, -1);
|
|
42
|
+
negative = true;
|
|
43
|
+
}
|
|
44
|
+
if (style & NumberStyles.AllowLeadingSign && /^[+-]/.test(s)) {
|
|
45
|
+
negative = s[0] === "-" ? !negative : negative;
|
|
46
|
+
s = s.slice(1);
|
|
47
|
+
}
|
|
48
|
+
else if (style & NumberStyles.AllowTrailingSign && /[+-]$/.test(s)) {
|
|
49
|
+
negative = s[s.length - 1] === "-" ? !negative : negative;
|
|
50
|
+
s = s.slice(0, -1);
|
|
51
|
+
}
|
|
52
|
+
if (!digitsPattern(style).test(s)) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
return { digits: s.replace(/,/g, ""), negative };
|
|
56
|
+
}
|
|
@@ -98,15 +98,83 @@ export function toExponential(x, dp) {
|
|
|
98
98
|
return x[symbol]().toExponential(dp);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
|
|
101
|
+
function isExactTie(x, k) {
|
|
102
|
+
if (k >= 0) {
|
|
103
|
+
const t = x * 2 ** (k + 1);
|
|
104
|
+
return Number.isInteger(t) && t % 2 !== 0;
|
|
105
|
+
}
|
|
106
|
+
else if (Number.isInteger(x)) {
|
|
107
|
+
const p = 10n ** BigInt(-k);
|
|
108
|
+
return BigInt(Math.abs(x)) % p === p / 2n;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function truncateLastDigit(digits) {
|
|
115
|
+
const s = digits.slice(0, -1);
|
|
116
|
+
return s.endsWith(".") ? s.slice(0, -1) : s;
|
|
117
|
+
}
|
|
118
|
+
function isLastDigitEven(digits) {
|
|
119
|
+
return digits.charCodeAt(digits.length - 1) % 2 === 0;
|
|
120
|
+
}
|
|
121
|
+
// .NET standard numeric formats give an exact midpoint of a double the even digit
|
|
122
|
+
export function toFixedHalfEven(x, dp) {
|
|
123
|
+
if (typeof x === "number" && dp < 100 && isExactTie(x, dp)) {
|
|
124
|
+
const truncated = truncateLastDigit(x.toFixed(dp + 1));
|
|
125
|
+
return isLastDigitEven(truncated) ? truncated : x.toFixed(dp);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
return toFixed(x, dp);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
export function toExponentialHalfEven(x, dp) {
|
|
132
|
+
if (typeof x === "number" && Number.isFinite(x) && dp < 100) {
|
|
133
|
+
const exact = x.toExponential(dp + 1);
|
|
134
|
+
const eIdx = exact.indexOf("e");
|
|
135
|
+
const mantissa = exact.slice(0, eIdx);
|
|
136
|
+
if (mantissa.endsWith("5") && isExactTie(x, dp - Number(exact.slice(eIdx + 1)))) {
|
|
137
|
+
const truncated = truncateLastDigit(mantissa);
|
|
138
|
+
return isLastDigitEven(truncated) ? truncated + exact.slice(eIdx) : x.toExponential(dp);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return toExponential(x, dp);
|
|
142
|
+
}
|
|
143
|
+
export function toPrecisionHalfEven(x, sd) {
|
|
144
|
+
if (typeof x !== "number" || !(sd > 0)) {
|
|
145
|
+
return toPrecision(x, sd);
|
|
146
|
+
}
|
|
147
|
+
const s = toExponentialHalfEven(x, sd - 1);
|
|
148
|
+
if (s === x.toExponential(sd - 1)) {
|
|
149
|
+
return x.toPrecision(sd);
|
|
150
|
+
}
|
|
151
|
+
// Same notation as Number.prototype.toPrecision
|
|
152
|
+
const eIdx = s.indexOf("e");
|
|
153
|
+
const e = Number(s.slice(eIdx + 1));
|
|
154
|
+
if (e < -6 || e >= sd) {
|
|
155
|
+
return s;
|
|
156
|
+
}
|
|
157
|
+
const sign = s.startsWith("-") ? "-" : "";
|
|
158
|
+
const digits = s.slice(sign.length, eIdx).replace(".", "");
|
|
159
|
+
return e < 0
|
|
160
|
+
? sign + "0." + "0".repeat(-e - 1) + digits
|
|
161
|
+
: sign + digits.slice(0, e + 1) + (sd > e + 1 ? "." + digits.slice(e + 1) : "");
|
|
162
|
+
}
|
|
163
|
+
export function toRadix(x, radix) {
|
|
102
164
|
if (typeof x === "number") {
|
|
103
|
-
return (Number(x) >>> 0).toString(
|
|
165
|
+
return (Number(x) >>> 0).toString(radix);
|
|
104
166
|
}
|
|
105
167
|
else if (typeof x === "bigint") {
|
|
106
168
|
// TODO: properly handle other bit sizes
|
|
107
|
-
return BigInt.asUintN(64, x).toString(
|
|
169
|
+
return BigInt.asUintN(64, x).toString(radix);
|
|
108
170
|
}
|
|
109
|
-
else {
|
|
171
|
+
else if (radix === 16) {
|
|
110
172
|
return x[symbol]().toHex();
|
|
111
173
|
}
|
|
174
|
+
else {
|
|
175
|
+
return String(x);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
export function toHex(x) {
|
|
179
|
+
return toRadix(x, 16);
|
|
112
180
|
}
|
|
@@ -1,19 +1,27 @@
|
|
|
1
|
-
import { ArgumentNullException_$ctor_Z721C83C5, ArgumentOutOfRangeException_$
|
|
2
|
-
import {
|
|
1
|
+
import { ArgumentNullException_$ctor_Z721C83C5, ArgumentOutOfRangeException_$ctor_Z384F8060 } from "./System.js";
|
|
2
|
+
import { int32ToString } from "./Util.js";
|
|
3
3
|
import { class_type } from "./Reflection.js";
|
|
4
|
-
import { fromFloat64, op_Addition, toInt32_unchecked, toFloat64, compare, fromInt32, toInt64_unchecked } from "./BigInt.js";
|
|
4
|
+
import { fromFloat64, op_Addition, toInt32_unchecked, toFloat64, compare, fromInt32, op_Subtraction, toInt64_unchecked } from "./BigInt.js";
|
|
5
5
|
import { item, setItem } from "./Array.js";
|
|
6
|
+
function checkMaxValue(maxValue) {
|
|
7
|
+
if (maxValue < 0) {
|
|
8
|
+
throw ArgumentOutOfRangeException_$ctor_Z384F8060("maxValue", ("maxValue (\'" + int32ToString(maxValue)) + "\') must be a non-negative value.");
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function checkMinMaxValue(minValue, maxValue) {
|
|
12
|
+
if (minValue > maxValue) {
|
|
13
|
+
throw ArgumentOutOfRangeException_$ctor_Z384F8060("minValue", "\'minValue\' cannot be greater than maxValue.");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
6
16
|
function Native_random() {
|
|
7
17
|
return Math.random();
|
|
8
18
|
}
|
|
9
19
|
function Native_randomNext(minValue, maxValue) {
|
|
10
|
-
|
|
11
|
-
throw ArgumentOutOfRangeException_$ctor_Z721C83C5("minValue must be less than maxValue");
|
|
12
|
-
}
|
|
20
|
+
checkMinMaxValue(minValue, maxValue);
|
|
13
21
|
return Math.floor(Math.random() * (maxValue - minValue)) + minValue;
|
|
14
22
|
}
|
|
15
23
|
function Native_randomBytes(buffer) {
|
|
16
|
-
if (
|
|
24
|
+
if (buffer == null) {
|
|
17
25
|
throw ArgumentNullException_$ctor_Z721C83C5("buffer");
|
|
18
26
|
}
|
|
19
27
|
for (let i = 0; i < buffer.length; i += 6) {
|
|
@@ -37,6 +45,7 @@ export class NonSeeded {
|
|
|
37
45
|
return Native_randomNext(0, 2147483647) | 0;
|
|
38
46
|
}
|
|
39
47
|
Next1(maxValue) {
|
|
48
|
+
checkMaxValue(maxValue);
|
|
40
49
|
return Native_randomNext(0, maxValue) | 0;
|
|
41
50
|
}
|
|
42
51
|
Next2(minValue, maxValue) {
|
|
@@ -94,17 +103,13 @@ export class Seeded {
|
|
|
94
103
|
}
|
|
95
104
|
Next1(maxValue) {
|
|
96
105
|
const this$ = this;
|
|
97
|
-
|
|
98
|
-
throw ArgumentOutOfRangeException_$ctor_Z721C83C5("maxValue must be positive");
|
|
99
|
-
}
|
|
106
|
+
checkMaxValue(maxValue);
|
|
100
107
|
return ~~(Seeded__Sample(this$) * maxValue) | 0;
|
|
101
108
|
}
|
|
102
109
|
Next2(minValue, maxValue) {
|
|
103
110
|
const this$ = this;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
const range = toInt64_unchecked(fromInt32(maxValue - minValue));
|
|
111
|
+
checkMinMaxValue(minValue, maxValue);
|
|
112
|
+
const range = toInt64_unchecked(op_Subtraction(toInt64_unchecked(fromInt32(maxValue)), toInt64_unchecked(fromInt32(minValue))));
|
|
108
113
|
return ((compare(range, toInt64_unchecked(fromInt32(2147483647))) <= 0) ? (~~(Seeded__Sample(this$) * toFloat64(range)) + minValue) : ~~toInt32_unchecked(toInt64_unchecked(op_Addition(toInt64_unchecked(fromFloat64(Seeded__GetSampleForLargeRange(this$) * toFloat64(range))), toInt64_unchecked(fromInt32(minValue)))))) | 0;
|
|
109
114
|
}
|
|
110
115
|
NextDouble() {
|
|
@@ -113,11 +118,11 @@ export class Seeded {
|
|
|
113
118
|
}
|
|
114
119
|
NextBytes(buffer) {
|
|
115
120
|
const this$ = this;
|
|
116
|
-
if (
|
|
121
|
+
if (buffer == null) {
|
|
117
122
|
throw ArgumentNullException_$ctor_Z721C83C5("buffer");
|
|
118
123
|
}
|
|
119
124
|
for (let i = 0; i <= (buffer.length - 1); i++) {
|
|
120
|
-
setItem(buffer, i, (Seeded__InternalSample(this$) % (~~255 + 1)) & 0xFF);
|
|
125
|
+
setItem(buffer, i, ~~(Seeded__InternalSample(this$) % (~~255 + 1)) & 0xFF);
|
|
121
126
|
}
|
|
122
127
|
}
|
|
123
128
|
}
|
|
@@ -161,12 +166,16 @@ export function Seeded__GetSampleForLargeRange(this$) {
|
|
|
161
166
|
}
|
|
162
167
|
let d = result;
|
|
163
168
|
d = (d + (2147483647 - 1));
|
|
164
|
-
d = (d / (2 *
|
|
169
|
+
d = (d / ((2 * 2147483647) - 1));
|
|
165
170
|
return d;
|
|
166
171
|
}
|
|
172
|
+
const sharedRandom = NonSeeded_$ctor();
|
|
167
173
|
export function nonSeeded() {
|
|
168
174
|
return NonSeeded_$ctor();
|
|
169
175
|
}
|
|
170
176
|
export function seeded(seed) {
|
|
171
177
|
return Seeded_$ctor_Z524259A4(seed);
|
|
172
178
|
}
|
|
179
|
+
export function shared() {
|
|
180
|
+
return sharedRandom;
|
|
181
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { compare } from "./Util.js";
|
|
2
|
+
import { Operators_InvalidArg } from "./FSharp.Core.js";
|
|
2
3
|
import { unfold, delay } from "./Seq.js";
|
|
3
4
|
import { toUInt64_unchecked, toInt64_unchecked, op_Addition, fromZero } from "./BigInt.js";
|
|
4
5
|
import { op_Addition as op_Addition_1, fromParts } from "./Decimal.js";
|
|
5
6
|
export function makeRangeStepFunction(step, stop, zero, add) {
|
|
6
7
|
const stepComparedWithZero = compare(step, zero) | 0;
|
|
7
8
|
if (stepComparedWithZero === 0) {
|
|
8
|
-
throw
|
|
9
|
+
throw Operators_InvalidArg("step", "The step of a range cannot be zero.");
|
|
9
10
|
}
|
|
10
11
|
const stepGreaterThanZero = stepComparedWithZero > 0;
|
|
11
12
|
return (x) => {
|
|
@@ -36,7 +37,7 @@ export function rangeChar(start, stop) {
|
|
|
36
37
|
const intStop = ~~stop.charCodeAt(0) | 0;
|
|
37
38
|
return delay(() => unfold((i) => {
|
|
38
39
|
if (i <= intStop) {
|
|
39
|
-
return [String.fromCharCode(i & 0xFFFF), i + 1];
|
|
40
|
+
return [String.fromCharCode(~~i & 0xFFFF), i + 1];
|
|
40
41
|
}
|
|
41
42
|
else {
|
|
42
43
|
return undefined;
|
package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Reflection.js
RENAMED
|
@@ -22,11 +22,17 @@ export class TypeInfo {
|
|
|
22
22
|
this.fullname = fullname;
|
|
23
23
|
this.generics = generics;
|
|
24
24
|
this.construct = construct;
|
|
25
|
-
this.
|
|
25
|
+
this.lazyParent = parent;
|
|
26
26
|
this.fields = fields;
|
|
27
27
|
this.cases = cases;
|
|
28
28
|
this.enumCases = enumCases;
|
|
29
29
|
}
|
|
30
|
+
get parent() {
|
|
31
|
+
if (typeof this.lazyParent === "function") {
|
|
32
|
+
this.lazyParent = this.lazyParent();
|
|
33
|
+
}
|
|
34
|
+
return this.lazyParent;
|
|
35
|
+
}
|
|
30
36
|
toString() {
|
|
31
37
|
return fullName(this);
|
|
32
38
|
}
|
|
@@ -6,8 +6,9 @@ export function create(pattern, options = 0) {
|
|
|
6
6
|
// * Compiled: 0x0008 (ignored)
|
|
7
7
|
// * Singleline: 0x0010
|
|
8
8
|
// * ECMAScript: 0x0100 (ignored)
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
// * NonBacktracking: 0x0400 (ignored)
|
|
10
|
+
if ((options & ~(1 ^ 2 ^ 8 ^ 16 ^ 256 ^ 1024)) !== 0) {
|
|
11
|
+
throw new Exception("RegexOptions only supports: IgnoreCase, Multiline, Compiled, Singleline, ECMAScript and NonBacktracking");
|
|
11
12
|
}
|
|
12
13
|
// Set always global and unicode flags for compatibility with dotnet, see #2925
|
|
13
14
|
let flags = "gu";
|