@fable-org/fable-library-js 1.4.2 → 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 CHANGED
@@ -7,6 +7,23 @@ 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
+
23
+ ## 1.4.3 - 2024-09-04
24
+
25
+ * [JS/TS] Fixed Decimal comparisons (#3884) (by @ncave)
26
+
10
27
  ## 1.4.2 - 2024-06-13
11
28
 
12
29
  ### Fixed
package/Date.js CHANGED
@@ -490,7 +490,6 @@ export function parseRaw(input) {
490
490
  let offset = null;
491
491
  if (isNaN(date.getTime())) {
492
492
  // Try to check strings JS Date cannot parse (see #1045, #1422)
493
- // tslint:disable-next-line:max-line-length
494
493
  const m = /^\s*(\d+[^\w\s:]\d+[^\w\s:]\d+)?\s*(\d+:\d+(?::\d+(?:\.\d+)?)?)?\s*([AaPp][Mm])?\s*(Z|[+-]([01]?\d):?([0-5]?\d)?)?\s*$/.exec(input);
495
494
  if (m != null) {
496
495
  let baseDate;
package/Decimal.js CHANGED
@@ -34,13 +34,13 @@ export function equals(x, y) {
34
34
  return !x.cmp(y);
35
35
  }
36
36
  export function abs(x) { return x.abs(); }
37
- export function sign(x) { return x < get_Zero ? -1 : x > get_Zero ? 1 : 0; }
38
- export function max(x, y) { return x > y ? x : y; }
39
- export function min(x, y) { return x < y ? x : y; }
40
- export function maxMagnitude(x, y) { return abs(x) > abs(y) ? x : y; }
41
- export function minMagnitude(x, y) { return abs(x) < abs(y) ? x : y; }
37
+ export function sign(x) { return x.lt(get_Zero) ? -1 : x.gt(get_Zero) ? 1 : 0; }
38
+ export function max(x, y) { return x.gt(y) ? x : y; }
39
+ export function min(x, y) { return x.lt(y) ? x : y; }
40
+ export function maxMagnitude(x, y) { return abs(x).gt(abs(y)) ? x : y; }
41
+ export function minMagnitude(x, y) { return abs(x).lt(abs(y)) ? x : y; }
42
42
  export function clamp(x, min, max) {
43
- return x < min ? min : x > max ? max : x;
43
+ return x.lt(min) ? min : x.gt(max) ? max : x;
44
44
  }
45
45
  export function round(x, digits = 0) {
46
46
  return x.round(digits, 2 /* ROUND_HALF_EVEN */);
package/Reflection.d.ts CHANGED
@@ -78,7 +78,7 @@ export declare function namespace(t: TypeInfo): string;
78
78
  export declare function isArray(t: TypeInfo): boolean;
79
79
  export declare function getElementType(t: TypeInfo): TypeInfo | undefined;
80
80
  export declare function isGenericType(t: TypeInfo): boolean;
81
- export declare function isGenericParameter(t: TypeInfo): boolean;
81
+ export declare function isGenericParameter(t: TypeInfo): t is GenericParameter;
82
82
  export declare function isEnum(t: TypeInfo): boolean;
83
83
  export declare function isSubclassOf(t1: TypeInfo, t2: TypeInfo): boolean;
84
84
  export declare function isInstanceOfType(t: TypeInfo, o: any): boolean;
package/RegExp.js CHANGED
@@ -41,7 +41,6 @@ export function matches(reg, input, startAt = 0) {
41
41
  const matches = [];
42
42
  let m;
43
43
  let lastMatchIndex = -1;
44
- // tslint:disable-next-line:no-conditional-assignment
45
44
  while ((m = reg.exec(input)) != null) {
46
45
  // It can happen even global regex get stuck, see #2845
47
46
  if (m.index === lastMatchIndex) {
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
- ? s.strs.reduce((acc, newPart, index) => acc + `{${String(index - 1) + s.fmts[index - 1]}}` + newPart)
542
- : s.strs.reduce((acc, newPart, index) => acc + `{${index - 1}}` + newPart);
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/Types.d.ts CHANGED
@@ -38,8 +38,8 @@ export declare class Exception {
38
38
  message?: string | undefined;
39
39
  constructor(message?: string | undefined);
40
40
  }
41
- export declare function isException(x: any): boolean;
42
- export declare function isPromise(x: any): boolean;
41
+ export declare function isException(x: any): x is Error | Exception;
42
+ export declare function isPromise(x: any): x is Promise<any>;
43
43
  export declare function ensureErrorOrException(e: any): any;
44
44
  export declare abstract class FSharpException extends Exception implements IEquatable<FSharpException>, IComparable<FSharpException> {
45
45
  toJSON(): any;
package/Uri.d.ts CHANGED
@@ -22,6 +22,8 @@ export declare class Uri {
22
22
  get host(): string;
23
23
  get absolutePath(): string;
24
24
  get query(): string;
25
+ get isDefaultPort(): boolean;
26
+ get port(): number;
25
27
  get pathAndQuery(): string;
26
28
  get fragment(): string;
27
29
  get originalString(): string;
package/Uri.js CHANGED
@@ -9,7 +9,6 @@ export class Uri {
9
9
  }
10
10
  static isAbsoluteUri(uri) {
11
11
  try {
12
- // tslint:disable-next-line no-unused-expression
13
12
  new URL(uri);
14
13
  return true;
15
14
  }
@@ -120,7 +119,13 @@ export class Uri {
120
119
  return protocol.slice(0, protocol.length - 1);
121
120
  }
122
121
  get host() {
123
- return this.asUrl().host;
122
+ const host = this.asUrl().host;
123
+ if (host.includes(":")) {
124
+ return host.split(":")[0];
125
+ }
126
+ else {
127
+ return host;
128
+ }
124
129
  }
125
130
  get absolutePath() {
126
131
  return this.asUrl().pathname;
@@ -128,6 +133,18 @@ export class Uri {
128
133
  get query() {
129
134
  return this.asUrl().search;
130
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
+ }
131
148
  get pathAndQuery() {
132
149
  const url = this.asUrl();
133
150
  return url.pathname + url.search;
package/Util.d.ts CHANGED
@@ -65,7 +65,7 @@ export declare class Enumerable<T> implements IEnumerable<T> {
65
65
  GetEnumerator(): IEnumerator<T>;
66
66
  "System.Collections.IEnumerable.GetEnumerator"(): IEnumerator<any>;
67
67
  [Symbol.iterator](): this;
68
- next(): IteratorResult<T, any>;
68
+ next(): IteratorResult<T>;
69
69
  }
70
70
  export declare class Enumerator<T> implements IEnumerator<T> {
71
71
  private iter;
@@ -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: object) => void): object;
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/Util.js CHANGED
@@ -1,4 +1,3 @@
1
- // tslint:disable:ban-types
2
1
  export function isArrayLike(x) {
3
2
  return Array.isArray(x) || ArrayBuffer.isView(x);
4
3
  }
package/lib/big.js CHANGED
@@ -1,5 +1,4 @@
1
1
  // Adapted from https://github.com/MikeMcl/big.js/blob/0f94dc9110d55c4f324a47ba6a2e832ce23ac589/big.mjs
2
- /* tslint:disable */
3
2
  var P = {};
4
3
  /*
5
4
  * big.js v6.0.3
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "private": false,
4
4
  "type": "module",
5
5
  "name": "@fable-org/fable-library-js",
6
- "version": "1.4.2",
6
+ "version": "1.5.0",
7
7
  "description": "Core library used by F# projects compiled with fable.io",
8
8
  "author": "Fable Contributors",
9
9
  "license": "MIT",