@fable-org/fable-library-js 1.4.3 → 1.5.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/CHANGELOG.md +13 -0
- package/String.d.ts +1 -1
- package/String.js +17 -6
- package/Uri.d.ts +2 -0
- package/Uri.js +19 -1
- package/Util.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## Unreleased
|
|
9
9
|
|
|
10
|
+
## 1.5.0 - 2024-09-19
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
* [JS/TS] Add support for `OrdinalIgnoreCase` overload for `String.EndsWith` (#3892) (by @goswinr)
|
|
15
|
+
* [JS/TS] Add `uri.Port`, `uri.IsDefaultPort` (by @MangelMaxime)
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
* [JS/TS] Fix escaping of `{` and `}` in FormattableString (#3890) (by @roboz0r)
|
|
20
|
+
* [JS/TS] Fix `uri.Host` to return the host name without the port (by @MangelMaxime)
|
|
21
|
+
* [JS/TS] Fix TypeScript compilation by resolving type of `jsOptions` (#3894) (by @ManngelMaxime)
|
|
22
|
+
|
|
10
23
|
## 1.4.3 - 2024-09-04
|
|
11
24
|
|
|
12
25
|
* [JS/TS] Fixed Decimal comparisons (#3884) (by @ncave)
|
package/String.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export declare function compare(...args: any[]): number;
|
|
|
2
2
|
export declare function compareOrdinal(x: string, y: string): number;
|
|
3
3
|
export declare function compareTo(x: string, y: string): number;
|
|
4
4
|
export declare function startsWith(str: string, pattern: string, ic: number): boolean;
|
|
5
|
+
export declare function endsWith(str: string, pattern: string, ic: number): boolean;
|
|
5
6
|
export declare function indexOfAny(str: string, anyOf: string[], ...args: number[]): number;
|
|
6
7
|
export type IPrintfFormatContinuation = (f: (x: string) => any) => any;
|
|
7
8
|
export interface IPrintfFormat {
|
|
@@ -16,7 +17,6 @@ export declare function toText(arg: IPrintfFormat | string): any;
|
|
|
16
17
|
export declare function toFail(arg: IPrintfFormat | string): any;
|
|
17
18
|
export declare function fsFormat(str: string): (cont: (...args: any[]) => any) => any;
|
|
18
19
|
export declare function format(str: string | object, ...args: any[]): string;
|
|
19
|
-
export declare function endsWith(str: string, search: string): boolean;
|
|
20
20
|
export declare function initialize(n: number, f: (i: number) => string): string;
|
|
21
21
|
export declare function insert(str: string, startIndex: number, value: string): string;
|
|
22
22
|
export declare function isNullOrEmpty(str: string | any): boolean;
|
package/String.js
CHANGED
|
@@ -58,11 +58,23 @@ export function compareTo(x, y) {
|
|
|
58
58
|
return cmp(x, y, 0 /* StringComparison.CurrentCulture */);
|
|
59
59
|
}
|
|
60
60
|
export function startsWith(str, pattern, ic) {
|
|
61
|
+
if (ic === 4 /* StringComparison.Ordinal */) { // to avoid substring allocation
|
|
62
|
+
return str.startsWith(pattern);
|
|
63
|
+
}
|
|
61
64
|
if (str.length >= pattern.length) {
|
|
62
65
|
return cmp(str.substr(0, pattern.length), pattern, ic) === 0;
|
|
63
66
|
}
|
|
64
67
|
return false;
|
|
65
68
|
}
|
|
69
|
+
export function endsWith(str, pattern, ic) {
|
|
70
|
+
if (ic === 4 /* StringComparison.Ordinal */) { // to avoid substring allocation
|
|
71
|
+
return str.endsWith(pattern);
|
|
72
|
+
}
|
|
73
|
+
if (str.length >= pattern.length) {
|
|
74
|
+
return cmp(str.substr(str.length - pattern.length, pattern.length), pattern, ic) === 0;
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
66
78
|
export function indexOfAny(str, anyOf, ...args) {
|
|
67
79
|
if (str == null || str === "") {
|
|
68
80
|
return -1;
|
|
@@ -361,10 +373,6 @@ export function format(str, ...args) {
|
|
|
361
373
|
return rep;
|
|
362
374
|
});
|
|
363
375
|
}
|
|
364
|
-
export function endsWith(str, search) {
|
|
365
|
-
const idx = str.lastIndexOf(search);
|
|
366
|
-
return idx >= 0 && idx === str.length - search.length;
|
|
367
|
-
}
|
|
368
376
|
export function initialize(n, f) {
|
|
369
377
|
if (n < 0) {
|
|
370
378
|
throw new Error("String length must be non-negative");
|
|
@@ -537,7 +545,10 @@ export function fmtWith(fmts) {
|
|
|
537
545
|
return (strs, ...args) => ({ strs, args, fmts });
|
|
538
546
|
}
|
|
539
547
|
export function getFormat(s) {
|
|
548
|
+
const strs = s.strs.map((value) => value.replace(/{/g, '{{').replace(/}/g, '}}'));
|
|
540
549
|
return s.fmts
|
|
541
|
-
?
|
|
542
|
-
|
|
550
|
+
? strs
|
|
551
|
+
.reduce((acc, newPart, index) => acc + `{${String(index - 1) + s.fmts[index - 1]}}` + newPart)
|
|
552
|
+
: strs
|
|
553
|
+
.reduce((acc, newPart, index) => acc + `{${index - 1}}` + newPart);
|
|
543
554
|
}
|
package/Uri.d.ts
CHANGED
package/Uri.js
CHANGED
|
@@ -119,7 +119,13 @@ export class Uri {
|
|
|
119
119
|
return protocol.slice(0, protocol.length - 1);
|
|
120
120
|
}
|
|
121
121
|
get host() {
|
|
122
|
-
|
|
122
|
+
const host = this.asUrl().host;
|
|
123
|
+
if (host.includes(":")) {
|
|
124
|
+
return host.split(":")[0];
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
return host;
|
|
128
|
+
}
|
|
123
129
|
}
|
|
124
130
|
get absolutePath() {
|
|
125
131
|
return this.asUrl().pathname;
|
|
@@ -127,6 +133,18 @@ export class Uri {
|
|
|
127
133
|
get query() {
|
|
128
134
|
return this.asUrl().search;
|
|
129
135
|
}
|
|
136
|
+
get isDefaultPort() {
|
|
137
|
+
return this.port === 80;
|
|
138
|
+
}
|
|
139
|
+
get port() {
|
|
140
|
+
const port = this.asUrl().port;
|
|
141
|
+
if (port === "") {
|
|
142
|
+
return 80;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
return parseInt(port);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
130
148
|
get pathAndQuery() {
|
|
131
149
|
const url = this.asUrl();
|
|
132
150
|
return url.pathname + url.search;
|
package/Util.d.ts
CHANGED
|
@@ -161,7 +161,7 @@ export declare function max<T>(comparer: (x: T, y: T) => number, x: T, y: T): T;
|
|
|
161
161
|
export declare function clamp<T>(comparer: (x: T, y: T) => number, value: T, min: T, max: T): T;
|
|
162
162
|
export declare function createAtom<T>(value: T): (<Args extends [] | [T]>(...args: Args) => Args extends [] ? T : void);
|
|
163
163
|
export declare function createObj(fields: Iterable<[string, any]>): any;
|
|
164
|
-
export declare function jsOptions(mutator: (x:
|
|
164
|
+
export declare function jsOptions<T>(mutator: (x: T) => void): T;
|
|
165
165
|
export declare function round(value: number, digits?: number): number;
|
|
166
166
|
export declare function sign(x: number): number;
|
|
167
167
|
export declare function unescapeDataString(s: string): string;
|
package/package.json
CHANGED