@byloth/core 1.5.3 → 2.0.0-rc.1
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 +521 -364
- package/dist/core.js.map +1 -1
- package/dist/core.umd.cjs +2 -2
- package/dist/core.umd.cjs.map +1 -1
- package/package.json +8 -8
- package/src/helpers.ts +3 -0
- package/src/index.ts +16 -4
- package/src/models/aggregators/reduced-iterator.ts +2 -2
- package/src/models/exceptions/core.ts +3 -4
- package/src/models/exceptions/index.ts +41 -1
- package/src/models/game-loop.ts +83 -0
- package/src/models/index.ts +10 -4
- package/src/models/iterators/smart-async-iterator.ts +3 -1
- package/src/models/iterators/smart-iterator.ts +3 -1
- package/src/models/json/index.ts +3 -0
- package/src/models/{json-storage.ts → json/json-storage.ts} +39 -26
- package/src/models/json/types.ts +3 -0
- package/src/models/publisher.ts +39 -0
- package/src/models/timers/clock.ts +47 -0
- package/src/models/timers/countdown.ts +81 -0
- package/src/models/timers/index.ts +4 -0
- package/src/models/types.ts +9 -0
- package/src/utils/date.ts +4 -4
- package/src/utils/index.ts +1 -1
- package/src/models/subscribers.ts +0 -35
package/dist/core.js
CHANGED
|
@@ -1,7 +1,153 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var u = (s, e, t) =>
|
|
4
|
-
|
|
1
|
+
var j = Object.defineProperty;
|
|
2
|
+
var D = (s, e, t) => e in s ? j(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var u = (s, e, t) => D(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
const E = typeof window < "u" && typeof window.document < "u";
|
|
5
|
+
var S;
|
|
6
|
+
const J = typeof process < "u" && ((S = process.versions) == null ? void 0 : S.node);
|
|
7
|
+
var k;
|
|
8
|
+
const W = typeof self == "object" && ((k = self.constructor) == null ? void 0 : k.name) === "DedicatedWorkerGlobalScope";
|
|
9
|
+
class h extends Error {
|
|
10
|
+
static FromUnknown(e) {
|
|
11
|
+
if (e instanceof h)
|
|
12
|
+
return e;
|
|
13
|
+
if (e instanceof Error) {
|
|
14
|
+
const t = new h(e.message);
|
|
15
|
+
return t.stack = e.stack, t.name = e.name, t;
|
|
16
|
+
}
|
|
17
|
+
return new h(`${e}`);
|
|
18
|
+
}
|
|
19
|
+
constructor(e, t, n = "Exception") {
|
|
20
|
+
super(e), this.cause = t, this.name = n, t && (t instanceof Error ? this.stack += `
|
|
21
|
+
|
|
22
|
+
Caused by ${t.stack}` : this.stack += `
|
|
23
|
+
|
|
24
|
+
Caused by ${t}`);
|
|
25
|
+
}
|
|
26
|
+
get [Symbol.toStringTag]() {
|
|
27
|
+
return "Exception";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
class g extends h {
|
|
31
|
+
constructor(e, t, n = "FatalErrorException") {
|
|
32
|
+
e === void 0 && (e = "The program has encountered an unrecoverable error and cannot continue as expected. Please, try again later. If the problem persists, contact the support team."), super(e, t, n);
|
|
33
|
+
}
|
|
34
|
+
get [Symbol.toStringTag]() {
|
|
35
|
+
return "FatalErrorException";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
class Y extends g {
|
|
39
|
+
constructor(e, t, n = "NotImplementedException") {
|
|
40
|
+
e === void 0 && (e = "This feature is not implemented yet. Please, try again later."), super(e, t, n);
|
|
41
|
+
}
|
|
42
|
+
get [Symbol.toStringTag]() {
|
|
43
|
+
return "NotImplementedException";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
class T extends h {
|
|
47
|
+
constructor(e, t, n = "FileException") {
|
|
48
|
+
super(e, t, n);
|
|
49
|
+
}
|
|
50
|
+
get [Symbol.toStringTag]() {
|
|
51
|
+
return "FileException";
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
class z extends T {
|
|
55
|
+
constructor(e, t, n = "FileExistsException") {
|
|
56
|
+
super(e, t, n);
|
|
57
|
+
}
|
|
58
|
+
get [Symbol.toStringTag]() {
|
|
59
|
+
return "FileExistsException";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
class V extends T {
|
|
63
|
+
constructor(e, t, n = "FileNotFoundException") {
|
|
64
|
+
super(e, t, n);
|
|
65
|
+
}
|
|
66
|
+
get [Symbol.toStringTag]() {
|
|
67
|
+
return "FileNotFoundException";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
class B extends h {
|
|
71
|
+
constructor(e, t, n = "KeyException") {
|
|
72
|
+
super(e, t, n);
|
|
73
|
+
}
|
|
74
|
+
get [Symbol.toStringTag]() {
|
|
75
|
+
return "KeyException";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
class K extends h {
|
|
79
|
+
constructor(e, t, n = "NetworkException") {
|
|
80
|
+
super(e, t, n);
|
|
81
|
+
}
|
|
82
|
+
get [Symbol.toStringTag]() {
|
|
83
|
+
return "NetworkException";
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
class G extends h {
|
|
87
|
+
constructor(e, t, n = "PermissionException") {
|
|
88
|
+
super(e, t, n);
|
|
89
|
+
}
|
|
90
|
+
get [Symbol.toStringTag]() {
|
|
91
|
+
return "PermissionException";
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
class q extends h {
|
|
95
|
+
constructor(e, t, n = "ReferenceException") {
|
|
96
|
+
super(e, t, n);
|
|
97
|
+
}
|
|
98
|
+
get [Symbol.toStringTag]() {
|
|
99
|
+
return "ReferenceException";
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
class m extends h {
|
|
103
|
+
constructor(e, t, n = "RuntimeException") {
|
|
104
|
+
super(e, t, n);
|
|
105
|
+
}
|
|
106
|
+
get [Symbol.toStringTag]() {
|
|
107
|
+
return "RuntimeException";
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
class A extends m {
|
|
111
|
+
constructor(e, t, n = "EnvironmentException") {
|
|
112
|
+
super(e, t, n);
|
|
113
|
+
}
|
|
114
|
+
get [Symbol.toStringTag]() {
|
|
115
|
+
return "EnvironmentException";
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
class C extends h {
|
|
119
|
+
constructor(e, t, n = "TimeoutException") {
|
|
120
|
+
super(e, t, n);
|
|
121
|
+
}
|
|
122
|
+
get [Symbol.toStringTag]() {
|
|
123
|
+
return "TimeoutException";
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
class H extends h {
|
|
127
|
+
constructor(e, t, n = "TypeException") {
|
|
128
|
+
super(e, t, n);
|
|
129
|
+
}
|
|
130
|
+
get [Symbol.toStringTag]() {
|
|
131
|
+
return "TypeException";
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
class f extends h {
|
|
135
|
+
constructor(e, t, n = "ValueException") {
|
|
136
|
+
super(e, t, n);
|
|
137
|
+
}
|
|
138
|
+
get [Symbol.toStringTag]() {
|
|
139
|
+
return "ValueException";
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
class M extends f {
|
|
143
|
+
constructor(e, t, n = "RangeException") {
|
|
144
|
+
super(e, t, n);
|
|
145
|
+
}
|
|
146
|
+
get [Symbol.toStringTag]() {
|
|
147
|
+
return "RangeException";
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
class a {
|
|
5
151
|
constructor(e) {
|
|
6
152
|
u(this, "_iterator");
|
|
7
153
|
u(this, "return");
|
|
@@ -32,7 +178,7 @@ class c {
|
|
|
32
178
|
}
|
|
33
179
|
filter(e) {
|
|
34
180
|
const t = this._iterator;
|
|
35
|
-
return new
|
|
181
|
+
return new a(function* () {
|
|
36
182
|
let n = 0;
|
|
37
183
|
for (; ; ) {
|
|
38
184
|
const r = t.next();
|
|
@@ -44,7 +190,7 @@ class c {
|
|
|
44
190
|
}
|
|
45
191
|
map(e) {
|
|
46
192
|
const t = this._iterator;
|
|
47
|
-
return new
|
|
193
|
+
return new a(function* () {
|
|
48
194
|
let n = 0;
|
|
49
195
|
for (; ; ) {
|
|
50
196
|
const r = t.next();
|
|
@@ -57,16 +203,16 @@ class c {
|
|
|
57
203
|
reduce(e, t) {
|
|
58
204
|
let n = 0, r = t;
|
|
59
205
|
if (r === void 0) {
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
62
|
-
throw new
|
|
63
|
-
r =
|
|
206
|
+
const i = this._iterator.next();
|
|
207
|
+
if (i.done)
|
|
208
|
+
throw new f("Cannot reduce an empty iterator without an initial value.");
|
|
209
|
+
r = i.value, n += 1;
|
|
64
210
|
}
|
|
65
211
|
for (; ; ) {
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
212
|
+
const i = this._iterator.next();
|
|
213
|
+
if (i.done)
|
|
68
214
|
return r;
|
|
69
|
-
r = e(r,
|
|
215
|
+
r = e(r, i.value, n), n += 1;
|
|
70
216
|
}
|
|
71
217
|
}
|
|
72
218
|
enumerate() {
|
|
@@ -74,7 +220,7 @@ class c {
|
|
|
74
220
|
}
|
|
75
221
|
unique() {
|
|
76
222
|
const e = this._iterator;
|
|
77
|
-
return new
|
|
223
|
+
return new a(function* () {
|
|
78
224
|
const t = /* @__PURE__ */ new Set();
|
|
79
225
|
for (; ; ) {
|
|
80
226
|
const n = e.next();
|
|
@@ -114,7 +260,7 @@ class c {
|
|
|
114
260
|
return this;
|
|
115
261
|
}
|
|
116
262
|
}
|
|
117
|
-
class
|
|
263
|
+
class d {
|
|
118
264
|
constructor(e) {
|
|
119
265
|
u(this, "_iterator");
|
|
120
266
|
u(this, "return");
|
|
@@ -178,7 +324,7 @@ class h {
|
|
|
178
324
|
}
|
|
179
325
|
filter(e) {
|
|
180
326
|
const t = this._iterator;
|
|
181
|
-
return new
|
|
327
|
+
return new d(async function* () {
|
|
182
328
|
let n = 0;
|
|
183
329
|
for (; ; ) {
|
|
184
330
|
const r = await t.next();
|
|
@@ -190,7 +336,7 @@ class h {
|
|
|
190
336
|
}
|
|
191
337
|
map(e) {
|
|
192
338
|
const t = this._iterator;
|
|
193
|
-
return new
|
|
339
|
+
return new d(async function* () {
|
|
194
340
|
let n = 0;
|
|
195
341
|
for (; ; ) {
|
|
196
342
|
const r = await t.next();
|
|
@@ -203,16 +349,16 @@ class h {
|
|
|
203
349
|
async reduce(e, t) {
|
|
204
350
|
let n = 0, r = t;
|
|
205
351
|
if (r === void 0) {
|
|
206
|
-
const
|
|
207
|
-
if (
|
|
208
|
-
throw new
|
|
209
|
-
r =
|
|
352
|
+
const i = await this._iterator.next();
|
|
353
|
+
if (i.done)
|
|
354
|
+
throw new f("Cannot reduce an empty iterator without an initial value.");
|
|
355
|
+
r = i.value, n += 1;
|
|
210
356
|
}
|
|
211
357
|
for (; ; ) {
|
|
212
|
-
const
|
|
213
|
-
if (
|
|
358
|
+
const i = await this._iterator.next();
|
|
359
|
+
if (i.done)
|
|
214
360
|
return r;
|
|
215
|
-
r = await e(r,
|
|
361
|
+
r = await e(r, i.value, n), n += 1;
|
|
216
362
|
}
|
|
217
363
|
}
|
|
218
364
|
enumerate() {
|
|
@@ -220,7 +366,7 @@ class h {
|
|
|
220
366
|
}
|
|
221
367
|
unique() {
|
|
222
368
|
const e = this._iterator;
|
|
223
|
-
return new
|
|
369
|
+
return new d(async function* () {
|
|
224
370
|
const t = /* @__PURE__ */ new Set();
|
|
225
371
|
for (; ; ) {
|
|
226
372
|
const n = await e.next();
|
|
@@ -266,132 +412,23 @@ class h {
|
|
|
266
412
|
return this;
|
|
267
413
|
}
|
|
268
414
|
}
|
|
269
|
-
class
|
|
270
|
-
static FromUnknown(e) {
|
|
271
|
-
if (e instanceof f)
|
|
272
|
-
return e;
|
|
273
|
-
if (e instanceof Error) {
|
|
274
|
-
const t = new f(e.message);
|
|
275
|
-
return t.stack = e.stack, t.name = e.name, t;
|
|
276
|
-
}
|
|
277
|
-
return new f(`${e}`);
|
|
278
|
-
}
|
|
279
|
-
constructor(e, t, n = "Exception") {
|
|
280
|
-
super(e), this.cause = t, this.name = n, t && (t instanceof Error ? this.stack += `
|
|
281
|
-
|
|
282
|
-
Caused by ${t.stack}` : this.stack += `
|
|
283
|
-
|
|
284
|
-
Caused by ${t}`);
|
|
285
|
-
}
|
|
286
|
-
get [Symbol.toStringTag]() {
|
|
287
|
-
return "Exception";
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
class j extends f {
|
|
291
|
-
constructor(e, t, n = "FatalErrorException") {
|
|
292
|
-
e === void 0 && (e = "The routine has encountered an unrecoverable error and cannot continue as expected. Please, refresh the page and try again. If the problem persists, contact the support team."), super(e, t, n);
|
|
293
|
-
}
|
|
294
|
-
get [Symbol.toStringTag]() {
|
|
295
|
-
return "FatalErrorException";
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
class F extends f {
|
|
299
|
-
constructor(e, t, n = "NotImplementedException") {
|
|
300
|
-
e === void 0 && (e = "This feature is not implemented yet. Please, try again later."), super(e, t, n);
|
|
301
|
-
}
|
|
302
|
-
get [Symbol.toStringTag]() {
|
|
303
|
-
return "NotImplementedException";
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
class R extends f {
|
|
307
|
-
constructor(e, t, n = "FileNotFoundException") {
|
|
308
|
-
super(e, t, n);
|
|
309
|
-
}
|
|
310
|
-
get [Symbol.toStringTag]() {
|
|
311
|
-
return "FileNotFoundException";
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
class q extends f {
|
|
315
|
-
constructor(e, t, n = "KeyException") {
|
|
316
|
-
super(e, t, n);
|
|
317
|
-
}
|
|
318
|
-
get [Symbol.toStringTag]() {
|
|
319
|
-
return "KeyException";
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
class A extends f {
|
|
323
|
-
constructor(e, t, n = "NetworkException") {
|
|
324
|
-
super(e, t, n);
|
|
325
|
-
}
|
|
326
|
-
get [Symbol.toStringTag]() {
|
|
327
|
-
return "NetworkException";
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
class O extends f {
|
|
331
|
-
constructor(e, t, n = "PermissionException") {
|
|
332
|
-
super(e, t, n);
|
|
333
|
-
}
|
|
334
|
-
get [Symbol.toStringTag]() {
|
|
335
|
-
return "PermissionException";
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
class k extends f {
|
|
339
|
-
constructor(e, t, n = "ReferenceException") {
|
|
340
|
-
super(e, t, n);
|
|
341
|
-
}
|
|
342
|
-
get [Symbol.toStringTag]() {
|
|
343
|
-
return "ReferenceException";
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
class $ extends f {
|
|
347
|
-
constructor(e, t, n = "RuntimeException") {
|
|
348
|
-
super(e, t, n);
|
|
349
|
-
}
|
|
350
|
-
get [Symbol.toStringTag]() {
|
|
351
|
-
return "RuntimeException";
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
class T extends f {
|
|
355
|
-
constructor(e, t, n = "TimeoutException") {
|
|
356
|
-
super(e, t, n);
|
|
357
|
-
}
|
|
358
|
-
get [Symbol.toStringTag]() {
|
|
359
|
-
return "TimeoutException";
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
class E extends f {
|
|
363
|
-
constructor(e, t, n = "TypeException") {
|
|
364
|
-
super(e, t, n);
|
|
365
|
-
}
|
|
366
|
-
get [Symbol.toStringTag]() {
|
|
367
|
-
return "TypeException";
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
class m extends f {
|
|
371
|
-
constructor(e, t, n = "ValueException") {
|
|
372
|
-
super(e, t, n);
|
|
373
|
-
}
|
|
374
|
-
get [Symbol.toStringTag]() {
|
|
375
|
-
return "ValueException";
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
class a {
|
|
415
|
+
class l {
|
|
379
416
|
constructor(e) {
|
|
380
417
|
u(this, "_elements");
|
|
381
|
-
this._elements = new
|
|
418
|
+
this._elements = new a(e);
|
|
382
419
|
}
|
|
383
420
|
filter(e) {
|
|
384
421
|
const t = this._elements;
|
|
385
|
-
return new
|
|
386
|
-
for (const [n, [r,
|
|
387
|
-
e(r,
|
|
422
|
+
return new l(function* () {
|
|
423
|
+
for (const [n, [r, i]] of t.enumerate())
|
|
424
|
+
e(r, i, n) && (yield [r, i]);
|
|
388
425
|
});
|
|
389
426
|
}
|
|
390
427
|
map(e) {
|
|
391
428
|
const t = this._elements;
|
|
392
|
-
return new
|
|
393
|
-
for (const [n, [r,
|
|
394
|
-
yield [r, e(r,
|
|
429
|
+
return new l(function* () {
|
|
430
|
+
for (const [n, [r, i]] of t.enumerate())
|
|
431
|
+
yield [r, e(r, i, n)];
|
|
395
432
|
});
|
|
396
433
|
}
|
|
397
434
|
reduce(e, t) {
|
|
@@ -399,18 +436,18 @@ class a {
|
|
|
399
436
|
if (t !== void 0)
|
|
400
437
|
r = t;
|
|
401
438
|
else {
|
|
402
|
-
const
|
|
403
|
-
if (
|
|
404
|
-
throw new
|
|
405
|
-
n += 1, r =
|
|
439
|
+
const i = this._elements.next();
|
|
440
|
+
if (i.done)
|
|
441
|
+
throw new f("Cannot reduce an empty iterator without an initial value.");
|
|
442
|
+
n += 1, r = i.value[1];
|
|
406
443
|
}
|
|
407
|
-
for (const [
|
|
408
|
-
r = e(
|
|
444
|
+
for (const [i, o] of this._elements)
|
|
445
|
+
r = e(i, r, o, n), n += 1;
|
|
409
446
|
return r;
|
|
410
447
|
}
|
|
411
448
|
keys() {
|
|
412
449
|
const e = this._elements;
|
|
413
|
-
return new
|
|
450
|
+
return new a(function* () {
|
|
414
451
|
for (const [t] of e)
|
|
415
452
|
yield t;
|
|
416
453
|
});
|
|
@@ -420,7 +457,7 @@ class a {
|
|
|
420
457
|
}
|
|
421
458
|
values() {
|
|
422
459
|
const e = this._elements;
|
|
423
|
-
return new
|
|
460
|
+
return new a(function* () {
|
|
424
461
|
for (const [t, n] of e)
|
|
425
462
|
yield n;
|
|
426
463
|
});
|
|
@@ -438,79 +475,79 @@ class a {
|
|
|
438
475
|
return "ReducedIterator";
|
|
439
476
|
}
|
|
440
477
|
}
|
|
441
|
-
class
|
|
478
|
+
class w {
|
|
442
479
|
constructor(e) {
|
|
443
480
|
u(this, "_elements");
|
|
444
|
-
this._elements = new
|
|
481
|
+
this._elements = new a(e);
|
|
445
482
|
}
|
|
446
483
|
every(e) {
|
|
447
484
|
const t = /* @__PURE__ */ new Map();
|
|
448
485
|
for (const [n, r] of this._elements) {
|
|
449
|
-
const [
|
|
450
|
-
|
|
486
|
+
const [i, o] = t.get(n) ?? [0, !0];
|
|
487
|
+
o && t.set(n, [i + 1, e(n, r, i)]);
|
|
451
488
|
}
|
|
452
|
-
return new
|
|
453
|
-
for (const [n, [r,
|
|
454
|
-
yield [n,
|
|
489
|
+
return new l(function* () {
|
|
490
|
+
for (const [n, [r, i]] of t)
|
|
491
|
+
yield [n, i];
|
|
455
492
|
});
|
|
456
493
|
}
|
|
457
494
|
some(e) {
|
|
458
495
|
const t = /* @__PURE__ */ new Map();
|
|
459
496
|
for (const [n, r] of this._elements) {
|
|
460
|
-
const [
|
|
461
|
-
|
|
497
|
+
const [i, o] = t.get(n) ?? [0, !1];
|
|
498
|
+
o || t.set(n, [i + 1, e(n, r, i)]);
|
|
462
499
|
}
|
|
463
|
-
return new
|
|
464
|
-
for (const [n, [r,
|
|
465
|
-
yield [n,
|
|
500
|
+
return new l(function* () {
|
|
501
|
+
for (const [n, [r, i]] of t)
|
|
502
|
+
yield [n, i];
|
|
466
503
|
});
|
|
467
504
|
}
|
|
468
505
|
filter(e) {
|
|
469
506
|
const t = this._elements;
|
|
470
|
-
return new
|
|
507
|
+
return new w(function* () {
|
|
471
508
|
const n = /* @__PURE__ */ new Map();
|
|
472
|
-
for (const [r,
|
|
473
|
-
const
|
|
474
|
-
n.set(r,
|
|
509
|
+
for (const [r, i] of t) {
|
|
510
|
+
const o = n.get(r) ?? 0;
|
|
511
|
+
n.set(r, o + 1), e(r, i, o) && (yield [r, i]);
|
|
475
512
|
}
|
|
476
513
|
});
|
|
477
514
|
}
|
|
478
515
|
map(e) {
|
|
479
516
|
const t = this._elements;
|
|
480
|
-
return new
|
|
517
|
+
return new w(function* () {
|
|
481
518
|
const n = /* @__PURE__ */ new Map();
|
|
482
|
-
for (const [r,
|
|
483
|
-
const
|
|
484
|
-
n.set(r,
|
|
519
|
+
for (const [r, i] of t) {
|
|
520
|
+
const o = n.get(r) ?? 0;
|
|
521
|
+
n.set(r, o + 1), yield [r, e(r, i, o)];
|
|
485
522
|
}
|
|
486
523
|
});
|
|
487
524
|
}
|
|
488
525
|
reduce(e, t) {
|
|
489
526
|
const n = /* @__PURE__ */ new Map();
|
|
490
|
-
for (const [r,
|
|
491
|
-
let
|
|
527
|
+
for (const [r, i] of this._elements) {
|
|
528
|
+
let o, c;
|
|
492
529
|
if (n.has(r))
|
|
493
|
-
[
|
|
530
|
+
[o, c] = n.get(r), o += 1;
|
|
494
531
|
else if (t !== void 0)
|
|
495
|
-
|
|
532
|
+
o = 0, c = t(r);
|
|
496
533
|
else {
|
|
497
|
-
n.set(r, [0,
|
|
534
|
+
n.set(r, [0, i]);
|
|
498
535
|
continue;
|
|
499
536
|
}
|
|
500
|
-
|
|
537
|
+
c = e(r, c, i, o), n.set(r, [o, c]);
|
|
501
538
|
}
|
|
502
|
-
return new
|
|
503
|
-
for (const [r, [
|
|
504
|
-
yield [r,
|
|
539
|
+
return new l(function* () {
|
|
540
|
+
for (const [r, [i, o]] of n)
|
|
541
|
+
yield [r, o];
|
|
505
542
|
});
|
|
506
543
|
}
|
|
507
544
|
unique() {
|
|
508
545
|
const e = this._elements;
|
|
509
|
-
return new
|
|
546
|
+
return new w(function* () {
|
|
510
547
|
const t = /* @__PURE__ */ new Map();
|
|
511
548
|
for (const [n, r] of e) {
|
|
512
|
-
const
|
|
513
|
-
|
|
549
|
+
const i = t.get(n) ?? /* @__PURE__ */ new Set();
|
|
550
|
+
i.has(r) || (i.add(r), t.set(n, i), yield [n, r]);
|
|
514
551
|
}
|
|
515
552
|
});
|
|
516
553
|
}
|
|
@@ -520,7 +557,7 @@ class d {
|
|
|
520
557
|
const n = e.get(t) ?? 0;
|
|
521
558
|
e.set(t, n + 1);
|
|
522
559
|
}
|
|
523
|
-
return new
|
|
560
|
+
return new l(function* () {
|
|
524
561
|
for (const [t, n] of e)
|
|
525
562
|
yield [t, n];
|
|
526
563
|
});
|
|
@@ -529,7 +566,7 @@ class d {
|
|
|
529
566
|
const e = /* @__PURE__ */ new Map();
|
|
530
567
|
for (const [t, n] of this._elements)
|
|
531
568
|
e.has(t) || e.set(t, n);
|
|
532
|
-
return new
|
|
569
|
+
return new l(function* () {
|
|
533
570
|
for (const [t, n] of e)
|
|
534
571
|
yield [t, n];
|
|
535
572
|
});
|
|
@@ -538,14 +575,14 @@ class d {
|
|
|
538
575
|
const e = /* @__PURE__ */ new Map();
|
|
539
576
|
for (const [t, n] of this._elements)
|
|
540
577
|
e.set(t, n);
|
|
541
|
-
return new
|
|
578
|
+
return new l(function* () {
|
|
542
579
|
for (const [t, n] of e)
|
|
543
580
|
yield [t, n];
|
|
544
581
|
});
|
|
545
582
|
}
|
|
546
583
|
keys() {
|
|
547
584
|
const e = this._elements;
|
|
548
|
-
return new
|
|
585
|
+
return new a(function* () {
|
|
549
586
|
const t = /* @__PURE__ */ new Set();
|
|
550
587
|
for (const [n] of e)
|
|
551
588
|
t.has(n) || (t.add(n), yield n);
|
|
@@ -556,7 +593,7 @@ class d {
|
|
|
556
593
|
}
|
|
557
594
|
values() {
|
|
558
595
|
const e = this._elements;
|
|
559
|
-
return new
|
|
596
|
+
return new a(function* () {
|
|
560
597
|
for (const [t, n] of e)
|
|
561
598
|
yield n;
|
|
562
599
|
});
|
|
@@ -584,22 +621,22 @@ class d {
|
|
|
584
621
|
return "AggregatedIterator";
|
|
585
622
|
}
|
|
586
623
|
}
|
|
587
|
-
class
|
|
624
|
+
class _ {
|
|
588
625
|
constructor(e) {
|
|
589
626
|
u(this, "_elements");
|
|
590
|
-
this._elements = new
|
|
627
|
+
this._elements = new a(e);
|
|
591
628
|
}
|
|
592
629
|
filter(e) {
|
|
593
|
-
return new
|
|
630
|
+
return new _(this._elements.filter(e));
|
|
594
631
|
}
|
|
595
632
|
map(e) {
|
|
596
|
-
return new
|
|
633
|
+
return new _(this._elements.map(e));
|
|
597
634
|
}
|
|
598
635
|
unique() {
|
|
599
|
-
return new
|
|
636
|
+
return new _(this._elements.unique());
|
|
600
637
|
}
|
|
601
638
|
groupBy(e) {
|
|
602
|
-
return new
|
|
639
|
+
return new w(this._elements.map((t, n) => [e(t, n), t]));
|
|
603
640
|
}
|
|
604
641
|
get [Symbol.toStringTag]() {
|
|
605
642
|
return "Aggregator";
|
|
@@ -608,37 +645,37 @@ class w {
|
|
|
608
645
|
class y {
|
|
609
646
|
constructor(e) {
|
|
610
647
|
u(this, "_elements");
|
|
611
|
-
this._elements = new
|
|
648
|
+
this._elements = new d(e);
|
|
612
649
|
}
|
|
613
650
|
async every(e) {
|
|
614
651
|
const t = /* @__PURE__ */ new Map();
|
|
615
652
|
for await (const [n, r] of this._elements) {
|
|
616
|
-
const [
|
|
617
|
-
|
|
653
|
+
const [i, o] = t.get(n) ?? [0, !0];
|
|
654
|
+
o && t.set(n, [i + 1, await e(n, r, i)]);
|
|
618
655
|
}
|
|
619
|
-
return new
|
|
620
|
-
for (const [n, [r,
|
|
621
|
-
yield [n,
|
|
656
|
+
return new l(function* () {
|
|
657
|
+
for (const [n, [r, i]] of t)
|
|
658
|
+
yield [n, i];
|
|
622
659
|
});
|
|
623
660
|
}
|
|
624
661
|
async some(e) {
|
|
625
662
|
const t = /* @__PURE__ */ new Map();
|
|
626
663
|
for await (const [n, r] of this._elements) {
|
|
627
|
-
const [
|
|
628
|
-
|
|
664
|
+
const [i, o] = t.get(n) ?? [0, !1];
|
|
665
|
+
o || t.set(n, [i + 1, await e(n, r, i)]);
|
|
629
666
|
}
|
|
630
|
-
return new
|
|
631
|
-
for (const [n, [r,
|
|
632
|
-
yield [n,
|
|
667
|
+
return new l(function* () {
|
|
668
|
+
for (const [n, [r, i]] of t)
|
|
669
|
+
yield [n, i];
|
|
633
670
|
});
|
|
634
671
|
}
|
|
635
672
|
filter(e) {
|
|
636
673
|
const t = this._elements;
|
|
637
674
|
return new y(async function* () {
|
|
638
675
|
const n = /* @__PURE__ */ new Map();
|
|
639
|
-
for await (const [r,
|
|
640
|
-
const
|
|
641
|
-
n.set(r,
|
|
676
|
+
for await (const [r, i] of t) {
|
|
677
|
+
const o = n.get(r) ?? 0;
|
|
678
|
+
n.set(r, o + 1), await e(r, i, o) && (yield [r, i]);
|
|
642
679
|
}
|
|
643
680
|
});
|
|
644
681
|
}
|
|
@@ -646,29 +683,29 @@ class y {
|
|
|
646
683
|
const t = this._elements;
|
|
647
684
|
return new y(async function* () {
|
|
648
685
|
const n = /* @__PURE__ */ new Map();
|
|
649
|
-
for await (const [r,
|
|
650
|
-
const
|
|
651
|
-
n.set(r,
|
|
686
|
+
for await (const [r, i] of t) {
|
|
687
|
+
const o = n.get(r) ?? 0;
|
|
688
|
+
n.set(r, o + 1), yield [r, await e(r, i, o)];
|
|
652
689
|
}
|
|
653
690
|
});
|
|
654
691
|
}
|
|
655
692
|
async reduce(e, t) {
|
|
656
693
|
const n = /* @__PURE__ */ new Map();
|
|
657
|
-
for await (const [r,
|
|
658
|
-
let
|
|
694
|
+
for await (const [r, i] of this._elements) {
|
|
695
|
+
let o, c;
|
|
659
696
|
if (n.has(r))
|
|
660
|
-
[
|
|
697
|
+
[o, c] = n.get(r), o += 1;
|
|
661
698
|
else if (t !== void 0)
|
|
662
|
-
|
|
699
|
+
o = 0, c = await t(r);
|
|
663
700
|
else {
|
|
664
|
-
n.set(r, [0,
|
|
701
|
+
n.set(r, [0, i]);
|
|
665
702
|
continue;
|
|
666
703
|
}
|
|
667
|
-
|
|
704
|
+
c = await e(r, c, i, o), n.set(r, [o, c]);
|
|
668
705
|
}
|
|
669
|
-
return new
|
|
670
|
-
for (const [r, [
|
|
671
|
-
yield [r,
|
|
706
|
+
return new l(function* () {
|
|
707
|
+
for (const [r, [i, o]] of n)
|
|
708
|
+
yield [r, o];
|
|
672
709
|
});
|
|
673
710
|
}
|
|
674
711
|
unique() {
|
|
@@ -676,8 +713,8 @@ class y {
|
|
|
676
713
|
return new y(async function* () {
|
|
677
714
|
const t = /* @__PURE__ */ new Map();
|
|
678
715
|
for await (const [n, r] of e) {
|
|
679
|
-
const
|
|
680
|
-
|
|
716
|
+
const i = t.get(n) ?? /* @__PURE__ */ new Set();
|
|
717
|
+
i.has(r) || (i.add(r), t.set(n, i), yield [n, r]);
|
|
681
718
|
}
|
|
682
719
|
});
|
|
683
720
|
}
|
|
@@ -687,7 +724,7 @@ class y {
|
|
|
687
724
|
const n = e.get(t) ?? 0;
|
|
688
725
|
e.set(t, n + 1);
|
|
689
726
|
}
|
|
690
|
-
return new
|
|
727
|
+
return new l(function* () {
|
|
691
728
|
for (const [t, n] of e)
|
|
692
729
|
yield [t, n];
|
|
693
730
|
});
|
|
@@ -696,7 +733,7 @@ class y {
|
|
|
696
733
|
const e = /* @__PURE__ */ new Map();
|
|
697
734
|
for await (const [t, n] of this._elements)
|
|
698
735
|
e.has(t) || e.set(t, n);
|
|
699
|
-
return new
|
|
736
|
+
return new l(function* () {
|
|
700
737
|
for (const [t, n] of e)
|
|
701
738
|
yield [t, n];
|
|
702
739
|
});
|
|
@@ -705,14 +742,14 @@ class y {
|
|
|
705
742
|
const e = /* @__PURE__ */ new Map();
|
|
706
743
|
for await (const [t, n] of this._elements)
|
|
707
744
|
e.set(t, n);
|
|
708
|
-
return new
|
|
745
|
+
return new l(function* () {
|
|
709
746
|
for (const [t, n] of e)
|
|
710
747
|
yield [t, n];
|
|
711
748
|
});
|
|
712
749
|
}
|
|
713
750
|
keys() {
|
|
714
751
|
const e = this._elements;
|
|
715
|
-
return new
|
|
752
|
+
return new d(async function* () {
|
|
716
753
|
const t = /* @__PURE__ */ new Set();
|
|
717
754
|
for await (const [n] of e)
|
|
718
755
|
t.has(n) || (t.add(n), yield n);
|
|
@@ -723,7 +760,7 @@ class y {
|
|
|
723
760
|
}
|
|
724
761
|
values() {
|
|
725
762
|
const e = this._elements;
|
|
726
|
-
return new
|
|
763
|
+
return new d(async function* () {
|
|
727
764
|
for await (const [t, n] of e)
|
|
728
765
|
yield n;
|
|
729
766
|
});
|
|
@@ -752,19 +789,19 @@ class y {
|
|
|
752
789
|
return "AggregatedAsyncIterator";
|
|
753
790
|
}
|
|
754
791
|
}
|
|
755
|
-
class
|
|
792
|
+
class p {
|
|
756
793
|
constructor(e) {
|
|
757
794
|
u(this, "_elements");
|
|
758
|
-
this._elements = new
|
|
795
|
+
this._elements = new d(e);
|
|
759
796
|
}
|
|
760
797
|
filter(e) {
|
|
761
|
-
return new
|
|
798
|
+
return new p(this._elements.filter(e));
|
|
762
799
|
}
|
|
763
800
|
map(e) {
|
|
764
|
-
return new
|
|
801
|
+
return new p(this._elements.map(e));
|
|
765
802
|
}
|
|
766
803
|
unique() {
|
|
767
|
-
return new
|
|
804
|
+
return new p(this._elements.unique());
|
|
768
805
|
}
|
|
769
806
|
groupBy(e) {
|
|
770
807
|
return new y(this._elements.map(async (t, n) => [await e(t, n), t]));
|
|
@@ -773,12 +810,69 @@ class _ {
|
|
|
773
810
|
return "AsyncAggregator";
|
|
774
811
|
}
|
|
775
812
|
}
|
|
776
|
-
|
|
813
|
+
var x = /* @__PURE__ */ ((s) => (s[s.Millisecond = 1] = "Millisecond", s[s.Second = 1e3] = "Second", s[s.Minute = 6e4] = "Minute", s[s.Hour = 36e5] = "Hour", s[s.Day = 864e5] = "Day", s[s.Week = 6048e5] = "Week", s[s.Month = 2592e6] = "Month", s[s.Year = 31536e6] = "Year", s))(x || {});
|
|
814
|
+
function L(s, e, t = 864e5) {
|
|
815
|
+
return s = new Date(s), e = new Date(e), Math.floor((e.getTime() - s.getTime()) / t);
|
|
816
|
+
}
|
|
817
|
+
function Q(s, e, t = 864e5) {
|
|
818
|
+
return s = new Date(s), e = new Date(e), new a(function* () {
|
|
819
|
+
const n = e.getTime();
|
|
820
|
+
let r = s.getTime();
|
|
821
|
+
for (; r < n; )
|
|
822
|
+
yield new Date(r), r += t;
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
function X(s, e = 864e5) {
|
|
826
|
+
return s = new Date(s), new Date(Math.floor(s.getTime() / e) * e);
|
|
827
|
+
}
|
|
828
|
+
class R {
|
|
829
|
+
constructor(e, t = 30) {
|
|
830
|
+
u(this, "_handle");
|
|
831
|
+
u(this, "_startTime");
|
|
832
|
+
u(this, "_isRunning");
|
|
833
|
+
u(this, "_start");
|
|
834
|
+
u(this, "_stop");
|
|
835
|
+
this._startTime = 0, this._isRunning = !1, E ? (this._start = () => {
|
|
836
|
+
e(this.elapsedTime), this._handle = window.requestAnimationFrame(this._start);
|
|
837
|
+
}, this._stop = () => window.cancelAnimationFrame(this._handle)) : (console.warn(
|
|
838
|
+
`Not a browser environment detected. Using setInterval@${t}fps instead of requestAnimationFrame...`
|
|
839
|
+
), this._start = () => {
|
|
840
|
+
const n = x.Second / t;
|
|
841
|
+
this._handle = setInterval(() => e(this.elapsedTime), n);
|
|
842
|
+
}, this._stop = () => clearInterval(this._handle));
|
|
843
|
+
}
|
|
844
|
+
get startTime() {
|
|
845
|
+
return this._startTime;
|
|
846
|
+
}
|
|
847
|
+
get isRunning() {
|
|
848
|
+
return this._isRunning;
|
|
849
|
+
}
|
|
850
|
+
get elapsedTime() {
|
|
851
|
+
return performance.now() - this._startTime;
|
|
852
|
+
}
|
|
853
|
+
start(e = 0) {
|
|
854
|
+
if (this._isRunning)
|
|
855
|
+
throw new m("The game loop has already been started.");
|
|
856
|
+
this._startTime = performance.now() - e, this._start(), this._isRunning = !0;
|
|
857
|
+
}
|
|
858
|
+
stop() {
|
|
859
|
+
if (!this._isRunning)
|
|
860
|
+
throw new m("The game loop hadn't yet started.");
|
|
861
|
+
if (!this._handle)
|
|
862
|
+
throw new g();
|
|
863
|
+
this._stop(), this._handle = void 0, this._isRunning = !1;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
class Z {
|
|
777
867
|
constructor(e = !0) {
|
|
778
868
|
u(this, "_preferPersistence");
|
|
779
869
|
u(this, "_volatile");
|
|
780
870
|
u(this, "_persistent");
|
|
781
|
-
this._preferPersistence = e,
|
|
871
|
+
if (this._preferPersistence = e, !E)
|
|
872
|
+
throw new A(
|
|
873
|
+
"The `JSONStorage` class can only be instantiated within a browser environment."
|
|
874
|
+
);
|
|
875
|
+
this._volatile = window.sessionStorage, this._persistent = window.localStorage;
|
|
782
876
|
}
|
|
783
877
|
_get(e, t, n) {
|
|
784
878
|
const r = e.getItem(t);
|
|
@@ -908,31 +1002,10 @@ class C {
|
|
|
908
1002
|
this._volatile.removeItem(e), this._persistent.removeItem(e);
|
|
909
1003
|
}
|
|
910
1004
|
get [Symbol.toStringTag]() {
|
|
911
|
-
return "
|
|
1005
|
+
return "JSONStorage";
|
|
912
1006
|
}
|
|
913
1007
|
}
|
|
914
|
-
class
|
|
915
|
-
constructor() {
|
|
916
|
-
u(this, "_subscribers");
|
|
917
|
-
this._subscribers = [];
|
|
918
|
-
}
|
|
919
|
-
add(e) {
|
|
920
|
-
this._subscribers.push(e);
|
|
921
|
-
}
|
|
922
|
-
remove(e) {
|
|
923
|
-
const t = this._subscribers.indexOf(e);
|
|
924
|
-
if (t < 0)
|
|
925
|
-
throw new k("Unable to remove the requested subscriber. It was not found.");
|
|
926
|
-
this._subscribers.splice(t, 1);
|
|
927
|
-
}
|
|
928
|
-
call(...e) {
|
|
929
|
-
return this._subscribers.slice().map((t) => t(...e));
|
|
930
|
-
}
|
|
931
|
-
get [Symbol.toStringTag]() {
|
|
932
|
-
return "Subscribers";
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
class g {
|
|
1008
|
+
class F {
|
|
936
1009
|
constructor(e) {
|
|
937
1010
|
u(this, "_isPending");
|
|
938
1011
|
u(this, "_isFulfilled");
|
|
@@ -966,15 +1039,15 @@ class g {
|
|
|
966
1039
|
return "SmartPromise";
|
|
967
1040
|
}
|
|
968
1041
|
}
|
|
969
|
-
class
|
|
1042
|
+
class O extends F {
|
|
970
1043
|
constructor(t, n) {
|
|
971
|
-
let r,
|
|
972
|
-
super((
|
|
973
|
-
r =
|
|
1044
|
+
let r, i;
|
|
1045
|
+
super((o, c) => {
|
|
1046
|
+
r = o, i = c;
|
|
974
1047
|
});
|
|
975
1048
|
u(this, "_resolve");
|
|
976
1049
|
u(this, "_reject");
|
|
977
|
-
this._promise.then(t, n), this._resolve = r, this._reject =
|
|
1050
|
+
this._promise.then(t, n), this._resolve = r, this._reject = i;
|
|
978
1051
|
}
|
|
979
1052
|
get resolve() {
|
|
980
1053
|
return this._resolve;
|
|
@@ -989,22 +1062,112 @@ class Y extends g {
|
|
|
989
1062
|
return "DeferredPromise";
|
|
990
1063
|
}
|
|
991
1064
|
}
|
|
992
|
-
class
|
|
1065
|
+
class U extends F {
|
|
993
1066
|
constructor(e, t) {
|
|
994
1067
|
super((n, r) => {
|
|
995
|
-
const
|
|
996
|
-
clearTimeout(
|
|
997
|
-
},
|
|
998
|
-
clearTimeout(
|
|
999
|
-
},
|
|
1000
|
-
e(
|
|
1068
|
+
const i = (v) => {
|
|
1069
|
+
clearTimeout(b), n(v);
|
|
1070
|
+
}, o = (v) => {
|
|
1071
|
+
clearTimeout(b), r(v);
|
|
1072
|
+
}, b = setTimeout(() => o(new C("The operation has timed out.")), t);
|
|
1073
|
+
e(i, o);
|
|
1001
1074
|
});
|
|
1002
1075
|
}
|
|
1003
1076
|
get [Symbol.toStringTag]() {
|
|
1004
1077
|
return "TimedPromise";
|
|
1005
1078
|
}
|
|
1006
1079
|
}
|
|
1007
|
-
class
|
|
1080
|
+
class P {
|
|
1081
|
+
constructor() {
|
|
1082
|
+
u(this, "_subscribers");
|
|
1083
|
+
this._subscribers = [];
|
|
1084
|
+
}
|
|
1085
|
+
subscribe(e) {
|
|
1086
|
+
return this._subscribers.push(e), () => {
|
|
1087
|
+
const t = this._subscribers.indexOf(e);
|
|
1088
|
+
if (t < 0)
|
|
1089
|
+
throw new q("Unable to unsubscribe the required subscriber. The subscription was already unsubscribed.");
|
|
1090
|
+
this._subscribers.splice(t, 1);
|
|
1091
|
+
};
|
|
1092
|
+
}
|
|
1093
|
+
publish(...e) {
|
|
1094
|
+
return this._subscribers.slice().map((t) => t(...e));
|
|
1095
|
+
}
|
|
1096
|
+
get [Symbol.toStringTag]() {
|
|
1097
|
+
return "Publisher";
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
class ee extends R {
|
|
1101
|
+
constructor(t = x.Second) {
|
|
1102
|
+
super((n) => this._publisher.publish(n), t);
|
|
1103
|
+
u(this, "_publisher");
|
|
1104
|
+
this._publisher = new P();
|
|
1105
|
+
}
|
|
1106
|
+
start(t = 0) {
|
|
1107
|
+
if (this._isRunning)
|
|
1108
|
+
throw new m("The clock has already been started.");
|
|
1109
|
+
super.start(t);
|
|
1110
|
+
}
|
|
1111
|
+
stop() {
|
|
1112
|
+
if (!this._isRunning)
|
|
1113
|
+
throw new m("The clock hadn't yet started.");
|
|
1114
|
+
super.stop();
|
|
1115
|
+
}
|
|
1116
|
+
onTick(t, n = 0) {
|
|
1117
|
+
if (n < 0)
|
|
1118
|
+
throw new M("The tick step must be a non-negative number.");
|
|
1119
|
+
if (n === 0)
|
|
1120
|
+
return this._publisher.subscribe(t);
|
|
1121
|
+
let r = 0;
|
|
1122
|
+
return this._publisher.subscribe((i) => {
|
|
1123
|
+
i - r < n || (t(i), r = i);
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
class te extends R {
|
|
1128
|
+
constructor(t, n = x.Second) {
|
|
1129
|
+
super((i) => {
|
|
1130
|
+
this._duration -= i;
|
|
1131
|
+
const o = this.remainingTime;
|
|
1132
|
+
this._publisher.publish(o), o <= 0 && this.stop();
|
|
1133
|
+
}, n);
|
|
1134
|
+
u(this, "_deferrer");
|
|
1135
|
+
u(this, "_publisher");
|
|
1136
|
+
u(this, "_duration");
|
|
1137
|
+
this._publisher = new P(), this._duration = t;
|
|
1138
|
+
}
|
|
1139
|
+
get duration() {
|
|
1140
|
+
return this._duration;
|
|
1141
|
+
}
|
|
1142
|
+
get remainingTime() {
|
|
1143
|
+
return this._duration - this.elapsedTime;
|
|
1144
|
+
}
|
|
1145
|
+
start(t = this.duration) {
|
|
1146
|
+
if (this._isRunning)
|
|
1147
|
+
throw new m("The countdown has already been started.");
|
|
1148
|
+
if (this._deferrer)
|
|
1149
|
+
throw new g();
|
|
1150
|
+
return this._deferrer = new O(() => this.stop()), super.start(this.duration - t), this._deferrer;
|
|
1151
|
+
}
|
|
1152
|
+
stop(t) {
|
|
1153
|
+
if (!this._isRunning)
|
|
1154
|
+
throw new m("The countdown hadn't yet started.");
|
|
1155
|
+
if (!this._deferrer)
|
|
1156
|
+
throw new g();
|
|
1157
|
+
super.stop(), t !== void 0 ? this._deferrer.reject(t) : this._deferrer.resolve(), this._deferrer = void 0;
|
|
1158
|
+
}
|
|
1159
|
+
onTick(t, n = 0) {
|
|
1160
|
+
if (n < 0)
|
|
1161
|
+
throw new M("The tick step must be a non-negative number.");
|
|
1162
|
+
if (n === 0)
|
|
1163
|
+
return this._publisher.subscribe(t);
|
|
1164
|
+
let r = 0;
|
|
1165
|
+
return this._publisher.subscribe((i) => {
|
|
1166
|
+
r - i < n || (t(i), r = i);
|
|
1167
|
+
});
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
class I {
|
|
1008
1171
|
static Boolean(e = 0.5) {
|
|
1009
1172
|
return Math.random() < e;
|
|
1010
1173
|
}
|
|
@@ -1016,51 +1179,36 @@ class v {
|
|
|
1016
1179
|
}
|
|
1017
1180
|
static Index(e) {
|
|
1018
1181
|
if (e.length === 0)
|
|
1019
|
-
throw new
|
|
1182
|
+
throw new f("You must provide at least one element.");
|
|
1020
1183
|
return this.Integer(e.length);
|
|
1021
1184
|
}
|
|
1022
1185
|
static Choice(e) {
|
|
1023
|
-
return e[
|
|
1186
|
+
return e[I.Index(e)];
|
|
1024
1187
|
}
|
|
1025
1188
|
// eslint-disable-next-line no-useless-constructor
|
|
1026
1189
|
constructor() {
|
|
1027
1190
|
}
|
|
1028
1191
|
}
|
|
1029
|
-
async function
|
|
1192
|
+
async function ne(s) {
|
|
1030
1193
|
return new Promise((e, t) => setTimeout(e, s));
|
|
1031
1194
|
}
|
|
1032
|
-
async function
|
|
1195
|
+
async function re() {
|
|
1033
1196
|
return new Promise((s, e) => requestAnimationFrame(() => s()));
|
|
1034
1197
|
}
|
|
1035
|
-
|
|
1036
|
-
function B(s, e, t = 864e5) {
|
|
1037
|
-
return s = new Date(s), e = new Date(e), Math.floor((e.getTime() - s.getTime()) / t);
|
|
1038
|
-
}
|
|
1039
|
-
function K(s, e, t = 864e5) {
|
|
1040
|
-
return s = new Date(s), e = new Date(e), new c(function* () {
|
|
1041
|
-
const n = e.getTime();
|
|
1042
|
-
let r = s.getTime();
|
|
1043
|
-
for (; r < n; )
|
|
1044
|
-
yield new Date(r), r += t;
|
|
1045
|
-
});
|
|
1046
|
-
}
|
|
1047
|
-
function H(s, e = 864e5) {
|
|
1048
|
-
return s = new Date(s), new Date(Math.floor(s.getTime() / e) * e);
|
|
1049
|
-
}
|
|
1050
|
-
function W(s, e = "text/javascript") {
|
|
1198
|
+
function se(s, e = "text/javascript") {
|
|
1051
1199
|
return new Promise((t, n) => {
|
|
1052
1200
|
const r = document.createElement("script");
|
|
1053
1201
|
r.async = !0, r.defer = !0, r.src = s, r.type = e, r.onload = () => t(), r.onerror = () => n(), document.body.appendChild(r);
|
|
1054
1202
|
});
|
|
1055
1203
|
}
|
|
1056
|
-
function
|
|
1057
|
-
return new
|
|
1204
|
+
function ie(...s) {
|
|
1205
|
+
return new a(function* () {
|
|
1058
1206
|
for (const e of s)
|
|
1059
1207
|
for (const t of e)
|
|
1060
1208
|
yield t;
|
|
1061
1209
|
});
|
|
1062
1210
|
}
|
|
1063
|
-
function
|
|
1211
|
+
function oe(s) {
|
|
1064
1212
|
if (Array.isArray(s))
|
|
1065
1213
|
return s.length;
|
|
1066
1214
|
let e = 0;
|
|
@@ -1068,21 +1216,21 @@ function L(s) {
|
|
|
1068
1216
|
e += 1;
|
|
1069
1217
|
return e;
|
|
1070
1218
|
}
|
|
1071
|
-
function
|
|
1072
|
-
return new
|
|
1219
|
+
function ue(s) {
|
|
1220
|
+
return new a(function* () {
|
|
1073
1221
|
let e = 0;
|
|
1074
1222
|
for (const t of s)
|
|
1075
1223
|
yield [e, t], e += 1;
|
|
1076
1224
|
});
|
|
1077
1225
|
}
|
|
1078
|
-
function
|
|
1079
|
-
return new
|
|
1226
|
+
function ae(s, e, t = 1) {
|
|
1227
|
+
return new a(function* () {
|
|
1080
1228
|
e === void 0 && (e = s, s = 0), s > e && (t = t ?? -1);
|
|
1081
1229
|
for (let n = s; n < e; n += t)
|
|
1082
1230
|
yield n;
|
|
1083
1231
|
});
|
|
1084
1232
|
}
|
|
1085
|
-
function
|
|
1233
|
+
function ce(s) {
|
|
1086
1234
|
const e = Array.from(s);
|
|
1087
1235
|
for (let t = e.length - 1; t > 0; t -= 1) {
|
|
1088
1236
|
const n = Math.floor(Math.random() * (t + 1));
|
|
@@ -1090,46 +1238,46 @@ function Z(s) {
|
|
|
1090
1238
|
}
|
|
1091
1239
|
return e;
|
|
1092
1240
|
}
|
|
1093
|
-
function
|
|
1094
|
-
return new
|
|
1241
|
+
function le(s) {
|
|
1242
|
+
return new a(function* () {
|
|
1095
1243
|
const e = /* @__PURE__ */ new Set();
|
|
1096
1244
|
for (const t of s)
|
|
1097
1245
|
e.has(t) || (e.add(t), yield t);
|
|
1098
1246
|
});
|
|
1099
1247
|
}
|
|
1100
|
-
function
|
|
1101
|
-
return new
|
|
1248
|
+
function N(s, e) {
|
|
1249
|
+
return new a(function* () {
|
|
1102
1250
|
const t = s[Symbol.iterator](), n = e[Symbol.iterator]();
|
|
1103
1251
|
for (; ; ) {
|
|
1104
|
-
const r = t.next(),
|
|
1105
|
-
if (r.done ||
|
|
1252
|
+
const r = t.next(), i = n.next();
|
|
1253
|
+
if (r.done || i.done)
|
|
1106
1254
|
break;
|
|
1107
|
-
yield [r.value,
|
|
1255
|
+
yield [r.value, i.value];
|
|
1108
1256
|
}
|
|
1109
1257
|
});
|
|
1110
1258
|
}
|
|
1111
|
-
function
|
|
1259
|
+
function he(s, e) {
|
|
1112
1260
|
if (e === void 0) {
|
|
1113
|
-
let
|
|
1114
|
-
for (const
|
|
1115
|
-
|
|
1116
|
-
if (
|
|
1117
|
-
throw new
|
|
1118
|
-
return
|
|
1261
|
+
let i = 0, o = 0;
|
|
1262
|
+
for (const c of s)
|
|
1263
|
+
i += c, o += 1;
|
|
1264
|
+
if (o === 0)
|
|
1265
|
+
throw new f("You must provide at least one value.");
|
|
1266
|
+
return i / o;
|
|
1119
1267
|
}
|
|
1120
1268
|
let t = 0, n = 0, r = 0;
|
|
1121
|
-
for (const [
|
|
1122
|
-
if (
|
|
1123
|
-
throw new
|
|
1124
|
-
t +=
|
|
1269
|
+
for (const [i, o] of N(s, e)) {
|
|
1270
|
+
if (o <= 0)
|
|
1271
|
+
throw new f(`The weight for the value #${r} must be greater than zero.`);
|
|
1272
|
+
t += i * o, n += o, r += 1;
|
|
1125
1273
|
}
|
|
1126
1274
|
if (r === 0)
|
|
1127
|
-
throw new
|
|
1275
|
+
throw new f("You must provide at least one value and weight.");
|
|
1128
1276
|
if (n > 0)
|
|
1129
|
-
throw new
|
|
1277
|
+
throw new f("The sum of weights must be greater than zero.");
|
|
1130
1278
|
return t / n;
|
|
1131
1279
|
}
|
|
1132
|
-
function
|
|
1280
|
+
function fe(s) {
|
|
1133
1281
|
let e = 0;
|
|
1134
1282
|
for (let t = 0; t < s.length; t += 1) {
|
|
1135
1283
|
const n = s.charCodeAt(t);
|
|
@@ -1137,60 +1285,69 @@ function ee(s) {
|
|
|
1137
1285
|
}
|
|
1138
1286
|
return e;
|
|
1139
1287
|
}
|
|
1140
|
-
function
|
|
1288
|
+
function de(s) {
|
|
1141
1289
|
let e = 0;
|
|
1142
1290
|
for (const t of s)
|
|
1143
1291
|
e += t;
|
|
1144
1292
|
return e;
|
|
1145
1293
|
}
|
|
1146
|
-
function
|
|
1294
|
+
function me(s) {
|
|
1147
1295
|
return `${s.charAt(0).toUpperCase()}${s.slice(1)}`;
|
|
1148
1296
|
}
|
|
1149
|
-
const
|
|
1297
|
+
const we = "2.0.0-rc.1";
|
|
1150
1298
|
export {
|
|
1151
1299
|
y as AggregatedAsyncIterator,
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
X as
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1300
|
+
w as AggregatedIterator,
|
|
1301
|
+
_ as Aggregator,
|
|
1302
|
+
p as AsyncAggregator,
|
|
1303
|
+
ee as Clock,
|
|
1304
|
+
te as Countdown,
|
|
1305
|
+
O as DeferredPromise,
|
|
1306
|
+
h as Exception,
|
|
1307
|
+
g as FatalErrorException,
|
|
1308
|
+
T as FileException,
|
|
1309
|
+
z as FileExistsException,
|
|
1310
|
+
V as FileNotFoundException,
|
|
1311
|
+
R as GameLoop,
|
|
1312
|
+
Z as JSONStorage,
|
|
1313
|
+
B as KeyException,
|
|
1314
|
+
K as NetworkException,
|
|
1315
|
+
Y as NotImplementedException,
|
|
1316
|
+
G as PermissionException,
|
|
1317
|
+
P as Publisher,
|
|
1318
|
+
I as Random,
|
|
1319
|
+
M as RangeException,
|
|
1320
|
+
l as ReducedIterator,
|
|
1321
|
+
q as ReferenceException,
|
|
1322
|
+
m as RuntimeException,
|
|
1323
|
+
d as SmartAsyncIterator,
|
|
1324
|
+
a as SmartIterator,
|
|
1325
|
+
F as SmartPromise,
|
|
1326
|
+
x as TimeUnit,
|
|
1327
|
+
U as TimedPromise,
|
|
1328
|
+
C as TimeoutException,
|
|
1329
|
+
H as TypeException,
|
|
1330
|
+
we as VERSION,
|
|
1331
|
+
f as ValueException,
|
|
1332
|
+
he as average,
|
|
1333
|
+
me as capitalize,
|
|
1334
|
+
ie as chain,
|
|
1335
|
+
oe as count,
|
|
1336
|
+
L as dateDifference,
|
|
1337
|
+
Q as dateRange,
|
|
1338
|
+
X as dateRound,
|
|
1339
|
+
ne as delay,
|
|
1340
|
+
ue as enumerate,
|
|
1341
|
+
fe as hash,
|
|
1342
|
+
E as isBrowser,
|
|
1343
|
+
J as isNode,
|
|
1344
|
+
W as isWebWorker,
|
|
1345
|
+
se as loadScript,
|
|
1346
|
+
re as nextAnimationFrame,
|
|
1347
|
+
ae as range,
|
|
1348
|
+
ce as shuffle,
|
|
1349
|
+
de as sum,
|
|
1350
|
+
le as unique,
|
|
1351
|
+
N as zip
|
|
1195
1352
|
};
|
|
1196
1353
|
//# sourceMappingURL=core.js.map
|