@fable-org/fable-library-ts 2.0.0-beta.2 → 2.0.0-beta.4

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/System.Text.ts CHANGED
@@ -1,203 +1,204 @@
1
- import { replace, format, replicate, substring, isNullOrEmpty, join } from "./String.js";
2
- import { float64, int32 } from "./Int32.js";
3
- import { class_type, TypeInfo } from "./Reflection.js";
4
- import { clear, int32ToString } from "./Util.js";
5
- import { toString } from "./Types.js";
6
-
7
- export class StringBuilder {
8
- readonly buf: string[];
9
- constructor(value: string, capacity: int32) {
10
- this.buf = [];
11
- if (!isNullOrEmpty(value)) {
12
- void (this.buf.push(value));
13
- }
14
- }
15
- toString(): string {
16
- const _: StringBuilder = this;
17
- return join("", _.buf);
18
- }
19
- }
20
-
21
- export function StringBuilder_$reflection(): TypeInfo {
22
- return class_type("System.Text.StringBuilder", undefined, StringBuilder);
23
- }
24
-
25
- export function StringBuilder_$ctor_Z18115A39(value: string, capacity: int32): StringBuilder {
26
- return new StringBuilder(value, capacity);
27
- }
28
-
29
- export function StringBuilder_$ctor_Z524259A4(capacity: int32): StringBuilder {
30
- return StringBuilder_$ctor_Z18115A39("", capacity);
31
- }
32
-
33
- export function StringBuilder_$ctor_Z721C83C5(value: string): StringBuilder {
34
- return StringBuilder_$ctor_Z18115A39(value, 16);
35
- }
36
-
37
- export function StringBuilder_$ctor(): StringBuilder {
38
- return StringBuilder_$ctor_Z18115A39("", 16);
39
- }
40
-
41
- export function StringBuilder__Append_Z721C83C5(x: StringBuilder, s: string): StringBuilder {
42
- void (x.buf.push(s));
43
- return x;
44
- }
45
-
46
- export function StringBuilder__Append_487EF8FB(x: StringBuilder, s: string, startIndex: int32, count: int32): StringBuilder {
47
- void (x.buf.push(substring(s, startIndex, count)));
48
- return x;
49
- }
50
-
51
- export function StringBuilder__Append_244C7CD6(x: StringBuilder, c: string): StringBuilder {
52
- void (x.buf.push(c));
53
- return x;
54
- }
55
-
56
- export function StringBuilder__Append_61B1CA(x: StringBuilder, c: string, repeatCount: int32): StringBuilder {
57
- const s: string = replicate(repeatCount, c);
58
- void (x.buf.push(s));
59
- return x;
60
- }
61
-
62
- export function StringBuilder__Append_Z524259A4(x: StringBuilder, o: int32): StringBuilder {
63
- void (x.buf.push(int32ToString(o)));
64
- return x;
65
- }
66
-
67
- export function StringBuilder__Append_5E38073B(x: StringBuilder, o: float64): StringBuilder {
68
- void (x.buf.push(o.toString()));
69
- return x;
70
- }
71
-
72
- export function StringBuilder__Append_Z1FBCCD16(x: StringBuilder, o: boolean): StringBuilder {
73
- void (x.buf.push(toString(o)));
74
- return x;
75
- }
76
-
77
- export function StringBuilder__Append_4E60E31B(x: StringBuilder, o: any): StringBuilder {
78
- void (x.buf.push(toString(o)));
79
- return x;
80
- }
81
-
82
- export function StringBuilder__Append_Z372E4D23(x: StringBuilder, cs: string[]): StringBuilder {
83
- void (x.buf.push(cs.join('')));
84
- return x;
85
- }
86
-
87
- export function StringBuilder__Append_43A65C09(x: StringBuilder, s: StringBuilder): StringBuilder {
88
- void (x.buf.push(toString(s)));
89
- return x;
90
- }
91
-
92
- export function StringBuilder__AppendFormat_433E080(x: StringBuilder, fmt: string, o: any): StringBuilder {
93
- void (x.buf.push(format(fmt, o)));
94
- return x;
95
- }
96
-
97
- export function StringBuilder__AppendFormat_Z3B30EC65(x: StringBuilder, fmt: string, o1: any, o2: any): StringBuilder {
98
- void (x.buf.push(format(fmt, o1, o2)));
99
- return x;
100
- }
101
-
102
- export function StringBuilder__AppendFormat_10D165E0(x: StringBuilder, fmt: string, o1: any, o2: any, o3: any): StringBuilder {
103
- void (x.buf.push(format(fmt, o1, o2, o3)));
104
- return x;
105
- }
106
-
107
- export function StringBuilder__AppendFormat_Z17053F5(x: StringBuilder, fmt: string, arr: any[]): StringBuilder {
108
- void (x.buf.push(format(fmt, ...arr)));
109
- return x;
110
- }
111
-
112
- export function StringBuilder__AppendFormat_Z696D8D1B(x: StringBuilder, provider: any, fmt: string, o: any): StringBuilder {
113
- void (x.buf.push(format(provider, fmt, o)));
114
- return x;
115
- }
116
-
117
- export function StringBuilder__AppendFormat_26802C9E(x: StringBuilder, provider: any, fmt: string, o1: any, o2: any): StringBuilder {
118
- void (x.buf.push(format(provider, fmt, o1, o2)));
119
- return x;
120
- }
121
-
122
- export function StringBuilder__AppendFormat_Z471ADCBB(x: StringBuilder, provider: any, fmt: string, o1: any, o2: any, o3: any): StringBuilder {
123
- void (x.buf.push(format(provider, fmt, o1, o2, o3)));
124
- return x;
125
- }
126
-
127
- export function StringBuilder__AppendFormat_6C2E3E6E(x: StringBuilder, provider: any, fmt: string, arr: any[]): StringBuilder {
128
- void (x.buf.push(format(provider, fmt, ...arr)));
129
- return x;
130
- }
131
-
132
- export function StringBuilder__AppendLine(x: StringBuilder): StringBuilder {
133
- void (x.buf.push("\n"));
134
- return x;
135
- }
136
-
137
- export function StringBuilder__AppendLine_Z721C83C5(x: StringBuilder, s: string): StringBuilder {
138
- void (x.buf.push(s));
139
- void (x.buf.push("\n"));
140
- return x;
141
- }
142
-
143
- export function StringBuilder__Clear(x: StringBuilder): StringBuilder {
144
- clear(x.buf);
145
- return x;
146
- }
147
-
148
- export function StringBuilder__get_Chars_Z524259A4(x: StringBuilder, index: int32): string {
149
- let len = 0;
150
- let i = -1;
151
- while (((i + 1) < x.buf.length) && (len < index)) {
152
- i = ((i + 1) | 0);
153
- len = ((len + x.buf[i].length) | 0);
154
- }
155
- if (((index < 0) ? true : (i < 0)) ? true : (i >= x.buf.length)) {
156
- throw new Error("Index was outside the bounds of the array");
157
- }
158
- else {
159
- const pos: int32 = ((len - index) - 1) | 0;
160
- return x.buf[i][pos];
161
- }
162
- }
163
-
164
- export function StringBuilder__set_Chars_413E0D0A(x: StringBuilder, index: int32, value: string): void {
165
- let len = 0;
166
- let i = -1;
167
- while (((i + 1) < x.buf.length) && (len < index)) {
168
- i = ((i + 1) | 0);
169
- len = ((len + x.buf[i].length) | 0);
170
- }
171
- if (((index < 0) ? true : (i < 0)) ? true : (i >= x.buf.length)) {
172
- throw new Error("Index was outside the bounds of the array");
173
- }
174
- else {
175
- const pos: int32 = ((len - index) - 1) | 0;
176
- x.buf[i] = ((x.buf[i].slice(0, (pos - 1) + 1) + value) + x.buf[i].slice(pos + 1, x.buf[i].length));
177
- }
178
- }
179
-
180
- export function StringBuilder__Replace_Z766F94C0(x: StringBuilder, oldValue: string, newValue: string): StringBuilder {
181
- for (let i: int32 = x.buf.length - 1; i >= 0; i--) {
182
- x.buf[i] = replace(x.buf[i], oldValue, newValue);
183
- }
184
- return x;
185
- }
186
-
187
- export function StringBuilder__Replace_Z384F8060(x: StringBuilder, oldValue: string, newValue: string): StringBuilder {
188
- const str: string = replace(toString(x), oldValue, newValue);
189
- return StringBuilder__Append_Z721C83C5(StringBuilder__Clear(x), str);
190
- }
191
-
192
- export function StringBuilder__get_Length(x: StringBuilder): int32 {
193
- let len = 0;
194
- for (let i: int32 = x.buf.length - 1; i >= 0; i--) {
195
- len = ((len + x.buf[i].length) | 0);
196
- }
197
- return len | 0;
198
- }
199
-
200
- export function StringBuilder__ToString_Z37302880(x: StringBuilder, firstIndex: int32, length: int32): string {
201
- return substring(toString(x), firstIndex, length);
202
- }
203
-
1
+
2
+ import { replace, format, replicate, substring, isNullOrEmpty, join } from "./String.js";
3
+ import { float64, int32 } from "./Int32.js";
4
+ import { class_type, TypeInfo } from "./Reflection.js";
5
+ import { toString } from "./Types.js";
6
+ import { clear, int32ToString, Nullable } from "./Util.js";
7
+
8
+ export class StringBuilder {
9
+ readonly buf: string[];
10
+ constructor(value: string, capacity: int32) {
11
+ this.buf = [];
12
+ if (!isNullOrEmpty(value)) {
13
+ void (this.buf.push(value));
14
+ }
15
+ }
16
+ toString(): string {
17
+ const _: StringBuilder = this;
18
+ return join("", _.buf);
19
+ }
20
+ }
21
+
22
+ export function StringBuilder_$reflection(): TypeInfo {
23
+ return class_type("System.Text.StringBuilder", undefined, StringBuilder);
24
+ }
25
+
26
+ export function StringBuilder_$ctor_Z18115A39(value: string, capacity: int32): StringBuilder {
27
+ return new StringBuilder(value, capacity);
28
+ }
29
+
30
+ export function StringBuilder_$ctor_Z524259A4(capacity: int32): StringBuilder {
31
+ return StringBuilder_$ctor_Z18115A39("", capacity);
32
+ }
33
+
34
+ export function StringBuilder_$ctor_Z721C83C5(value: string): StringBuilder {
35
+ return StringBuilder_$ctor_Z18115A39(value, 16);
36
+ }
37
+
38
+ export function StringBuilder_$ctor(): StringBuilder {
39
+ return StringBuilder_$ctor_Z18115A39("", 16);
40
+ }
41
+
42
+ export function StringBuilder__Append_Z721C83C5(x: StringBuilder, s: Nullable<string>): StringBuilder {
43
+ void (x.buf.push(toString(s)));
44
+ return x;
45
+ }
46
+
47
+ export function StringBuilder__Append_487EF8FB(x: StringBuilder, s: Nullable<string>, startIndex: int32, count: int32): StringBuilder {
48
+ void (x.buf.push(substring(toString(s), startIndex, count)));
49
+ return x;
50
+ }
51
+
52
+ export function StringBuilder__Append_244C7CD6(x: StringBuilder, c: string): StringBuilder {
53
+ void (x.buf.push(c));
54
+ return x;
55
+ }
56
+
57
+ export function StringBuilder__Append_61B1CA(x: StringBuilder, c: string, repeatCount: int32): StringBuilder {
58
+ const s: string = replicate(repeatCount, c);
59
+ void (x.buf.push(s));
60
+ return x;
61
+ }
62
+
63
+ export function StringBuilder__Append_Z524259A4(x: StringBuilder, o: int32): StringBuilder {
64
+ void (x.buf.push(int32ToString(o)));
65
+ return x;
66
+ }
67
+
68
+ export function StringBuilder__Append_5E38073B(x: StringBuilder, o: float64): StringBuilder {
69
+ void (x.buf.push(o.toString()));
70
+ return x;
71
+ }
72
+
73
+ export function StringBuilder__Append_Z1FBCCD16(x: StringBuilder, o: boolean): StringBuilder {
74
+ void (x.buf.push(toString(o)));
75
+ return x;
76
+ }
77
+
78
+ export function StringBuilder__Append_4E60E31B(x: StringBuilder, o: any): StringBuilder {
79
+ void (x.buf.push(toString(o)));
80
+ return x;
81
+ }
82
+
83
+ export function StringBuilder__Append_Z372E4D23(x: StringBuilder, cs: string[]): StringBuilder {
84
+ void (x.buf.push(cs.join('')));
85
+ return x;
86
+ }
87
+
88
+ export function StringBuilder__Append_43A65C09(x: StringBuilder, s: StringBuilder): StringBuilder {
89
+ void (x.buf.push(s.toString()));
90
+ return x;
91
+ }
92
+
93
+ export function StringBuilder__AppendFormat_433E080(x: StringBuilder, fmt: string, o: any): StringBuilder {
94
+ void (x.buf.push(format(fmt, o)));
95
+ return x;
96
+ }
97
+
98
+ export function StringBuilder__AppendFormat_Z3B30EC65(x: StringBuilder, fmt: string, o1: any, o2: any): StringBuilder {
99
+ void (x.buf.push(format(fmt, o1, o2)));
100
+ return x;
101
+ }
102
+
103
+ export function StringBuilder__AppendFormat_10D165E0(x: StringBuilder, fmt: string, o1: any, o2: any, o3: any): StringBuilder {
104
+ void (x.buf.push(format(fmt, o1, o2, o3)));
105
+ return x;
106
+ }
107
+
108
+ export function StringBuilder__AppendFormat_Z17053F5(x: StringBuilder, fmt: string, arr: any[]): StringBuilder {
109
+ void (x.buf.push(format(fmt, ...arr)));
110
+ return x;
111
+ }
112
+
113
+ export function StringBuilder__AppendFormat_Z696D8D1B(x: StringBuilder, provider: any, fmt: string, o: any): StringBuilder {
114
+ void (x.buf.push(format(provider, fmt, o)));
115
+ return x;
116
+ }
117
+
118
+ export function StringBuilder__AppendFormat_26802C9E(x: StringBuilder, provider: any, fmt: string, o1: any, o2: any): StringBuilder {
119
+ void (x.buf.push(format(provider, fmt, o1, o2)));
120
+ return x;
121
+ }
122
+
123
+ export function StringBuilder__AppendFormat_Z471ADCBB(x: StringBuilder, provider: any, fmt: string, o1: any, o2: any, o3: any): StringBuilder {
124
+ void (x.buf.push(format(provider, fmt, o1, o2, o3)));
125
+ return x;
126
+ }
127
+
128
+ export function StringBuilder__AppendFormat_6C2E3E6E(x: StringBuilder, provider: any, fmt: string, arr: any[]): StringBuilder {
129
+ void (x.buf.push(format(provider, fmt, ...arr)));
130
+ return x;
131
+ }
132
+
133
+ export function StringBuilder__AppendLine(x: StringBuilder): StringBuilder {
134
+ void (x.buf.push("\n"));
135
+ return x;
136
+ }
137
+
138
+ export function StringBuilder__AppendLine_Z721C83C5(x: StringBuilder, s: string): StringBuilder {
139
+ void (x.buf.push(s));
140
+ void (x.buf.push("\n"));
141
+ return x;
142
+ }
143
+
144
+ export function StringBuilder__Clear(x: StringBuilder): StringBuilder {
145
+ clear(x.buf);
146
+ return x;
147
+ }
148
+
149
+ export function StringBuilder__get_Chars_Z524259A4(x: StringBuilder, index: int32): string {
150
+ let len = 0;
151
+ let i = -1;
152
+ while (((i + 1) < x.buf.length) && (len < index)) {
153
+ i = ((i + 1) | 0);
154
+ len = ((len + x.buf[i].length) | 0);
155
+ }
156
+ if (((index < 0) ? true : (i < 0)) ? true : (i >= x.buf.length)) {
157
+ throw new Error("Index was outside the bounds of the array");
158
+ }
159
+ else {
160
+ const pos: int32 = ((len - index) - 1) | 0;
161
+ return x.buf[i][pos];
162
+ }
163
+ }
164
+
165
+ export function StringBuilder__set_Chars_413E0D0A(x: StringBuilder, index: int32, value: string): void {
166
+ let len = 0;
167
+ let i = -1;
168
+ while (((i + 1) < x.buf.length) && (len < index)) {
169
+ i = ((i + 1) | 0);
170
+ len = ((len + x.buf[i].length) | 0);
171
+ }
172
+ if (((index < 0) ? true : (i < 0)) ? true : (i >= x.buf.length)) {
173
+ throw new Error("Index was outside the bounds of the array");
174
+ }
175
+ else {
176
+ const pos: int32 = ((len - index) - 1) | 0;
177
+ x.buf[i] = ((x.buf[i].slice(0, (pos - 1) + 1) + value) + x.buf[i].slice(pos + 1, x.buf[i].length));
178
+ }
179
+ }
180
+
181
+ export function StringBuilder__Replace_Z766F94C0(x: StringBuilder, oldValue: string, newValue: string): StringBuilder {
182
+ for (let i: int32 = x.buf.length - 1; i >= 0; i--) {
183
+ x.buf[i] = replace(x.buf[i], oldValue, newValue);
184
+ }
185
+ return x;
186
+ }
187
+
188
+ export function StringBuilder__Replace_Z384F8060(x: StringBuilder, oldValue: string, newValue: string): StringBuilder {
189
+ const str: string = replace(x.toString(), oldValue, newValue);
190
+ return StringBuilder__Append_Z721C83C5(StringBuilder__Clear(x), str);
191
+ }
192
+
193
+ export function StringBuilder__get_Length(x: StringBuilder): int32 {
194
+ let len = 0;
195
+ for (let i: int32 = x.buf.length - 1; i >= 0; i--) {
196
+ len = ((len + x.buf[i].length) | 0);
197
+ }
198
+ return len | 0;
199
+ }
200
+
201
+ export function StringBuilder__ToString_Z37302880(x: StringBuilder, firstIndex: int32, length: int32): string {
202
+ return substring(x.toString(), firstIndex, length);
203
+ }
204
+
package/Util.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export type Nullable<T> = T | null | undefined;
2
+
1
3
  // Don't change, this corresponds to DateTime.Kind enum values in .NET
2
4
  export const enum DateKind {
3
5
  Unspecified = 0,
@@ -30,11 +32,11 @@ export interface IDisposable {
30
32
  }
31
33
 
32
34
  export interface IComparer<T> {
33
- Compare(x: T, y: T): number;
35
+ Compare(x: Nullable<T>, y: Nullable<T>): number;
34
36
  }
35
37
 
36
38
  export interface IEqualityComparer<T> {
37
- Equals(x: T, y: T): boolean;
39
+ Equals(x: Nullable<T>, y: Nullable<T>): boolean;
38
40
  GetHashCode(x: T): number;
39
41
  }
40
42
 
@@ -426,7 +428,7 @@ export function safeHash<T>(x: T): number {
426
428
  return identityHash(x);
427
429
  }
428
430
 
429
- export function equalArraysWith<T>(x: ArrayLike<T>, y: ArrayLike<T>, eq: (x: T, y: T) => boolean): boolean {
431
+ export function equalArraysWith<T>(x: Nullable<ArrayLike<T>>, y: Nullable<ArrayLike<T>>, eq: (x: T, y: T) => boolean): boolean {
430
432
  if (x == null) { return y == null; }
431
433
  if (y == null) { return false; }
432
434
  if (x.length !== y.length) { return false; }
@@ -436,7 +438,7 @@ export function equalArraysWith<T>(x: ArrayLike<T>, y: ArrayLike<T>, eq: (x: T,
436
438
  return true;
437
439
  }
438
440
 
439
- export function equalArrays<T>(x: ArrayLike<T>, y: ArrayLike<T>): boolean {
441
+ export function equalArrays<T>(x: Nullable<ArrayLike<T>>, y: Nullable<ArrayLike<T>>): boolean {
440
442
  return equalArraysWith(x, y, equals);
441
443
  }
442
444
 
@@ -456,10 +458,16 @@ function equalObjects(x: { [k: string]: any }, y: { [k: string]: any }): boolean
456
458
  return true;
457
459
  }
458
460
 
459
- export function physicalEquality<T>(x: T, y: T): boolean {
461
+ export function physicalEquals<T>(x: T, y: T): boolean {
460
462
  return x === y;
461
463
  }
462
464
 
465
+ export function nullableEquals<T>(x: Nullable<T>, y: Nullable<T>): boolean {
466
+ if (x == null) { return y == null; }
467
+ if (y == null) { return false; }
468
+ return equals(x, y);
469
+ }
470
+
463
471
  export function equals<T>(x: T, y: T): boolean {
464
472
  if (x === y) {
465
473
  return true;
package/package.json CHANGED
@@ -1,24 +1,24 @@
1
1
  {
2
- "sideEffects": false,
3
- "private": false,
4
- "type": "module",
5
- "name": "@fable-org/fable-library-ts",
6
- "version": "2.0.0-beta.2",
7
- "description": "Core library used by F# projects compiled with fable.io",
8
- "author": "Fable Contributors",
9
- "license": "MIT",
10
- "repository": {
11
- "type": "git",
12
- "url": "git+https://github.com/fable-compiler/Fable.git"
13
- },
14
- "bugs": {
15
- "url": "https://github.com/fable-compiler/Fable/issues"
16
- },
17
- "homepage": "https://fable.io",
18
- "keywords": [
19
- "fable",
20
- "fable-compiler",
21
- "fsharp",
22
- "F#"
23
- ]
2
+ "sideEffects": false,
3
+ "private": false,
4
+ "type": "module",
5
+ "name": "@fable-org/fable-library-ts",
6
+ "version": "2.0.0-beta.4",
7
+ "description": "Core library used by F# projects compiled with fable.io",
8
+ "author": "Fable Contributors",
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/fable-compiler/Fable.git"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/fable-compiler/Fable/issues"
16
+ },
17
+ "homepage": "https://fable.io",
18
+ "keywords": [
19
+ "fable",
20
+ "fable-compiler",
21
+ "fsharp",
22
+ "F#"
23
+ ]
24
24
  }