@byloth/core 2.0.0-rc.2 → 2.0.0-rc.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.
@@ -7,7 +7,7 @@ export class FileException extends Exception
7
7
  super(message, cause, name);
8
8
  }
9
9
 
10
- public get [Symbol.toStringTag]() { return "FileException"; }
10
+ public readonly [Symbol.toStringTag]: string = "FileException";
11
11
  }
12
12
  export class FileExistsException extends FileException
13
13
  {
@@ -16,7 +16,7 @@ export class FileExistsException extends FileException
16
16
  super(message, cause, name);
17
17
  }
18
18
 
19
- public get [Symbol.toStringTag]() { return "FileExistsException"; }
19
+ public readonly [Symbol.toStringTag]: string = "FileExistsException";
20
20
  }
21
21
  export class FileNotFoundException extends FileException
22
22
  {
@@ -25,7 +25,7 @@ export class FileNotFoundException extends FileException
25
25
  super(message, cause, name);
26
26
  }
27
27
 
28
- public get [Symbol.toStringTag]() { return "FileNotFoundException"; }
28
+ public readonly [Symbol.toStringTag]: string = "FileNotFoundException";
29
29
  }
30
30
 
31
31
  export class KeyException extends Exception
@@ -35,7 +35,7 @@ export class KeyException extends Exception
35
35
  super(message, cause, name);
36
36
  }
37
37
 
38
- public get [Symbol.toStringTag]() { return "KeyException"; }
38
+ public readonly [Symbol.toStringTag]: string = "KeyException";
39
39
  }
40
40
  export class NetworkException extends Exception
41
41
  {
@@ -44,7 +44,7 @@ export class NetworkException extends Exception
44
44
  super(message, cause, name);
45
45
  }
46
46
 
47
- public get [Symbol.toStringTag]() { return "NetworkException"; }
47
+ public readonly [Symbol.toStringTag]: string = "NetworkException";
48
48
  }
49
49
  export class PermissionException extends Exception
50
50
  {
@@ -53,7 +53,7 @@ export class PermissionException extends Exception
53
53
  super(message, cause, name);
54
54
  }
55
55
 
56
- public get [Symbol.toStringTag]() { return "PermissionException"; }
56
+ public readonly [Symbol.toStringTag]: string = "PermissionException";
57
57
  }
58
58
  export class ReferenceException extends Exception
59
59
  {
@@ -62,7 +62,7 @@ export class ReferenceException extends Exception
62
62
  super(message, cause, name);
63
63
  }
64
64
 
65
- public get [Symbol.toStringTag]() { return "ReferenceException"; }
65
+ public readonly [Symbol.toStringTag]: string = "ReferenceException";
66
66
  }
67
67
 
68
68
  export class RuntimeException extends Exception
@@ -72,7 +72,7 @@ export class RuntimeException extends Exception
72
72
  super(message, cause, name);
73
73
  }
74
74
 
75
- public get [Symbol.toStringTag]() { return "RuntimeException"; }
75
+ public readonly [Symbol.toStringTag]: string = "RuntimeException";
76
76
  }
77
77
  export class EnvironmentException extends RuntimeException
78
78
  {
@@ -81,7 +81,7 @@ export class EnvironmentException extends RuntimeException
81
81
  super(message, cause, name);
82
82
  }
83
83
 
84
- public get [Symbol.toStringTag]() { return "EnvironmentException"; }
84
+ public readonly [Symbol.toStringTag]: string = "EnvironmentException";
85
85
  }
86
86
 
87
87
  export class TimeoutException extends Exception
@@ -91,7 +91,7 @@ export class TimeoutException extends Exception
91
91
  super(message, cause, name);
92
92
  }
93
93
 
94
- public get [Symbol.toStringTag]() { return "TimeoutException"; }
94
+ public readonly [Symbol.toStringTag]: string = "TimeoutException";
95
95
  }
96
96
  export class TypeException extends Exception
97
97
  {
@@ -100,7 +100,7 @@ export class TypeException extends Exception
100
100
  super(message, cause, name);
101
101
  }
102
102
 
103
- public get [Symbol.toStringTag]() { return "TypeException"; }
103
+ public readonly [Symbol.toStringTag]: string = "TypeException";
104
104
  }
105
105
 
106
106
  export class ValueException extends Exception
@@ -110,7 +110,7 @@ export class ValueException extends Exception
110
110
  super(message, cause, name);
111
111
  }
112
112
 
113
- public get [Symbol.toStringTag]() { return "ValueException"; }
113
+ public readonly [Symbol.toStringTag]: string = "ValueException";
114
114
  }
115
115
  export class RangeException extends ValueException
116
116
  {
@@ -119,7 +119,7 @@ export class RangeException extends ValueException
119
119
  super(message, cause, name);
120
120
  }
121
121
 
122
- public get [Symbol.toStringTag]() { return "RangeException"; }
122
+ public readonly [Symbol.toStringTag]: string = "RangeException";
123
123
  }
124
124
 
125
125
  export { Exception };
@@ -80,4 +80,6 @@ export default class GameLoop
80
80
  this._handle = undefined;
81
81
  this._isRunning = false;
82
82
  }
83
+
84
+ public readonly [Symbol.toStringTag]: string = "GameLoop";
83
85
  }
@@ -1,6 +1,4 @@
1
1
  export {
2
- Aggregator,
3
- AsyncAggregator,
4
2
  AggregatedIterator,
5
3
  AggregatedAsyncIterator,
6
4
  ReducedIterator
@@ -1,11 +1,14 @@
1
+ import AggregatedAsyncIterator from "../aggregators/aggregated-async-iterator.js";
1
2
  import { ValueException } from "../exceptions/index.js";
2
3
 
3
4
  import type {
4
- AsyncGeneratorFunction,
5
5
  GeneratorFunction,
6
+ AsyncGeneratorFunction,
7
+ MaybeAsyncGeneratorFunction,
6
8
  MaybeAsyncIteratee,
7
9
  MaybeAsyncReducer,
8
- MaybeAsyncIterLike,
10
+ MaybeAsyncIterable,
11
+ MaybeAsyncIteratorLike,
9
12
  MaybeAsyncTypeGuardIteratee
10
13
 
11
14
  } from "./types.js";
@@ -23,8 +26,8 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
23
26
  public constructor(iterator: AsyncIterator<T, R, N>);
24
27
  public constructor(generatorFn: GeneratorFunction<T, R, N>);
25
28
  public constructor(generatorFn: AsyncGeneratorFunction<T, R, N>);
26
- public constructor(argument: MaybeAsyncIterLike<T, R, N>);
27
- public constructor(argument: MaybeAsyncIterLike<T, R, N>)
29
+ public constructor(argument: MaybeAsyncIteratorLike<T, R, N> | MaybeAsyncGeneratorFunction<T, R, N>);
30
+ public constructor(argument: MaybeAsyncIteratorLike<T, R, N> | MaybeAsyncGeneratorFunction<T, R, N>)
28
31
  {
29
32
  if (argument instanceof Function)
30
33
  {
@@ -94,13 +97,12 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
94
97
  {
95
98
  let index = 0;
96
99
 
97
- // eslint-disable-next-line no-constant-condition
98
100
  while (true)
99
101
  {
100
102
  const result = await this._iterator.next();
101
103
 
102
104
  if (result.done) { return true; }
103
- if (!(predicate(result.value, index))) { return false; }
105
+ if (!(await predicate(result.value, index))) { return false; }
104
106
 
105
107
  index += 1;
106
108
  }
@@ -109,13 +111,12 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
109
111
  {
110
112
  let index = 0;
111
113
 
112
- // eslint-disable-next-line no-constant-condition
113
114
  while (true)
114
115
  {
115
116
  const result = await this._iterator.next();
116
117
 
117
118
  if (result.done) { return false; }
118
- if (predicate(result.value, index)) { return true; }
119
+ if (await predicate(result.value, index)) { return true; }
119
120
 
120
121
  index += 1;
121
122
  }
@@ -136,7 +137,7 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
136
137
  const result = await iterator.next();
137
138
 
138
139
  if (result.done) { return result.value; }
139
- if (predicate(result.value, index)) { yield result.value; }
140
+ if (await predicate(result.value, index)) { yield result.value; }
140
141
 
141
142
  index += 1;
142
143
  }
@@ -155,7 +156,7 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
155
156
  const result = await iterator.next();
156
157
  if (result.done) { return result.value; }
157
158
 
158
- yield iteratee(result.value, index);
159
+ yield await iteratee(result.value, index);
159
160
 
160
161
  index += 1;
161
162
  }
@@ -176,7 +177,6 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
176
177
  index += 1;
177
178
  }
178
179
 
179
- // eslint-disable-next-line no-constant-condition
180
180
  while (true)
181
181
  {
182
182
  const result = await this._iterator.next();
@@ -188,6 +188,93 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
188
188
  }
189
189
  }
190
190
 
191
+ public flatMap<V>(iteratee: MaybeAsyncIteratee<T, MaybeAsyncIterable<V>>): SmartAsyncIterator<V, R>
192
+ {
193
+ const iterator = this._iterator;
194
+
195
+ return new SmartAsyncIterator<V, R>(async function* ()
196
+ {
197
+ let index = 0;
198
+
199
+ while (true)
200
+ {
201
+ const result = await iterator.next();
202
+ if (result.done) { return result.value; }
203
+
204
+ const elements = await iteratee(result.value, index);
205
+
206
+ for await (const element of elements)
207
+ {
208
+ yield element;
209
+ }
210
+
211
+ index += 1;
212
+ }
213
+ });
214
+ }
215
+
216
+ public drop(count: number): SmartAsyncIterator<T, R | undefined>
217
+ {
218
+ const iterator = this._iterator;
219
+
220
+ return new SmartAsyncIterator<T, R | undefined>(async function* ()
221
+ {
222
+ let index = 0;
223
+
224
+ while (index < count)
225
+ {
226
+ const result = await iterator.next();
227
+ if (result.done) { return; }
228
+
229
+ index += 1;
230
+ }
231
+
232
+ while (true)
233
+ {
234
+ const result = await iterator.next();
235
+ if (result.done) { return result.value; }
236
+
237
+ yield result.value;
238
+ }
239
+ });
240
+ }
241
+ public take(limit: number): SmartAsyncIterator<T, R | undefined>
242
+ {
243
+ const iterator = this._iterator;
244
+
245
+ return new SmartAsyncIterator<T, R | undefined>(async function* ()
246
+ {
247
+ let index = 0;
248
+
249
+ while (index < limit)
250
+ {
251
+ const result = await iterator.next();
252
+ if (result.done) { return result.value; }
253
+
254
+ yield result.value;
255
+
256
+ index += 1;
257
+ }
258
+
259
+ return;
260
+ });
261
+ }
262
+
263
+ public async find(predicate: MaybeAsyncIteratee<T, boolean>): Promise<T | undefined>
264
+ {
265
+ let index = 0;
266
+
267
+ while (true)
268
+ {
269
+ const result = await this._iterator.next();
270
+
271
+ if (result.done) { return; }
272
+ if (await predicate(result.value, index)) { return result.value; }
273
+
274
+ index += 1;
275
+ }
276
+ }
277
+
191
278
  public enumerate(): SmartAsyncIterator<[number, T], R>
192
279
  {
193
280
  return this.map((value, index) => [index, value]);
@@ -218,7 +305,6 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
218
305
  {
219
306
  let index = 0;
220
307
 
221
- // eslint-disable-next-line no-constant-condition
222
308
  while (true)
223
309
  {
224
310
  const result = await this._iterator.next();
@@ -231,7 +317,6 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
231
317
  {
232
318
  let index = 0;
233
319
 
234
- // eslint-disable-next-line no-constant-condition
235
320
  while (true)
236
321
  {
237
322
  const result = await this._iterator.next();
@@ -248,21 +333,22 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
248
333
  return this._iterator.next(...values);
249
334
  }
250
335
 
251
- public async toArray(): Promise<T[]>
336
+ public groupBy<K extends PropertyKey>(iteratee: MaybeAsyncIteratee<T, K>): AggregatedAsyncIterator<K, T>
252
337
  {
253
- const elements: T[] = [];
254
-
255
- // eslint-disable-next-line no-constant-condition
256
- while (true)
338
+ return new AggregatedAsyncIterator(this.map(async (element, index) =>
257
339
  {
258
- const result = await this._iterator.next();
259
- if (result.done) { return elements; }
340
+ const key = await iteratee(element, index);
260
341
 
261
- elements.push(result.value);
262
- }
342
+ return [key, element] as [K, T];
343
+ }));
344
+ }
345
+
346
+ public toArray(): Promise<T[]>
347
+ {
348
+ return Array.fromAsync(this as AsyncIterable<T>);
263
349
  }
264
350
 
265
- public get [Symbol.toStringTag]() { return "SmartAsyncIterator"; }
351
+ public readonly [Symbol.toStringTag]: string = "SmartAsyncIterator";
266
352
 
267
353
  public [Symbol.asyncIterator](): SmartAsyncIterator<T, R, N> { return this; }
268
354
  }
@@ -1,6 +1,7 @@
1
+ import AggregatedIterator from "../aggregators/aggregated-iterator.js";
1
2
  import { ValueException } from "../exceptions/index.js";
2
3
 
3
- import type { GeneratorFunction, Iteratee, TypeGuardIteratee, Reducer, IterLike } from "./types.js";
4
+ import type { GeneratorFunction, Iteratee, TypeGuardIteratee, Reducer, IteratorLike } from "./types.js";
4
5
 
5
6
  export default class SmartIterator<T, R = void, N = undefined> implements Iterator<T, R, N>
6
7
  {
@@ -9,11 +10,11 @@ export default class SmartIterator<T, R = void, N = undefined> implements Iterat
9
10
  public return?: (value?: R) => IteratorResult<T, R>;
10
11
  public throw?: (error?: unknown) => IteratorResult<T, R>;
11
12
 
12
- public constructor(iterable: Iterable<T>);
13
+ public constructor(iterable: Iterable<T, R, N>);
13
14
  public constructor(iterator: Iterator<T, R, N>);
14
15
  public constructor(generatorFn: GeneratorFunction<T, R, N>);
15
- public constructor(argument: IterLike<T, R, N>);
16
- public constructor(argument: IterLike<T, R, N>)
16
+ public constructor(argument: IteratorLike<T, R, N> | GeneratorFunction<T, R, N>);
17
+ public constructor(argument: IteratorLike<T, R, N> | GeneratorFunction<T, R, N>)
17
18
  {
18
19
  if (argument instanceof Function)
19
20
  {
@@ -28,15 +29,14 @@ export default class SmartIterator<T, R = void, N = undefined> implements Iterat
28
29
  this._iterator = argument;
29
30
  }
30
31
 
31
- if (this._iterator.return) { this.return = (value?: R) => this._iterator.return!(value); }
32
- if (this._iterator.throw) { this.throw = (error?: unknown) => this._iterator.throw!(error); }
32
+ if (this._iterator.return) { this.return = (value) => this._iterator.return!(value); }
33
+ if (this._iterator.throw) { this.throw = (error) => this._iterator.throw!(error); }
33
34
  }
34
35
 
35
36
  public every(predicate: Iteratee<T, boolean>): boolean
36
37
  {
37
38
  let index = 0;
38
39
 
39
- // eslint-disable-next-line no-constant-condition
40
40
  while (true)
41
41
  {
42
42
  const result = this._iterator.next();
@@ -51,7 +51,6 @@ export default class SmartIterator<T, R = void, N = undefined> implements Iterat
51
51
  {
52
52
  let index = 0;
53
53
 
54
- // eslint-disable-next-line no-constant-condition
55
54
  while (true)
56
55
  {
57
56
  const result = this._iterator.next();
@@ -118,7 +117,6 @@ export default class SmartIterator<T, R = void, N = undefined> implements Iterat
118
117
  index += 1;
119
118
  }
120
119
 
121
- // eslint-disable-next-line no-constant-condition
122
120
  while (true)
123
121
  {
124
122
  const result = this._iterator.next();
@@ -130,6 +128,92 @@ export default class SmartIterator<T, R = void, N = undefined> implements Iterat
130
128
  }
131
129
  }
132
130
 
131
+ public flatMap<V>(iteratee: Iteratee<T, Iterable<V>>): SmartIterator<V, R>
132
+ {
133
+ const iterator = this._iterator;
134
+
135
+ return new SmartIterator<V, R>(function* ()
136
+ {
137
+ let index = 0;
138
+
139
+ while (true)
140
+ {
141
+ const result = iterator.next();
142
+ if (result.done) { return result.value; }
143
+
144
+ const iterable = iteratee(result.value, index);
145
+ for (const value of iterable)
146
+ {
147
+ yield value;
148
+ }
149
+
150
+ index += 1;
151
+ }
152
+ });
153
+ }
154
+
155
+ public drop(count: number): SmartIterator<T, R | undefined>
156
+ {
157
+ const iterator = this._iterator;
158
+
159
+ return new SmartIterator<T, R | undefined>(function* ()
160
+ {
161
+ let index = 0;
162
+ while (index < count)
163
+ {
164
+ const result = iterator.next();
165
+ if (result.done) { return; }
166
+
167
+ index += 1;
168
+ }
169
+
170
+ while (true)
171
+ {
172
+ const result = iterator.next();
173
+ if (result.done) { return result.value; }
174
+
175
+ yield result.value;
176
+ }
177
+ });
178
+ }
179
+ public take(limit: number): SmartIterator<T, R | undefined>
180
+ {
181
+ const iterator = this._iterator;
182
+
183
+ return new SmartIterator<T, R | undefined>(function* ()
184
+ {
185
+ let index = 0;
186
+ while (index < limit)
187
+ {
188
+ const result = iterator.next();
189
+ if (result.done) { return result.value; }
190
+
191
+ yield result.value;
192
+
193
+ index += 1;
194
+ }
195
+
196
+ return;
197
+ });
198
+ }
199
+
200
+ public find(predicate: Iteratee<T, boolean>): T | undefined;
201
+ public find<S extends T>(predicate: TypeGuardIteratee<T, S>): S | undefined;
202
+ public find(predicate: Iteratee<T, boolean>): T | undefined
203
+ {
204
+ let index = 0;
205
+
206
+ while (true)
207
+ {
208
+ const result = this._iterator.next();
209
+
210
+ if (result.done) { return; }
211
+ if (predicate(result.value, index)) { return result.value; }
212
+
213
+ index += 1;
214
+ }
215
+ }
216
+
133
217
  public enumerate(): SmartIterator<[number, T], R>
134
218
  {
135
219
  return this.map((value, index) => [index, value]);
@@ -160,7 +244,6 @@ export default class SmartIterator<T, R = void, N = undefined> implements Iterat
160
244
  {
161
245
  let index = 0;
162
246
 
163
- // eslint-disable-next-line no-constant-condition
164
247
  while (true)
165
248
  {
166
249
  const result = this._iterator.next();
@@ -169,11 +252,11 @@ export default class SmartIterator<T, R = void, N = undefined> implements Iterat
169
252
  index += 1;
170
253
  }
171
254
  }
255
+
172
256
  public forEach(iteratee: Iteratee<T>): void
173
257
  {
174
258
  let index = 0;
175
259
 
176
- // eslint-disable-next-line no-constant-condition
177
260
  while (true)
178
261
  {
179
262
  const result = this._iterator.next();
@@ -190,12 +273,22 @@ export default class SmartIterator<T, R = void, N = undefined> implements Iterat
190
273
  return this._iterator.next(...values);
191
274
  }
192
275
 
276
+ public groupBy<K extends PropertyKey>(iteratee: Iteratee<T, K>): AggregatedIterator<K, T>
277
+ {
278
+ return new AggregatedIterator(this.map((element, index) =>
279
+ {
280
+ const key = iteratee(element, index);
281
+
282
+ return [key, element] as [K, T];
283
+ }));
284
+ }
285
+
193
286
  public toArray(): T[]
194
287
  {
195
288
  return Array.from(this as Iterable<T>);
196
289
  }
197
290
 
198
- public get [Symbol.toStringTag]() { return "SmartIterator"; }
291
+ public readonly [Symbol.toStringTag]: string = "SmartIterator";
199
292
 
200
293
  public [Symbol.iterator](): SmartIterator<T, R, N> { return this; }
201
294
  }
@@ -1,20 +1,30 @@
1
+
1
2
  import type { MaybePromise } from "../promises/types.js";
2
3
 
4
+ export type MaybeAsyncIterable<T, R = void, N = undefined> = Iterable<T, R, N> | AsyncIterable<T, R, N>;
5
+ export type MaybeAsyncIterator<T, R = void, N = undefined> = Iterator<T, R, N> | AsyncIterator<T, R, N>;
6
+ export type MaybeAsyncGenerator<T, R = void, N = undefined> = Generator<T, R, N> | AsyncGenerator<T, R, N>;
7
+
3
8
  export type GeneratorFunction<T, R = void, N = undefined> = () => Generator<T, R, N>;
4
9
  export type AsyncGeneratorFunction<T, R = void, N = undefined> = () => AsyncGenerator<T, R, N>;
10
+ export type MaybeAsyncGeneratorFunction<T, R = void, N = undefined> = () => MaybeAsyncGenerator<T, R, N>;
5
11
 
6
12
  export type Iteratee<T, R = void> = (value: T, index: number) => R;
13
+ export type AsyncIteratee<T, R = void> = (value: T, index: number) => Promise<R>;
7
14
  export type MaybeAsyncIteratee<T, R = void> = (value: T, index: number) => MaybePromise<R>;
8
15
 
9
16
  export type TypeGuardIteratee<T, R extends T> = (value: T, index: number) => value is R;
10
- export type MaybeAsyncTypeGuardIteratee<T, R extends T> = (value: MaybePromise<T>, index: number) =>
11
- value is MaybePromise<R>;
17
+
18
+ // @ts-expect-error - This is an asyncronous type guard iteratee that guarantees the return value is a promise.
19
+ export type AsyncTypeGuardIteratee<T, R extends T> = (value: T, index: number) => value is Promise<R>;
20
+
21
+ // @ts-expect-error - This may be an asyncronous type guard iteratee that guarantees the return value may be a promise.
22
+ export type MaybeAsyncTypeGuardIteratee<T, R extends T> = (value: T, index: number) => value is MaybePromise<R>;
12
23
 
13
24
  export type Reducer<T, A> = (accumulator: A, value: T, index: number) => A;
25
+ export type AsyncReducer<T, A> = (accumulator: A, value: T, index: number) => Promise<A>;
14
26
  export type MaybeAsyncReducer<T, A> = (accumulator: A, value: T, index: number) => MaybePromise<A>;
15
27
 
16
- export type IterLike<T, R = void, N = undefined> = Iterable<T> | Iterator<T, R, N> | GeneratorFunction<T, R, N>;
17
- export type AsyncIterLike<T, R = void, N = undefined> =
18
- AsyncIterable<T> | AsyncIterator<T, R, N> | AsyncGeneratorFunction<T, R, N>;
19
-
20
- export type MaybeAsyncIterLike<T, R = void, N = undefined> = IterLike<T, R, N> | AsyncIterLike<T, R, N>;
28
+ export type IteratorLike<T, R = void, N = undefined> = Iterable<T> | Iterator<T, R, N>;
29
+ export type AsyncIteratorLike<T, R = void, N = undefined> = AsyncIterable<T> | AsyncIterator<T, R, N>;
30
+ export type MaybeAsyncIteratorLike<T, R = void, N = undefined> = IteratorLike<T, R, N> | AsyncIteratorLike<T, R, N>;
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-trailing-spaces */
2
1
 
3
2
  import { isBrowser } from "../../helpers.js";
4
3
  import { EnvironmentException } from "../exceptions/index.js";
@@ -45,7 +44,7 @@ export default class JSONStorage
45
44
  {
46
45
  return JSON.parse(propertyValue);
47
46
  }
48
- catch (error)
47
+ catch
49
48
  {
50
49
  // eslint-disable-next-line no-console
51
50
  console.warn(
@@ -252,5 +251,5 @@ export default class JSONStorage
252
251
  this._persistent.removeItem(propertyName);
253
252
  }
254
253
 
255
- public get [Symbol.toStringTag]() { return "JSONStorage"; }
254
+ public readonly [Symbol.toStringTag]: string = "JSONStorage";
256
255
  }
@@ -1,3 +1,7 @@
1
1
  export type JSONArray = JSONValue[];
2
- export type JSONObject = { [key: string]: JSONValue };
2
+
3
+ // @ts-expect-error - This is a circular reference to itself.
4
+ export type JSONObject = Record<string, JSONValue>;
5
+
6
+ // @ts-expect-error - This is a circular reference to itself.
3
7
  export type JSONValue = boolean | number | string | null | JSONObject | JSONArray;
@@ -37,5 +37,5 @@ export default class DeferredPromise<T = void, F = T, R = never> extends SmartPr
37
37
  return this;
38
38
  }
39
39
 
40
- public get [Symbol.toStringTag]() { return "DeferredPromise"; }
40
+ public readonly [Symbol.toStringTag]: string = "DeferredPromise";
41
41
  }
@@ -2,6 +2,11 @@ import type { FulfilledHandler, PromiseExecutor, RejectedHandler } from "./types
2
2
 
3
3
  export default class SmartPromise<T = void> implements Promise<T>
4
4
  {
5
+ public static FromPromise<T>(promise: Promise<T>): SmartPromise<T>
6
+ {
7
+ return new SmartPromise((resolve, reject) => promise.then(resolve, reject));
8
+ }
9
+
5
10
  protected _isPending: boolean;
6
11
  protected _isFulfilled: boolean;
7
12
  protected _isRejected: boolean;
@@ -59,5 +64,5 @@ export default class SmartPromise<T = void> implements Promise<T>
59
64
  return this._promise.finally(onFinally);
60
65
  }
61
66
 
62
- public get [Symbol.toStringTag]() { return "SmartPromise"; }
67
+ public readonly [Symbol.toStringTag]: string = "SmartPromise";
63
68
  }
@@ -27,5 +27,5 @@ export default class TimedPromise<T = void> extends SmartPromise<T>
27
27
  });
28
28
  }
29
29
 
30
- public get [Symbol.toStringTag]() { return "TimedPromise"; }
30
+ public readonly [Symbol.toStringTag]: string = "TimedPromise";
31
31
  }
@@ -35,5 +35,5 @@ export default class Publisher<A extends unknown[] = [], R = void>
35
35
  .map((subscriber) => subscriber(...args));
36
36
  }
37
37
 
38
- public get [Symbol.toStringTag]() { return "Publisher"; }
38
+ public readonly [Symbol.toStringTag]: string = "Publisher";
39
39
  }
@@ -6,7 +6,7 @@ import Publisher from "../publisher.js";
6
6
 
7
7
  export default class Clock extends GameLoop
8
8
  {
9
- protected _publisher: Publisher<[number], void>;
9
+ protected _publisher: Publisher<[number]>;
10
10
 
11
11
  public constructor(fpsIfNotBrowser: number = TimeUnit.Second)
12
12
  {
@@ -44,4 +44,6 @@ export default class Clock extends GameLoop
44
44
  lastTick = elapsedTime;
45
45
  });
46
46
  }
47
+
48
+ public readonly [Symbol.toStringTag]: string = "Clock";
47
49
  }