@byloth/core 2.0.0-rc.3 → 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.
- package/dist/core.js +783 -786
- package/dist/core.js.map +1 -1
- package/dist/core.umd.cjs +3 -3
- package/dist/core.umd.cjs.map +1 -1
- package/package.json +6 -9
- package/src/helpers.ts +7 -0
- package/src/index.ts +1 -1
- package/src/models/aggregators/aggregated-async-iterator.ts +4 -4
- package/src/models/aggregators/aggregated-iterator.ts +4 -4
- package/src/models/aggregators/reduced-iterator.ts +1 -1
- package/src/models/exceptions/core.ts +3 -3
- package/src/models/exceptions/index.ts +13 -13
- package/src/models/game-loop.ts +2 -0
- package/src/models/iterators/smart-async-iterator.ts +6 -12
- package/src/models/iterators/smart-iterator.ts +8 -14
- package/src/models/iterators/types.ts +0 -1
- package/src/models/json/json-storage.ts +2 -3
- package/src/models/json/types.ts +5 -1
- package/src/models/promises/deferred-promise.ts +1 -1
- package/src/models/promises/smart-promise.ts +1 -1
- package/src/models/promises/timed-promise.ts +1 -1
- package/src/models/publisher.ts +1 -1
- package/src/models/timers/clock.ts +2 -0
- package/src/models/timers/countdown.ts +2 -0
- package/src/utils/date.ts +3 -0
- package/src/utils/random.ts +4 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@byloth/core",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.4",
|
|
4
4
|
"description": "An unopinionated collection of useful functions and classes that I use widely in all my projects. 🔧",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Core",
|
|
@@ -47,21 +47,18 @@
|
|
|
47
47
|
},
|
|
48
48
|
"types": "./src/index.ts",
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@byloth/eslint-config-typescript": "^
|
|
51
|
-
"@types/node": "^20.16.
|
|
52
|
-
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
53
|
-
"@typescript-eslint/parser": "^7.18.0",
|
|
54
|
-
"eslint": "^8.57.1",
|
|
50
|
+
"@byloth/eslint-config-typescript": "^3.0.0",
|
|
51
|
+
"@types/node": "^20.16.11",
|
|
55
52
|
"husky": "^9.1.6",
|
|
56
|
-
"typescript": "^5.6.
|
|
57
|
-
"vite": "^5.4.
|
|
53
|
+
"typescript": "^5.6.3",
|
|
54
|
+
"vite": "^5.4.8"
|
|
58
55
|
},
|
|
59
56
|
"scripts": {
|
|
60
57
|
"dev": "vite",
|
|
61
58
|
"build": "vite build",
|
|
62
59
|
"preview": "vite preview",
|
|
63
60
|
"typecheck": "tsc",
|
|
64
|
-
"lint": "eslint
|
|
61
|
+
"lint": "eslint .",
|
|
65
62
|
"test": "vitest",
|
|
66
63
|
"ci": "pnpm install --frozen-lockfile"
|
|
67
64
|
}
|
package/src/helpers.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
+
|
|
3
|
+
// @ts-ignore
|
|
1
4
|
export const isBrowser = ((typeof window !== "undefined") && (typeof window.document !== "undefined"));
|
|
5
|
+
|
|
6
|
+
// @ts-ignore
|
|
2
7
|
export const isNode = ((typeof process !== "undefined") && (process.versions?.node));
|
|
8
|
+
|
|
9
|
+
// @ts-ignore
|
|
3
10
|
export const isWebWorker = ((typeof self === "object") && (self.constructor?.name === "DedicatedWorkerGlobalScope"));
|
package/src/index.ts
CHANGED
|
@@ -204,11 +204,11 @@ export default class AggregatedAsyncIterator<K extends PropertyKey, T>
|
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
public async find(predicate: MaybeAsyncKeyedIteratee<K, T, boolean>): Promise<ReducedIterator<K, T |
|
|
207
|
+
public async find(predicate: MaybeAsyncKeyedIteratee<K, T, boolean>): Promise<ReducedIterator<K, T | undefined>>;
|
|
208
208
|
public async find<S extends T>(predicate: MaybeAsyncKeyedTypeGuardIteratee<K, T, S>)
|
|
209
|
-
: Promise<ReducedIterator<K, S |
|
|
209
|
+
: Promise<ReducedIterator<K, S | undefined>>;
|
|
210
210
|
|
|
211
|
-
public async find(predicate: MaybeAsyncKeyedIteratee<K, T, boolean>): Promise<ReducedIterator<K, T |
|
|
211
|
+
public async find(predicate: MaybeAsyncKeyedIteratee<K, T, boolean>): Promise<ReducedIterator<K, T | undefined>>
|
|
212
212
|
{
|
|
213
213
|
const values = new Map<K, [number, T | undefined]>();
|
|
214
214
|
|
|
@@ -347,5 +347,5 @@ export default class AggregatedAsyncIterator<K extends PropertyKey, T>
|
|
|
347
347
|
return groups;
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
public
|
|
350
|
+
public readonly [Symbol.toStringTag]: string = "AggregatedAsyncIterator";
|
|
351
351
|
}
|
|
@@ -192,9 +192,9 @@ export default class AggregatedIterator<K extends PropertyKey, T>
|
|
|
192
192
|
});
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
public find(predicate: KeyedIteratee<K, T, boolean>): ReducedIterator<K, T |
|
|
196
|
-
public find<S extends T>(predicate: KeyedTypeGuardIteratee<K, T, S>): ReducedIterator<K, S |
|
|
197
|
-
public find(predicate: KeyedIteratee<K, T, boolean>): ReducedIterator<K, T |
|
|
195
|
+
public find(predicate: KeyedIteratee<K, T, boolean>): ReducedIterator<K, T | undefined>;
|
|
196
|
+
public find<S extends T>(predicate: KeyedTypeGuardIteratee<K, T, S>): ReducedIterator<K, S | undefined>;
|
|
197
|
+
public find(predicate: KeyedIteratee<K, T, boolean>): ReducedIterator<K, T | undefined>
|
|
198
198
|
{
|
|
199
199
|
const values = new Map<K, [number, T | undefined]>();
|
|
200
200
|
|
|
@@ -337,5 +337,5 @@ export default class AggregatedIterator<K extends PropertyKey, T>
|
|
|
337
337
|
return groups;
|
|
338
338
|
}
|
|
339
339
|
|
|
340
|
-
public
|
|
340
|
+
public readonly [Symbol.toStringTag]: string = "AggregatedIterator";
|
|
341
341
|
}
|
|
@@ -209,5 +209,5 @@ export default class ReducedIterator<K extends PropertyKey, T>
|
|
|
209
209
|
return Object.fromEntries(this.items()) as Record<K, T>;
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
public
|
|
212
|
+
public readonly [Symbol.toStringTag]: string = "ReducedIterator";
|
|
213
213
|
}
|
|
@@ -39,7 +39,7 @@ export default class Exception extends Error
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
public
|
|
42
|
+
public readonly [Symbol.toStringTag]: string = "Exception";
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export class FatalErrorException extends Exception
|
|
@@ -55,7 +55,7 @@ export class FatalErrorException extends Exception
|
|
|
55
55
|
super(message, cause, name);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
public
|
|
58
|
+
public readonly [Symbol.toStringTag]: string = "FatalErrorException";
|
|
59
59
|
}
|
|
60
60
|
export class NotImplementedException extends FatalErrorException
|
|
61
61
|
{
|
|
@@ -69,5 +69,5 @@ export class NotImplementedException extends FatalErrorException
|
|
|
69
69
|
super(message, cause, name);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
public
|
|
72
|
+
public readonly [Symbol.toStringTag]: string = "NotImplementedException";
|
|
73
73
|
}
|
|
@@ -7,7 +7,7 @@ export class FileException extends Exception
|
|
|
7
7
|
super(message, cause, name);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
public
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
122
|
+
public readonly [Symbol.toStringTag]: string = "RangeException";
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
export { Exception };
|
package/src/models/game-loop.ts
CHANGED
|
@@ -97,7 +97,6 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
|
|
|
97
97
|
{
|
|
98
98
|
let index = 0;
|
|
99
99
|
|
|
100
|
-
// eslint-disable-next-line no-constant-condition
|
|
101
100
|
while (true)
|
|
102
101
|
{
|
|
103
102
|
const result = await this._iterator.next();
|
|
@@ -112,7 +111,6 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
|
|
|
112
111
|
{
|
|
113
112
|
let index = 0;
|
|
114
113
|
|
|
115
|
-
// eslint-disable-next-line no-constant-condition
|
|
116
114
|
while (true)
|
|
117
115
|
{
|
|
118
116
|
const result = await this._iterator.next();
|
|
@@ -179,7 +177,6 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
|
|
|
179
177
|
index += 1;
|
|
180
178
|
}
|
|
181
179
|
|
|
182
|
-
// eslint-disable-next-line no-constant-condition
|
|
183
180
|
while (true)
|
|
184
181
|
{
|
|
185
182
|
const result = await this._iterator.next();
|
|
@@ -216,11 +213,11 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
|
|
|
216
213
|
});
|
|
217
214
|
}
|
|
218
215
|
|
|
219
|
-
public drop(count: number): SmartAsyncIterator<T, R |
|
|
216
|
+
public drop(count: number): SmartAsyncIterator<T, R | undefined>
|
|
220
217
|
{
|
|
221
218
|
const iterator = this._iterator;
|
|
222
219
|
|
|
223
|
-
return new SmartAsyncIterator<T, R |
|
|
220
|
+
return new SmartAsyncIterator<T, R | undefined>(async function* ()
|
|
224
221
|
{
|
|
225
222
|
let index = 0;
|
|
226
223
|
|
|
@@ -241,11 +238,11 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
|
|
|
241
238
|
}
|
|
242
239
|
});
|
|
243
240
|
}
|
|
244
|
-
public take(limit: number): SmartAsyncIterator<T, R |
|
|
241
|
+
public take(limit: number): SmartAsyncIterator<T, R | undefined>
|
|
245
242
|
{
|
|
246
243
|
const iterator = this._iterator;
|
|
247
244
|
|
|
248
|
-
return new SmartAsyncIterator<T, R |
|
|
245
|
+
return new SmartAsyncIterator<T, R | undefined>(async function* ()
|
|
249
246
|
{
|
|
250
247
|
let index = 0;
|
|
251
248
|
|
|
@@ -263,11 +260,10 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
|
|
|
263
260
|
});
|
|
264
261
|
}
|
|
265
262
|
|
|
266
|
-
public async find(predicate: MaybeAsyncIteratee<T, boolean>): Promise<T |
|
|
263
|
+
public async find(predicate: MaybeAsyncIteratee<T, boolean>): Promise<T | undefined>
|
|
267
264
|
{
|
|
268
265
|
let index = 0;
|
|
269
266
|
|
|
270
|
-
// eslint-disable-next-line no-constant-condition
|
|
271
267
|
while (true)
|
|
272
268
|
{
|
|
273
269
|
const result = await this._iterator.next();
|
|
@@ -309,7 +305,6 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
|
|
|
309
305
|
{
|
|
310
306
|
let index = 0;
|
|
311
307
|
|
|
312
|
-
// eslint-disable-next-line no-constant-condition
|
|
313
308
|
while (true)
|
|
314
309
|
{
|
|
315
310
|
const result = await this._iterator.next();
|
|
@@ -322,7 +317,6 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
|
|
|
322
317
|
{
|
|
323
318
|
let index = 0;
|
|
324
319
|
|
|
325
|
-
// eslint-disable-next-line no-constant-condition
|
|
326
320
|
while (true)
|
|
327
321
|
{
|
|
328
322
|
const result = await this._iterator.next();
|
|
@@ -354,7 +348,7 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
|
|
|
354
348
|
return Array.fromAsync(this as AsyncIterable<T>);
|
|
355
349
|
}
|
|
356
350
|
|
|
357
|
-
public
|
|
351
|
+
public readonly [Symbol.toStringTag]: string = "SmartAsyncIterator";
|
|
358
352
|
|
|
359
353
|
public [Symbol.asyncIterator](): SmartAsyncIterator<T, R, N> { return this; }
|
|
360
354
|
}
|
|
@@ -37,7 +37,6 @@ export default class SmartIterator<T, R = void, N = undefined> implements Iterat
|
|
|
37
37
|
{
|
|
38
38
|
let index = 0;
|
|
39
39
|
|
|
40
|
-
// eslint-disable-next-line no-constant-condition
|
|
41
40
|
while (true)
|
|
42
41
|
{
|
|
43
42
|
const result = this._iterator.next();
|
|
@@ -52,7 +51,6 @@ export default class SmartIterator<T, R = void, N = undefined> implements Iterat
|
|
|
52
51
|
{
|
|
53
52
|
let index = 0;
|
|
54
53
|
|
|
55
|
-
// eslint-disable-next-line no-constant-condition
|
|
56
54
|
while (true)
|
|
57
55
|
{
|
|
58
56
|
const result = this._iterator.next();
|
|
@@ -119,7 +117,6 @@ export default class SmartIterator<T, R = void, N = undefined> implements Iterat
|
|
|
119
117
|
index += 1;
|
|
120
118
|
}
|
|
121
119
|
|
|
122
|
-
// eslint-disable-next-line no-constant-condition
|
|
123
120
|
while (true)
|
|
124
121
|
{
|
|
125
122
|
const result = this._iterator.next();
|
|
@@ -155,11 +152,11 @@ export default class SmartIterator<T, R = void, N = undefined> implements Iterat
|
|
|
155
152
|
});
|
|
156
153
|
}
|
|
157
154
|
|
|
158
|
-
public drop(count: number): SmartIterator<T, R |
|
|
155
|
+
public drop(count: number): SmartIterator<T, R | undefined>
|
|
159
156
|
{
|
|
160
157
|
const iterator = this._iterator;
|
|
161
158
|
|
|
162
|
-
return new SmartIterator<T, R |
|
|
159
|
+
return new SmartIterator<T, R | undefined>(function* ()
|
|
163
160
|
{
|
|
164
161
|
let index = 0;
|
|
165
162
|
while (index < count)
|
|
@@ -179,11 +176,11 @@ export default class SmartIterator<T, R = void, N = undefined> implements Iterat
|
|
|
179
176
|
}
|
|
180
177
|
});
|
|
181
178
|
}
|
|
182
|
-
public take(limit: number): SmartIterator<T, R |
|
|
179
|
+
public take(limit: number): SmartIterator<T, R | undefined>
|
|
183
180
|
{
|
|
184
181
|
const iterator = this._iterator;
|
|
185
182
|
|
|
186
|
-
return new SmartIterator<T, R |
|
|
183
|
+
return new SmartIterator<T, R | undefined>(function* ()
|
|
187
184
|
{
|
|
188
185
|
let index = 0;
|
|
189
186
|
while (index < limit)
|
|
@@ -200,13 +197,12 @@ export default class SmartIterator<T, R = void, N = undefined> implements Iterat
|
|
|
200
197
|
});
|
|
201
198
|
}
|
|
202
199
|
|
|
203
|
-
public find(predicate: Iteratee<T, boolean>): T |
|
|
204
|
-
public find<S extends T>(predicate: TypeGuardIteratee<T, S>): S |
|
|
205
|
-
public find(predicate: Iteratee<T, boolean>): T |
|
|
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
|
|
206
203
|
{
|
|
207
204
|
let index = 0;
|
|
208
205
|
|
|
209
|
-
// eslint-disable-next-line no-constant-condition
|
|
210
206
|
while (true)
|
|
211
207
|
{
|
|
212
208
|
const result = this._iterator.next();
|
|
@@ -248,7 +244,6 @@ export default class SmartIterator<T, R = void, N = undefined> implements Iterat
|
|
|
248
244
|
{
|
|
249
245
|
let index = 0;
|
|
250
246
|
|
|
251
|
-
// eslint-disable-next-line no-constant-condition
|
|
252
247
|
while (true)
|
|
253
248
|
{
|
|
254
249
|
const result = this._iterator.next();
|
|
@@ -262,7 +257,6 @@ export default class SmartIterator<T, R = void, N = undefined> implements Iterat
|
|
|
262
257
|
{
|
|
263
258
|
let index = 0;
|
|
264
259
|
|
|
265
|
-
// eslint-disable-next-line no-constant-condition
|
|
266
260
|
while (true)
|
|
267
261
|
{
|
|
268
262
|
const result = this._iterator.next();
|
|
@@ -294,7 +288,7 @@ export default class SmartIterator<T, R = void, N = undefined> implements Iterat
|
|
|
294
288
|
return Array.from(this as Iterable<T>);
|
|
295
289
|
}
|
|
296
290
|
|
|
297
|
-
public
|
|
291
|
+
public readonly [Symbol.toStringTag]: string = "SmartIterator";
|
|
298
292
|
|
|
299
293
|
public [Symbol.iterator](): SmartIterator<T, R, N> { return this; }
|
|
300
294
|
}
|
|
@@ -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
|
|
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
|
|
254
|
+
public readonly [Symbol.toStringTag]: string = "JSONStorage";
|
|
256
255
|
}
|
package/src/models/json/types.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export type JSONArray = JSONValue[];
|
|
2
|
-
|
|
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;
|
package/src/models/publisher.ts
CHANGED
package/src/utils/date.ts
CHANGED
package/src/utils/random.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ValueException } from "../models/index.js";
|
|
|
2
2
|
|
|
3
3
|
export default class Random
|
|
4
4
|
{
|
|
5
|
-
public static Boolean(ratio
|
|
5
|
+
public static Boolean(ratio = 0.5): boolean
|
|
6
6
|
{
|
|
7
7
|
return (Math.random() < ratio);
|
|
8
8
|
}
|
|
@@ -38,6 +38,7 @@ export default class Random
|
|
|
38
38
|
return elements[Random.Index(elements)];
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
private constructor() { /* ... */ }
|
|
42
|
+
|
|
43
|
+
public readonly [Symbol.toStringTag]: string = "Random";
|
|
43
44
|
}
|