@magnusopera/fscript 0.88.0 → 0.90.1
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 +61 -68
- package/dist/FScript.Language/BuiltinSignatures.js +6 -6
- 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 +34 -33
- package/dist/FScript.Language/SupportLibrary.js +21 -20
- 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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { toString as dateToString } from "./Date.js";
|
|
2
|
-
import { compare as numericCompare, divide, isNumeric, isIntegral, multiply, toExponential, toFixed, toHex, toPrecision } from "./Numeric.js";
|
|
2
|
+
import { compare as numericCompare, divide, isNumeric, isIntegral, multiply, toExponential, toExponentialHalfEven, toFixed, toFixedHalfEven, toHex, toPrecision, toPrecisionHalfEven, toRadix } from "./Numeric.js";
|
|
3
3
|
import { escape } from "./RegExp.js";
|
|
4
|
+
import { ArgumentNullException_$ctor_Z721C83C5, ArgumentOutOfRangeException_$ctor_Z384F8060, ArgumentOutOfRangeException_$ctor_Z721C83C5, FormatException_$ctor_Z721C83C5 } from "./System.js";
|
|
4
5
|
import { toString } from "./Types.js";
|
|
5
6
|
import { Exception } from "./Util.js";
|
|
6
7
|
// Temporal date/time values (only present under --test:js-temporal) are not JS Dates. To avoid
|
|
@@ -16,7 +17,7 @@ function formatDateLike(rep, format) {
|
|
|
16
17
|
}
|
|
17
18
|
const fsFormatRegExp = /(^|[^%])%([0+\- ]*)(\*|\d+)?(?:\.(\d+))?(\w)/g;
|
|
18
19
|
const interpolateRegExp = /(?:(^|[^%])%([0+\- ]*)(\d+)?(?:\.(\d+))?(\w))?%P\(\)/g;
|
|
19
|
-
const formatRegExp = /\{(\d+)(,-?\d+)?(?:\:([a-zA-Z])(\d{0,2})|\:(.+?))?\}/g;
|
|
20
|
+
const formatRegExp = /\{\{|\}\}|\{(\d+)(,-?\d+)?(?:\:([a-zA-Z])(\d{0,2})|\:(.+?))?\}/g;
|
|
20
21
|
function isLessThan(x, y) {
|
|
21
22
|
return numericCompare(x, y) < 0;
|
|
22
23
|
}
|
|
@@ -161,6 +162,12 @@ export function printf(input) {
|
|
|
161
162
|
cont: fsFormat(input),
|
|
162
163
|
};
|
|
163
164
|
}
|
|
165
|
+
export function interpolatedPrintf(input, text) {
|
|
166
|
+
return {
|
|
167
|
+
input,
|
|
168
|
+
cont: (f) => f(text),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
164
171
|
export function interpolate(str, values) {
|
|
165
172
|
let valIdx = 0;
|
|
166
173
|
let strIdx = 0;
|
|
@@ -207,42 +214,44 @@ function formatReplacement(rep, flags, padLength, precision, format) {
|
|
|
207
214
|
flags = flags || "";
|
|
208
215
|
format = format || "";
|
|
209
216
|
if (isNumeric(rep)) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
sign = "+";
|
|
221
|
-
}
|
|
222
|
-
}
|
|
217
|
+
const radix = format === "x" || format === "X" ? 16 : format === "o" ? 8 : 10;
|
|
218
|
+
if (radix === 10 && isLessThan(rep, 0)) {
|
|
219
|
+
rep = multiply(rep, -1);
|
|
220
|
+
sign = "-";
|
|
221
|
+
}
|
|
222
|
+
else if (flags.indexOf(" ") >= 0) {
|
|
223
|
+
sign = " ";
|
|
224
|
+
}
|
|
225
|
+
else if (flags.indexOf("+") >= 0) {
|
|
226
|
+
sign = "+";
|
|
223
227
|
}
|
|
224
228
|
precision = precision == null ? null : parseInt(precision, 10);
|
|
225
229
|
switch (format) {
|
|
226
230
|
case "f":
|
|
227
231
|
case "F":
|
|
228
232
|
precision = precision != null ? precision : 6;
|
|
229
|
-
rep =
|
|
233
|
+
rep = toFixedHalfEven(rep, precision);
|
|
230
234
|
break;
|
|
231
235
|
case "g":
|
|
232
236
|
case "G":
|
|
233
|
-
rep = precision != null ?
|
|
237
|
+
rep = precision != null ? toPrecisionHalfEven(rep, precision) : toPrecision(rep);
|
|
234
238
|
break;
|
|
235
239
|
case "e":
|
|
236
240
|
case "E":
|
|
237
|
-
rep = precision != null ?
|
|
241
|
+
rep = precision != null ? toExponentialHalfEven(rep, precision) : toExponential(rep);
|
|
238
242
|
break;
|
|
239
243
|
case "x":
|
|
240
|
-
|
|
244
|
+
case "o":
|
|
245
|
+
rep = toRadix(rep, radix);
|
|
241
246
|
break;
|
|
242
247
|
case "X":
|
|
243
|
-
rep =
|
|
248
|
+
rep = toRadix(rep, radix).toUpperCase();
|
|
249
|
+
break;
|
|
250
|
+
case "":
|
|
251
|
+
case "O":
|
|
252
|
+
rep = typeof rep === "number" ? formatGeneral(rep, "R", null) : String(rep);
|
|
244
253
|
break;
|
|
245
|
-
default: //
|
|
254
|
+
default: // Aid
|
|
246
255
|
rep = String(rep);
|
|
247
256
|
break;
|
|
248
257
|
}
|
|
@@ -253,6 +262,9 @@ function formatReplacement(rep, flags, padLength, precision, format) {
|
|
|
253
262
|
else if (format === "A" && typeof rep === "string") {
|
|
254
263
|
rep = "\"" + rep + "\"";
|
|
255
264
|
}
|
|
265
|
+
else if (format === "s" && rep == null) {
|
|
266
|
+
rep = "";
|
|
267
|
+
}
|
|
256
268
|
else {
|
|
257
269
|
rep = toString(rep);
|
|
258
270
|
}
|
|
@@ -343,9 +355,69 @@ function splitIntAndDecimalPart(value) {
|
|
|
343
355
|
decimal: repDecimal
|
|
344
356
|
};
|
|
345
357
|
}
|
|
358
|
+
// .NET rounds a percentage on the unscaled value, at precision + 2 decimals
|
|
359
|
+
function shiftPercent(value) {
|
|
360
|
+
const sign = value.startsWith("-") ? "-" : "";
|
|
361
|
+
const [integral, decimal = ""] = value.slice(sign.length).split(".");
|
|
362
|
+
const shifted = (integral + decimal.slice(0, 2)).replace(/^0+(?=\d)/, "");
|
|
363
|
+
return sign + shifted + (decimal.length > 2 ? "." + decimal.slice(2) : "");
|
|
364
|
+
}
|
|
346
365
|
function thousandSeparate(value) {
|
|
347
366
|
return value.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
348
367
|
}
|
|
368
|
+
function splitExponential(s) {
|
|
369
|
+
const eIdx = s.indexOf("e");
|
|
370
|
+
return [s.slice(0, eIdx).replace(".", ""), Number(s.slice(eIdx + 1))];
|
|
371
|
+
}
|
|
372
|
+
function shortestSingle(x) {
|
|
373
|
+
// 100 digits tell where a float32 lies between two candidates, and 9 digits always round-trip
|
|
374
|
+
const [digits, exponent] = splitExponential(x.toExponential(99));
|
|
375
|
+
for (let p = 1;; p++) {
|
|
376
|
+
const down = Number(digits.slice(0, p));
|
|
377
|
+
const rest = digits.slice(p);
|
|
378
|
+
const half = "5".padEnd(rest.length, "0");
|
|
379
|
+
const roundUp = rest > half || rest === half && down % 2 === 1;
|
|
380
|
+
for (const n of roundUp ? [down + 1, down] : [down, down + 1]) {
|
|
381
|
+
if (Math.fround(Number(n + "e" + (exponent - p + 1))) === x) {
|
|
382
|
+
return [String(n), exponent + String(n).length - p];
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
// .NET "G" and "R": fixed notation unless the exponent is below -4 or reaches the precision (17 for the shortest digits, 9 for a float32)
|
|
388
|
+
function formatGeneral(x, format, precision, isSingle = false) {
|
|
389
|
+
if (!Number.isFinite(x)) {
|
|
390
|
+
return String(x);
|
|
391
|
+
}
|
|
392
|
+
const sign = x < 0 || Object.is(x, -0) ? "-" : "";
|
|
393
|
+
x = Math.abs(x);
|
|
394
|
+
// R ignores the precision and G0 is G
|
|
395
|
+
const p = format === "r" || format === "R" ? 0 : precision ?? 0;
|
|
396
|
+
const [significand, exponent] = p > 0 ? splitExponential(toExponentialHalfEven(x, p - 1)) : isSingle ? shortestSingle(x) : splitExponential(x.toExponential());
|
|
397
|
+
const digits = trimEnd(significand, "0") || "0";
|
|
398
|
+
if (exponent < -4 || exponent >= (p > 0 ? p : isSingle ? 9 : 17)) {
|
|
399
|
+
const mantissa = digits.length > 1 ? digits[0] + "." + digits.slice(1) : digits;
|
|
400
|
+
const eChar = format === "G" || format === "R" ? "E" : "e";
|
|
401
|
+
return sign + mantissa + eChar + (exponent < 0 ? "-" : "+") + padLeft(String(Math.abs(exponent)), 2, "0");
|
|
402
|
+
}
|
|
403
|
+
else if (exponent < 0) {
|
|
404
|
+
return sign + "0." + "0".repeat(-exponent - 1) + digits;
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
const decimals = digits.slice(exponent + 1);
|
|
408
|
+
return sign + digits.slice(0, exponent + 1).padEnd(exponent + 1, "0") + (decimals ? "." + decimals : "");
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
export function formatSingle(str, x) {
|
|
412
|
+
const m = /^\{0:([GgRr])(\d{0,2})\}$/.exec(str);
|
|
413
|
+
return m != null ? formatGeneral(Math.fround(x), m[1], m[2] ? parseInt(m[2], 10) : null, true) : format(str, x);
|
|
414
|
+
}
|
|
415
|
+
export function float64ToString(x) {
|
|
416
|
+
return formatGeneral(x, "R", null);
|
|
417
|
+
}
|
|
418
|
+
export function float32ToString(x) {
|
|
419
|
+
return formatGeneral(Math.fround(x), "R", null, true);
|
|
420
|
+
}
|
|
349
421
|
export function format(str, ...args) {
|
|
350
422
|
let str2;
|
|
351
423
|
if (typeof str === "object") {
|
|
@@ -356,7 +428,10 @@ export function format(str, ...args) {
|
|
|
356
428
|
else {
|
|
357
429
|
str2 = str;
|
|
358
430
|
}
|
|
359
|
-
return str2.replace(formatRegExp, (
|
|
431
|
+
return str2.replace(formatRegExp, (match, idx, padLength, format, precision, pattern) => {
|
|
432
|
+
if (match === "{{" || match === "}}") {
|
|
433
|
+
return match[0];
|
|
434
|
+
}
|
|
360
435
|
if (idx < 0 || idx >= args.length) {
|
|
361
436
|
throw new Exception("Index must be greater or equal to zero and less than the arguments' length.");
|
|
362
437
|
}
|
|
@@ -379,7 +454,7 @@ export function format(str, ...args) {
|
|
|
379
454
|
rep = multiply(rep, -1);
|
|
380
455
|
}
|
|
381
456
|
precision = precision == null ? 2 : precision;
|
|
382
|
-
rep =
|
|
457
|
+
rep = toFixedHalfEven(rep, precision);
|
|
383
458
|
parts = splitIntAndDecimalPart(rep);
|
|
384
459
|
if (precision > 0) {
|
|
385
460
|
rep = "¤" + thousandSeparate(parts.integral) + "." + padRight(parts.decimal, precision, "0");
|
|
@@ -409,7 +484,7 @@ export function format(str, ...args) {
|
|
|
409
484
|
case "e":
|
|
410
485
|
case "E": {
|
|
411
486
|
precision = precision != null ? precision : 6;
|
|
412
|
-
rep =
|
|
487
|
+
rep = toExponentialHalfEven(rep, precision);
|
|
413
488
|
// .NET always signs the exponent and pads it to at least three digits
|
|
414
489
|
const eIdx = rep.indexOf("e");
|
|
415
490
|
rep = rep.slice(0, eIdx) + format + rep[eIdx + 1] + padLeft(rep.slice(eIdx + 2), 3, "0");
|
|
@@ -418,19 +493,25 @@ export function format(str, ...args) {
|
|
|
418
493
|
case "f":
|
|
419
494
|
case "F":
|
|
420
495
|
precision = precision != null ? precision : 2;
|
|
421
|
-
rep =
|
|
496
|
+
rep = toFixedHalfEven(rep, precision);
|
|
422
497
|
if (precision > 0) {
|
|
423
498
|
parts = splitIntAndDecimalPart(rep);
|
|
424
499
|
rep = parts.integral + "." + padRight(parts.decimal, precision, "0");
|
|
425
500
|
}
|
|
426
501
|
break;
|
|
427
502
|
case "g":
|
|
428
|
-
case "G":
|
|
429
|
-
|
|
503
|
+
case "G":
|
|
504
|
+
case "r":
|
|
505
|
+
case "R": {
|
|
506
|
+
if (typeof rep === "number") {
|
|
507
|
+
rep = formatGeneral(rep, format, precision);
|
|
508
|
+
break;
|
|
509
|
+
}
|
|
510
|
+
if (precision == null) {
|
|
430
511
|
rep = String(rep);
|
|
431
512
|
break;
|
|
432
513
|
}
|
|
433
|
-
rep =
|
|
514
|
+
rep = toPrecision(rep, precision);
|
|
434
515
|
// Handle exponential notation: only trim trailing zeros from mantissa, not from exponent.
|
|
435
516
|
// .NET G format guarantees an exponent of at least 2 digits with an explicit sign (e.g. "E-07").
|
|
436
517
|
const eIdx = rep.indexOf("e");
|
|
@@ -439,7 +520,7 @@ export function format(str, ...args) {
|
|
|
439
520
|
const expSign = rep[eIdx + 1]; // toPrecision always emits "+" or "-"
|
|
440
521
|
const expDigits = rep.slice(eIdx + 2);
|
|
441
522
|
const paddedExpDigits = expDigits.length < 2 ? "0" + expDigits : expDigits;
|
|
442
|
-
const eChar = format === "G" ? "E" : "e";
|
|
523
|
+
const eChar = format === "G" || format === "R" ? "E" : "e";
|
|
443
524
|
rep = mantissa + eChar + expSign + paddedExpDigits;
|
|
444
525
|
}
|
|
445
526
|
else if (rep.indexOf(".") >= 0) {
|
|
@@ -450,7 +531,7 @@ export function format(str, ...args) {
|
|
|
450
531
|
case "n":
|
|
451
532
|
case "N":
|
|
452
533
|
precision = precision != null ? precision : 2;
|
|
453
|
-
rep =
|
|
534
|
+
rep = toFixedHalfEven(rep, precision);
|
|
454
535
|
parts = splitIntAndDecimalPart(rep);
|
|
455
536
|
if (precision > 0) {
|
|
456
537
|
rep = thousandSeparate(parts.integral) + "." + padRight(parts.decimal, precision, "0");
|
|
@@ -462,7 +543,7 @@ export function format(str, ...args) {
|
|
|
462
543
|
case "p":
|
|
463
544
|
case "P":
|
|
464
545
|
precision = precision != null ? precision : 2;
|
|
465
|
-
rep = toFixed(multiply(rep, 100), precision);
|
|
546
|
+
rep = typeof rep === "number" ? shiftPercent(toFixedHalfEven(rep, precision + 2)) : toFixed(multiply(rep, 100), precision);
|
|
466
547
|
parts = splitIntAndDecimalPart(rep);
|
|
467
548
|
if (precision > 0) {
|
|
468
549
|
rep = thousandSeparate(parts.integral) + "." + padRight(parts.decimal, precision, "0") + " %";
|
|
@@ -471,9 +552,6 @@ export function format(str, ...args) {
|
|
|
471
552
|
rep = thousandSeparate(parts.integral) + " %";
|
|
472
553
|
}
|
|
473
554
|
break;
|
|
474
|
-
case "r":
|
|
475
|
-
case "R":
|
|
476
|
-
throw new Exception("The round-trip format is not supported by Fable");
|
|
477
555
|
case "x":
|
|
478
556
|
case "X":
|
|
479
557
|
if (!isIntegral(rep)) {
|
|
@@ -539,13 +617,16 @@ export function format(str, ...args) {
|
|
|
539
617
|
});
|
|
540
618
|
rep = sign + rep;
|
|
541
619
|
}
|
|
620
|
+
else if (typeof rep === "number") {
|
|
621
|
+
rep = formatGeneral(rep, "R", null);
|
|
622
|
+
}
|
|
542
623
|
}
|
|
543
624
|
}
|
|
544
625
|
else if (rep instanceof Date || isNetDateFormattable(rep)) {
|
|
545
626
|
rep = formatDateLike(rep, pattern || format);
|
|
546
627
|
}
|
|
547
628
|
else {
|
|
548
|
-
rep = toString(rep);
|
|
629
|
+
rep = rep == null ? "" : toString(rep);
|
|
549
630
|
}
|
|
550
631
|
padLength = parseInt((padLength || " ").substring(1), 10);
|
|
551
632
|
if (!isNaN(padLength)) {
|
|
@@ -577,14 +658,14 @@ export function isNullOrWhiteSpace(str) {
|
|
|
577
658
|
return typeof str !== "string" || /^\s*$/.test(str);
|
|
578
659
|
}
|
|
579
660
|
export function concat(...xs) {
|
|
580
|
-
return xs.map((x) => String(x)).join("");
|
|
661
|
+
return xs.map((x) => (x == null ? "" : String(x))).join("");
|
|
581
662
|
}
|
|
582
663
|
export function join(delimiter, xs) {
|
|
583
664
|
if (Array.isArray(xs)) {
|
|
584
|
-
return xs.join(delimiter);
|
|
665
|
+
return xs.join(delimiter ?? "");
|
|
585
666
|
}
|
|
586
667
|
else {
|
|
587
|
-
return Array.from(xs).join(delimiter);
|
|
668
|
+
return Array.from(xs).join(delimiter ?? "");
|
|
588
669
|
}
|
|
589
670
|
}
|
|
590
671
|
export function joinWithIndices(delimiter, xs, startIndex, count) {
|
|
@@ -592,7 +673,7 @@ export function joinWithIndices(delimiter, xs, startIndex, count) {
|
|
|
592
673
|
if (endIndexPlusOne > xs.length) {
|
|
593
674
|
throw new Exception("Index and count must refer to a location within the buffer.");
|
|
594
675
|
}
|
|
595
|
-
return xs.slice(startIndex, endIndexPlusOne).join(delimiter);
|
|
676
|
+
return xs.slice(startIndex, endIndexPlusOne).join(delimiter ?? "");
|
|
596
677
|
}
|
|
597
678
|
function notSupported(name) {
|
|
598
679
|
throw new Exception("The environment doesn't support '" + name + "', please use a polyfill.");
|
|
@@ -612,6 +693,46 @@ export function fromBase64String(b64Encoded) {
|
|
|
612
693
|
}
|
|
613
694
|
return bytes;
|
|
614
695
|
}
|
|
696
|
+
export function toHexString(inArray, offset, length) {
|
|
697
|
+
if (inArray == null) {
|
|
698
|
+
throw ArgumentNullException_$ctor_Z721C83C5("inArray");
|
|
699
|
+
}
|
|
700
|
+
const start = offset ?? 0;
|
|
701
|
+
const count = length ?? inArray.length - start;
|
|
702
|
+
if (count < 0) {
|
|
703
|
+
throw ArgumentOutOfRangeException_$ctor_Z384F8060("length", "Non-negative number required.");
|
|
704
|
+
}
|
|
705
|
+
if (start < 0) {
|
|
706
|
+
throw ArgumentOutOfRangeException_$ctor_Z384F8060("offset", "Non-negative number required.");
|
|
707
|
+
}
|
|
708
|
+
if (start > inArray.length - count) {
|
|
709
|
+
throw ArgumentOutOfRangeException_$ctor_Z721C83C5("offset");
|
|
710
|
+
}
|
|
711
|
+
let str = "";
|
|
712
|
+
for (let i = start; i < start + count; i++) {
|
|
713
|
+
str += inArray[i].toString(16).padStart(2, "0");
|
|
714
|
+
}
|
|
715
|
+
return str.toUpperCase();
|
|
716
|
+
}
|
|
717
|
+
export function toHexStringLower(inArray, offset, length) {
|
|
718
|
+
return toHexString(inArray, offset, length).toLowerCase();
|
|
719
|
+
}
|
|
720
|
+
export function fromHexString(s) {
|
|
721
|
+
if (s == null) {
|
|
722
|
+
throw ArgumentNullException_$ctor_Z721C83C5("s");
|
|
723
|
+
}
|
|
724
|
+
if (s.length % 2 !== 0) {
|
|
725
|
+
throw FormatException_$ctor_Z721C83C5("The input is not a valid hex string as its length is not a multiple of 2.");
|
|
726
|
+
}
|
|
727
|
+
if (!/^[0-9A-Fa-f]*$/.test(s)) {
|
|
728
|
+
throw FormatException_$ctor_Z721C83C5("The input is not a valid hex string as it contains a non-hex character.");
|
|
729
|
+
}
|
|
730
|
+
const bytes = new Uint8Array(s.length / 2);
|
|
731
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
732
|
+
bytes[i] = parseInt(s.substring(2 * i, 2 * i + 2), 16);
|
|
733
|
+
}
|
|
734
|
+
return bytes;
|
|
735
|
+
}
|
|
615
736
|
function pad(str, len, ch, isRight) {
|
|
616
737
|
ch = ch || " ";
|
|
617
738
|
len = len - str.length;
|
|
@@ -5,6 +5,7 @@ import { toArray, empty, singleton, append, enumerateWhile, delay } from "./Seq.
|
|
|
5
5
|
import { setItem, initialize, copyTo, fill, item as item_1 } from "./Array.js";
|
|
6
6
|
import { max } from "./Double.js";
|
|
7
7
|
import { ArgumentOutOfRangeException_$ctor_Z721C83C5 } from "./System.js";
|
|
8
|
+
import { Operators_InvalidOp } from "./FSharp.Core.js";
|
|
8
9
|
export class KeyNotFoundException extends Exception {
|
|
9
10
|
constructor(message) {
|
|
10
11
|
super(message);
|
|
@@ -231,7 +232,7 @@ export function Queue$1__Enqueue_2B595(_, value) {
|
|
|
231
232
|
}
|
|
232
233
|
export function Queue$1__Dequeue(_) {
|
|
233
234
|
if (_.count === 0) {
|
|
234
|
-
throw
|
|
235
|
+
throw Operators_InvalidOp("Queue is empty");
|
|
235
236
|
}
|
|
236
237
|
const value = item_1(_.head, _.contents);
|
|
237
238
|
_.head = (((_.head + 1) % Queue$1__size(_)) | 0);
|
|
@@ -240,7 +241,7 @@ export function Queue$1__Dequeue(_) {
|
|
|
240
241
|
}
|
|
241
242
|
export function Queue$1__Peek(_) {
|
|
242
243
|
if (_.count === 0) {
|
|
243
|
-
throw
|
|
244
|
+
throw Operators_InvalidOp("Queue is empty");
|
|
244
245
|
}
|
|
245
246
|
return item_1(_.head, _.contents);
|
|
246
247
|
}
|
package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/System.Text.js
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { replace, format, replicate, substring, isNullOrEmpty, join } from "./String.js";
|
|
1
|
+
import { replace, getCharAtIndex, format, float64ToString, float32ToString, replicate, substring, isNullOrEmpty, join } from "./String.js";
|
|
2
2
|
import { class_type } from "./Reflection.js";
|
|
3
|
-
import {
|
|
3
|
+
import { toStringOrEmpty } from "./Types.js";
|
|
4
4
|
import { Exception, clear, int64ToString, int32ToString, int16ToString } from "./Util.js";
|
|
5
5
|
import { setItem, item } from "./Array.js";
|
|
6
6
|
export class StringBuilder {
|
|
@@ -31,11 +31,11 @@ export function StringBuilder_$ctor() {
|
|
|
31
31
|
return StringBuilder_$ctor_Z18115A39("", 16);
|
|
32
32
|
}
|
|
33
33
|
export function StringBuilder__Append_Z721C83C5(x, s) {
|
|
34
|
-
void (x.buf.push(
|
|
34
|
+
void (x.buf.push(toStringOrEmpty(s)));
|
|
35
35
|
return x;
|
|
36
36
|
}
|
|
37
37
|
export function StringBuilder__Append_487EF8FB(x, s, startIndex, count) {
|
|
38
|
-
void (x.buf.push(substring(
|
|
38
|
+
void (x.buf.push(substring(toStringOrEmpty(s), startIndex, count)));
|
|
39
39
|
return x;
|
|
40
40
|
}
|
|
41
41
|
export function StringBuilder__Append_244C7CD6(x, c) {
|
|
@@ -80,19 +80,19 @@ export function StringBuilder__Append_Z6EF827B6(x, o) {
|
|
|
80
80
|
return x;
|
|
81
81
|
}
|
|
82
82
|
export function StringBuilder__Append_Z7138B98C(x, o) {
|
|
83
|
-
void (x.buf.push(o
|
|
83
|
+
void (x.buf.push(float32ToString(o)));
|
|
84
84
|
return x;
|
|
85
85
|
}
|
|
86
86
|
export function StringBuilder__Append_5E38073B(x, o) {
|
|
87
|
-
void (x.buf.push(o
|
|
87
|
+
void (x.buf.push(float64ToString(o)));
|
|
88
88
|
return x;
|
|
89
89
|
}
|
|
90
90
|
export function StringBuilder__Append_Z1FBCCD16(x, o) {
|
|
91
|
-
void (x.buf.push(
|
|
91
|
+
void (x.buf.push(toStringOrEmpty(o)));
|
|
92
92
|
return x;
|
|
93
93
|
}
|
|
94
94
|
export function StringBuilder__Append_4E60E31B(x, o) {
|
|
95
|
-
void (x.buf.push(
|
|
95
|
+
void (x.buf.push(toStringOrEmpty(o)));
|
|
96
96
|
return x;
|
|
97
97
|
}
|
|
98
98
|
export function StringBuilder__Append_Z372E4D23(x, cs) {
|
|
@@ -160,7 +160,7 @@ export function StringBuilder__get_Chars_Z524259A4(x, index) {
|
|
|
160
160
|
}
|
|
161
161
|
else {
|
|
162
162
|
const pos = (index - len) | 0;
|
|
163
|
-
return item(i, x.buf)
|
|
163
|
+
return getCharAtIndex(item(i, x.buf), pos);
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
export function StringBuilder__set_Chars_413E0D0A(x, index, value) {
|
|
@@ -175,7 +175,7 @@ export function StringBuilder__set_Chars_413E0D0A(x, index, value) {
|
|
|
175
175
|
}
|
|
176
176
|
else {
|
|
177
177
|
const pos = (index - len) | 0;
|
|
178
|
-
setItem(x.buf, i, (item(i, x.buf).slice(0, (pos - 1) + 1) + value) + item(i, x.buf).slice(pos + 1, item(i, x.buf).length));
|
|
178
|
+
setItem(x.buf, i, (item(i, x.buf).slice(0, Math.max((pos - 1) + 1, 0)) + value) + item(i, x.buf).slice(Math.max(pos + 1, 0), item(i, x.buf).length));
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
export function StringBuilder__get_Length(x) {
|
|
@@ -239,16 +239,16 @@ export function ArgumentException_$ctor_Z60A2B367(message, paramName, innerExcep
|
|
|
239
239
|
return new ArgumentException(message, paramName, innerException);
|
|
240
240
|
}
|
|
241
241
|
export function ArgumentException_$ctor() {
|
|
242
|
-
return ArgumentException_$ctor_Z60A2B367(SR_Arg_ArgumentException,
|
|
242
|
+
return ArgumentException_$ctor_Z60A2B367(SR_Arg_ArgumentException, defaultOf(), defaultOf());
|
|
243
243
|
}
|
|
244
244
|
export function ArgumentException_$ctor_Z721C83C5(message) {
|
|
245
|
-
return ArgumentException_$ctor_Z60A2B367(message,
|
|
245
|
+
return ArgumentException_$ctor_Z60A2B367(message, defaultOf(), defaultOf());
|
|
246
246
|
}
|
|
247
247
|
export function ArgumentException_$ctor_Z384F8060(message, paramName) {
|
|
248
248
|
return ArgumentException_$ctor_Z60A2B367(message, paramName, defaultOf());
|
|
249
249
|
}
|
|
250
250
|
export function ArgumentException_$ctor_68CE3CA2(message, innerException) {
|
|
251
|
-
return ArgumentException_$ctor_Z60A2B367(message,
|
|
251
|
+
return ArgumentException_$ctor_Z60A2B367(message, defaultOf(), innerException);
|
|
252
252
|
}
|
|
253
253
|
export function ArgumentException__get_ParamName(_) {
|
|
254
254
|
return _.paramName;
|
|
@@ -268,7 +268,7 @@ export function ArgumentNullException_$ctor_Z721C83C5(paramName) {
|
|
|
268
268
|
return ArgumentNullException_$ctor_Z384F8060(paramName, SR_ArgumentNull_Generic);
|
|
269
269
|
}
|
|
270
270
|
export function ArgumentNullException_$ctor() {
|
|
271
|
-
return ArgumentNullException_$ctor_Z721C83C5(
|
|
271
|
+
return ArgumentNullException_$ctor_Z721C83C5(defaultOf());
|
|
272
272
|
}
|
|
273
273
|
export class ArgumentOutOfRangeException extends ArgumentException {
|
|
274
274
|
constructor(paramName, message) {
|
|
@@ -285,5 +285,5 @@ export function ArgumentOutOfRangeException_$ctor_Z721C83C5(paramName) {
|
|
|
285
285
|
return ArgumentOutOfRangeException_$ctor_Z384F8060(paramName, SR_Arg_ArgumentOutOfRangeException);
|
|
286
286
|
}
|
|
287
287
|
export function ArgumentOutOfRangeException_$ctor() {
|
|
288
|
-
return ArgumentOutOfRangeException_$ctor_Z721C83C5(
|
|
288
|
+
return ArgumentOutOfRangeException_$ctor_Z721C83C5(defaultOf());
|
|
289
289
|
}
|
|
@@ -28,7 +28,7 @@ export function add(t, ts, wrappedDays) {
|
|
|
28
28
|
const t2 = (t + ts) % millisecondsPerDay;
|
|
29
29
|
return t2 < 0 ? millisecondsPerDay + t2 : t2;
|
|
30
30
|
}
|
|
31
|
-
wrappedDays.contents = ts / millisecondsPerDay;
|
|
31
|
+
wrappedDays.contents = Math.trunc(ts / millisecondsPerDay);
|
|
32
32
|
let newMs = t + ts % millisecondsPerDay;
|
|
33
33
|
if (newMs < 0) {
|
|
34
34
|
wrappedDays.contents--;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Exception,
|
|
1
|
+
import { Exception, combineHashCode, compare, compareArrays, equalArrays, equals, sameConstructor, numberHash, structuralHash } from "./Util.js";
|
|
2
2
|
export function seqToString(self) {
|
|
3
3
|
let count = 0;
|
|
4
4
|
let str = "[";
|
|
@@ -41,6 +41,9 @@ export function toString(x, callStack = 0) {
|
|
|
41
41
|
}
|
|
42
42
|
return String(x);
|
|
43
43
|
}
|
|
44
|
+
export function toStringOrEmpty(x) {
|
|
45
|
+
return x == null ? "" : toString(x);
|
|
46
|
+
}
|
|
44
47
|
export function unionToString(name, fields) {
|
|
45
48
|
if (fields.length === 0) {
|
|
46
49
|
return name;
|
|
@@ -69,9 +72,11 @@ export class Union {
|
|
|
69
72
|
return unionToString(this.name, this.fields);
|
|
70
73
|
}
|
|
71
74
|
GetHashCode() {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
let h = combineHashCode(0, numberHash(this.tag));
|
|
76
|
+
for (let i = 0; i < this.fields.length; i++) {
|
|
77
|
+
h = combineHashCode(h, structuralHash(this.fields[i]));
|
|
78
|
+
}
|
|
79
|
+
return h;
|
|
75
80
|
}
|
|
76
81
|
Equals(other) {
|
|
77
82
|
if (this === other) {
|
|
@@ -114,8 +119,13 @@ function recordToString(self) {
|
|
|
114
119
|
return "{ " + Object.entries(self).map(([k, v]) => k + " = " + toStringQuoted(v)).join("\n ") + " }";
|
|
115
120
|
}
|
|
116
121
|
function recordGetHashCode(self) {
|
|
117
|
-
|
|
118
|
-
|
|
122
|
+
// Snapshot all values before calling any user-defined hash functions.
|
|
123
|
+
const values = Object.values(self);
|
|
124
|
+
let hash = 0;
|
|
125
|
+
for (let i = 0; i < values.length; i++) {
|
|
126
|
+
hash = combineHashCode(hash, structuralHash(values[i]));
|
|
127
|
+
}
|
|
128
|
+
return hash;
|
|
119
129
|
}
|
|
120
130
|
function recordEquals(self, other) {
|
|
121
131
|
if (self === other) {
|
|
@@ -161,19 +171,27 @@ export class Record {
|
|
|
161
171
|
}
|
|
162
172
|
export class FSharpRef {
|
|
163
173
|
get contents() {
|
|
164
|
-
return this.getter();
|
|
174
|
+
return this.getter === undefined ? this.value : this.getter();
|
|
165
175
|
}
|
|
166
176
|
set contents(v) {
|
|
167
|
-
this.setter
|
|
177
|
+
if (this.setter === undefined) {
|
|
178
|
+
this.value = v;
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
this.setter(v);
|
|
182
|
+
}
|
|
168
183
|
}
|
|
184
|
+
// Same field layout on both paths so every cell shares one hidden class
|
|
169
185
|
constructor(contentsOrGetter, setter) {
|
|
170
186
|
if (typeof setter === "function") {
|
|
171
187
|
this.getter = contentsOrGetter;
|
|
172
188
|
this.setter = setter;
|
|
189
|
+
this.value = undefined;
|
|
173
190
|
}
|
|
174
191
|
else {
|
|
175
|
-
this.getter =
|
|
176
|
-
this.setter =
|
|
192
|
+
this.getter = undefined;
|
|
193
|
+
this.setter = undefined;
|
|
194
|
+
this.value = contentsOrGetter;
|
|
177
195
|
}
|
|
178
196
|
}
|
|
179
197
|
}
|