@fable-org/fable-library-js 2.0.0-rc.4 → 2.0.0-rc.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/CHANGELOG.md +7 -0
- package/RegExp.js +11 -2
- package/String.js +18 -3
- package/Types.js +8 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## Unreleased
|
|
9
9
|
|
|
10
|
+
## 2.0.0-rc.5 - 2026-03-31
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
* [JS/TS] Improve `Regex.Escape` and `Regex.Unescape` handling (by @MangelMaxime)
|
|
15
|
+
* [JS/TS] Fixed quotation for union string cases (by @MangelMaxime)
|
|
16
|
+
|
|
10
17
|
## 2.0.0-rc.4 - 2026-03-19
|
|
11
18
|
|
|
12
19
|
### Fixed
|
package/RegExp.js
CHANGED
|
@@ -18,10 +18,19 @@ export function create(pattern, options = 0) {
|
|
|
18
18
|
}
|
|
19
19
|
// From http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
|
|
20
20
|
export function escape(str) {
|
|
21
|
-
|
|
21
|
+
// Matches the characters escaped by .NET's Regex.Escape.
|
|
22
|
+
// Note:
|
|
23
|
+
//
|
|
24
|
+
// .NET also escapes space and # (relevant for IgnorePatternWhitespace mode),
|
|
25
|
+
// but JS unicode-mode regex rejects \ and \# as invalid escapes, and we don't
|
|
26
|
+
// support IgnorePatternWhitespace, so we omit them.
|
|
27
|
+
//
|
|
28
|
+
// .NET does not escape ] and } but JS unicode-mode regex rejects bare ] and }
|
|
29
|
+
// as invalid, so we escape them too for compatibility.
|
|
30
|
+
return str.replace(/[$()*+.?[\\\^{|}\]]/g, "\\$&");
|
|
22
31
|
}
|
|
23
32
|
export function unescape(str) {
|
|
24
|
-
return str.replace(/\\([
|
|
33
|
+
return str.replace(/\\([$()*+.?[\\\^{|}\]])/g, "$1");
|
|
25
34
|
}
|
|
26
35
|
export function isMatch(reg, input, startAt = 0) {
|
|
27
36
|
reg.lastIndex = startAt;
|
package/String.js
CHANGED
|
@@ -331,7 +331,12 @@ export function format(str, ...args) {
|
|
|
331
331
|
precision = precision == null ? 2 : precision;
|
|
332
332
|
rep = toFixed(rep, precision);
|
|
333
333
|
parts = splitIntAndDecimalPart(rep);
|
|
334
|
-
|
|
334
|
+
if (precision > 0) {
|
|
335
|
+
rep = "¤" + thousandSeparate(parts.integral) + "." + padRight(parts.decimal, precision, "0");
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
rep = "¤" + thousandSeparate(parts.integral);
|
|
339
|
+
}
|
|
335
340
|
if (isNegative) {
|
|
336
341
|
rep = "(" + rep + ")";
|
|
337
342
|
}
|
|
@@ -375,14 +380,24 @@ export function format(str, ...args) {
|
|
|
375
380
|
precision = precision != null ? precision : 2;
|
|
376
381
|
rep = toFixed(rep, precision);
|
|
377
382
|
parts = splitIntAndDecimalPart(rep);
|
|
378
|
-
|
|
383
|
+
if (precision > 0) {
|
|
384
|
+
rep = thousandSeparate(parts.integral) + "." + padRight(parts.decimal, precision, "0");
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
rep = thousandSeparate(parts.integral);
|
|
388
|
+
}
|
|
379
389
|
break;
|
|
380
390
|
case "p":
|
|
381
391
|
case "P":
|
|
382
392
|
precision = precision != null ? precision : 2;
|
|
383
393
|
rep = toFixed(multiply(rep, 100), precision);
|
|
384
394
|
parts = splitIntAndDecimalPart(rep);
|
|
385
|
-
|
|
395
|
+
if (precision > 0) {
|
|
396
|
+
rep = thousandSeparate(parts.integral) + "." + padRight(parts.decimal, precision, "0") + " %";
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
rep = thousandSeparate(parts.integral) + " %";
|
|
400
|
+
}
|
|
386
401
|
break;
|
|
387
402
|
case "r":
|
|
388
403
|
case "R":
|
package/Types.js
CHANGED
|
@@ -36,6 +36,12 @@ export function toString(x, callStack = 0) {
|
|
|
36
36
|
return String(x);
|
|
37
37
|
}
|
|
38
38
|
export function unionToString(name, fields) {
|
|
39
|
+
function unionFieldToString(x) {
|
|
40
|
+
if (typeof x === "string") {
|
|
41
|
+
return '"' + x + '"';
|
|
42
|
+
}
|
|
43
|
+
return toString(x);
|
|
44
|
+
}
|
|
39
45
|
if (fields.length === 0) {
|
|
40
46
|
return name;
|
|
41
47
|
}
|
|
@@ -43,11 +49,11 @@ export function unionToString(name, fields) {
|
|
|
43
49
|
let fieldStr;
|
|
44
50
|
let withParens = true;
|
|
45
51
|
if (fields.length === 1) {
|
|
46
|
-
fieldStr =
|
|
52
|
+
fieldStr = unionFieldToString(fields[0]);
|
|
47
53
|
withParens = fieldStr.indexOf(" ") >= 0;
|
|
48
54
|
}
|
|
49
55
|
else {
|
|
50
|
-
fieldStr = fields.map((x) =>
|
|
56
|
+
fieldStr = fields.map((x) => unionFieldToString(x)).join(", ");
|
|
51
57
|
}
|
|
52
58
|
return name + (withParens ? " (" : " ") + fieldStr + (withParens ? ")" : "");
|
|
53
59
|
}
|
package/package.json
CHANGED