@byloth/core 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/core.cjs +6 -0
- package/dist/core.cjs.map +1 -0
- package/dist/{core.js → core.esm.js} +1098 -779
- package/dist/core.esm.js.map +1 -0
- package/dist/core.global.js +6 -0
- package/dist/core.global.js.map +1 -0
- package/dist/core.umd.cjs +3 -3
- package/dist/core.umd.cjs.map +1 -1
- package/package.json +15 -11
- package/src/core/types.ts +43 -10
- package/src/index.ts +9 -2
- package/src/models/aggregators/aggregated-async-iterator.ts +5 -0
- package/src/models/aggregators/aggregated-iterator.ts +5 -0
- package/src/models/aggregators/reduced-iterator.ts +18 -5
- package/src/models/aggregators/types.ts +35 -0
- package/src/models/callbacks/callable-object.ts +7 -0
- package/src/models/callbacks/publisher.ts +16 -12
- package/src/models/callbacks/switchable-callback.ts +9 -1
- package/src/models/callbacks/types.ts +35 -0
- package/src/models/collections/index.ts +4 -0
- package/src/models/collections/map-view.ts +206 -0
- package/src/models/collections/set-view.ts +204 -0
- package/src/models/collections/types.ts +25 -0
- package/src/models/exceptions/core.ts +10 -1
- package/src/models/exceptions/index.ts +40 -1
- package/src/models/index.ts +1 -0
- package/src/models/iterators/smart-async-iterator.ts +5 -0
- package/src/models/iterators/smart-iterator.ts +5 -0
- package/src/models/iterators/types.ts +79 -1
- package/src/models/json/json-storage.ts +4 -1
- package/src/models/json/types.ts +1 -1
- package/src/models/promises/deferred-promise.ts +5 -0
- package/src/models/promises/smart-promise.ts +5 -0
- package/src/models/promises/timed-promise.ts +5 -0
- package/src/models/promises/types.ts +30 -0
- package/src/models/timers/clock.ts +3 -0
- package/src/models/timers/countdown.ts +5 -0
- package/src/models/timers/game-loop.ts +3 -0
- package/src/models/types.ts +3 -8
- package/src/utils/async.ts +15 -0
- package/src/utils/curve.ts +1 -1
- package/src/utils/date.ts +36 -6
- package/src/utils/dom.ts +5 -0
- package/src/utils/iterator.ts +43 -3
- package/src/utils/math.ts +15 -0
- package/src/utils/random.ts +4 -0
- package/src/utils/string.ts +5 -0
- package/dist/core.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var a = (i,
|
|
4
|
-
const
|
|
1
|
+
var Ye = Object.defineProperty;
|
|
2
|
+
var Le = (i, n, e) => n in i ? Ye(i, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[n] = e;
|
|
3
|
+
var a = (i, n, e) => Le(i, typeof n != "symbol" ? n + "" : n, e);
|
|
4
|
+
const De = typeof window < "u" && typeof window.document < "u";
|
|
5
5
|
var I;
|
|
6
|
-
const
|
|
6
|
+
const nt = typeof process < "u" && !!((I = process.versions) != null && I.node);
|
|
7
7
|
var A;
|
|
8
|
-
const
|
|
8
|
+
const st = typeof self == "object" && ((A = self.constructor) == null ? void 0 : A.name) === "DedicatedWorkerGlobalScope";
|
|
9
9
|
var N, O;
|
|
10
|
-
class
|
|
10
|
+
class c extends (O = Error, N = Symbol.toStringTag, O) {
|
|
11
11
|
/**
|
|
12
12
|
* Initializes a new instance of the {@link Exception} class.
|
|
13
13
|
*
|
|
@@ -24,14 +24,14 @@ class u extends (O = Error, N = Symbol.toStringTag, O) {
|
|
|
24
24
|
* @param cause The previous caught error that caused this one, if any.
|
|
25
25
|
* @param name The name of the exception. Default is `"Exception"`.
|
|
26
26
|
*/
|
|
27
|
-
constructor(e,
|
|
27
|
+
constructor(e, t, s = "Exception") {
|
|
28
28
|
super(e);
|
|
29
29
|
a(this, N, "Exception");
|
|
30
|
-
this.cause =
|
|
30
|
+
this.cause = t, this.name = s, t && (t instanceof Error ? this.stack += `
|
|
31
31
|
|
|
32
|
-
Caused by ${
|
|
32
|
+
Caused by ${t.stack}` : this.stack += `
|
|
33
33
|
|
|
34
|
-
Caused by ${
|
|
34
|
+
Caused by ${t}`);
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* A static method to convert a generic caught error, ensuring it's an instance of the {@link Exception} class.
|
|
@@ -56,17 +56,17 @@ Caused by ${n}`);
|
|
|
56
56
|
* @returns An instance of the {@link Exception} class.
|
|
57
57
|
*/
|
|
58
58
|
static FromUnknown(e) {
|
|
59
|
-
if (e instanceof
|
|
59
|
+
if (e instanceof c)
|
|
60
60
|
return e;
|
|
61
61
|
if (e instanceof Error) {
|
|
62
|
-
const
|
|
63
|
-
return
|
|
62
|
+
const t = new c(e.message);
|
|
63
|
+
return t.stack = e.stack, t.name = e.name, t;
|
|
64
64
|
}
|
|
65
|
-
return new
|
|
65
|
+
return new c(`${e}`);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
var $,
|
|
69
|
-
class
|
|
68
|
+
var $, z;
|
|
69
|
+
class g extends (z = c, $ = Symbol.toStringTag, z) {
|
|
70
70
|
/**
|
|
71
71
|
* Initializes a new instance of the {@link FatalErrorException} class.
|
|
72
72
|
*
|
|
@@ -83,14 +83,14 @@ class x extends (q = u, $ = Symbol.toStringTag, q) {
|
|
|
83
83
|
* @param cause The previous caught error that caused this one, if any.
|
|
84
84
|
* @param name The name of the exception. Default is `"FatalErrorException"`.
|
|
85
85
|
*/
|
|
86
|
-
constructor(e,
|
|
86
|
+
constructor(e, t, s = "FatalErrorException") {
|
|
87
87
|
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.");
|
|
88
|
-
super(e,
|
|
88
|
+
super(e, t, s);
|
|
89
89
|
a(this, $, "FatalErrorException");
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
var
|
|
93
|
-
class
|
|
92
|
+
var q, D;
|
|
93
|
+
class Ve extends (D = g, q = Symbol.toStringTag, D) {
|
|
94
94
|
/**
|
|
95
95
|
* Initializes a new instance of the {@link NotImplementedException} class.
|
|
96
96
|
*
|
|
@@ -107,14 +107,14 @@ class Be extends (z = x, D = Symbol.toStringTag, z) {
|
|
|
107
107
|
* @param cause The previous caught error that caused this one, if any.
|
|
108
108
|
* @param name The name of the exception. Default is `"NotImplementedException"`.
|
|
109
109
|
*/
|
|
110
|
-
constructor(e,
|
|
110
|
+
constructor(e, t, s = "NotImplementedException") {
|
|
111
111
|
e === void 0 && (e = "This feature isn't implemented yet. Please, try again later.");
|
|
112
|
-
super(e,
|
|
113
|
-
a(this,
|
|
112
|
+
super(e, t, s);
|
|
113
|
+
a(this, q, "NotImplementedException");
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
var B, J;
|
|
117
|
-
class
|
|
117
|
+
class Be extends (J = c, B = Symbol.toStringTag, J) {
|
|
118
118
|
/**
|
|
119
119
|
* Initializes a new instance of the {@link FileException} class.
|
|
120
120
|
*
|
|
@@ -131,13 +131,13 @@ class $e extends (J = u, B = Symbol.toStringTag, J) {
|
|
|
131
131
|
* @param cause The previous caught error that caused this one, if any.
|
|
132
132
|
* @param name The name of the exception. Default is `"FileException"`.
|
|
133
133
|
*/
|
|
134
|
-
constructor(e,
|
|
135
|
-
super(e,
|
|
134
|
+
constructor(e, t, s = "FileException") {
|
|
135
|
+
super(e, t, s);
|
|
136
136
|
a(this, B, "FileException");
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
var Y, L;
|
|
140
|
-
class
|
|
140
|
+
class rt extends (L = Be, Y = Symbol.toStringTag, L) {
|
|
141
141
|
/**
|
|
142
142
|
* Initializes a new instance of the {@link FileExistsException} class.
|
|
143
143
|
*
|
|
@@ -154,13 +154,13 @@ class et extends (L = $e, Y = Symbol.toStringTag, L) {
|
|
|
154
154
|
* @param cause The previous caught error that caused this one, if any.
|
|
155
155
|
* @param name The name of the exception. Default is `"FileExistsException"`.
|
|
156
156
|
*/
|
|
157
|
-
constructor(e,
|
|
158
|
-
super(e,
|
|
157
|
+
constructor(e, t, s = "FileExistsException") {
|
|
158
|
+
super(e, t, s);
|
|
159
159
|
a(this, Y, "FileExistsException");
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
var
|
|
163
|
-
class
|
|
162
|
+
var V, G;
|
|
163
|
+
class it extends (G = Be, V = Symbol.toStringTag, G) {
|
|
164
164
|
/**
|
|
165
165
|
* Initializes a new instance of the {@link FileNotFoundException} class.
|
|
166
166
|
*
|
|
@@ -177,13 +177,13 @@ class tt extends (K = $e, G = Symbol.toStringTag, K) {
|
|
|
177
177
|
* @param cause The previous caught error that caused this one, if any.
|
|
178
178
|
* @param name The name of the exception. Default is `"FileNotFoundException"`.
|
|
179
179
|
*/
|
|
180
|
-
constructor(e,
|
|
181
|
-
super(e,
|
|
182
|
-
a(this,
|
|
180
|
+
constructor(e, t, s = "FileNotFoundException") {
|
|
181
|
+
super(e, t, s);
|
|
182
|
+
a(this, V, "FileNotFoundException");
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
-
var
|
|
186
|
-
class
|
|
185
|
+
var K, H;
|
|
186
|
+
class y extends (H = c, K = Symbol.toStringTag, H) {
|
|
187
187
|
/**
|
|
188
188
|
* Initializes a new instance of the {@link KeyException} class.
|
|
189
189
|
*
|
|
@@ -200,13 +200,13 @@ class _ extends (Q = u, H = Symbol.toStringTag, Q) {
|
|
|
200
200
|
* @param cause The previous caught error that caused this one, if any.
|
|
201
201
|
* @param name The name of the exception. Default is `"KeyException"`.
|
|
202
202
|
*/
|
|
203
|
-
constructor(e,
|
|
204
|
-
super(e,
|
|
205
|
-
a(this,
|
|
203
|
+
constructor(e, t, s = "KeyException") {
|
|
204
|
+
super(e, t, s);
|
|
205
|
+
a(this, K, "KeyException");
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
-
var
|
|
209
|
-
class
|
|
208
|
+
var Q, X;
|
|
209
|
+
class ot extends (X = c, Q = Symbol.toStringTag, X) {
|
|
210
210
|
/**
|
|
211
211
|
* Initializes a new instance of the {@link NetworkException} class.
|
|
212
212
|
*
|
|
@@ -223,13 +223,13 @@ class nt extends (X = u, V = Symbol.toStringTag, X) {
|
|
|
223
223
|
* @param cause The previous caught error that caused this one, if any.
|
|
224
224
|
* @param name The name of the exception. Default is `"NetworkException"`.
|
|
225
225
|
*/
|
|
226
|
-
constructor(e,
|
|
227
|
-
super(e,
|
|
228
|
-
a(this,
|
|
226
|
+
constructor(e, t, s = "NetworkException") {
|
|
227
|
+
super(e, t, s);
|
|
228
|
+
a(this, Q, "NetworkException");
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
var Z, W;
|
|
232
|
-
class
|
|
232
|
+
class at extends (W = c, Z = Symbol.toStringTag, W) {
|
|
233
233
|
/**
|
|
234
234
|
* Initializes a new instance of the {@link PermissionException} class.
|
|
235
235
|
*
|
|
@@ -246,13 +246,13 @@ class st extends (W = u, Z = Symbol.toStringTag, W) {
|
|
|
246
246
|
* @param cause The previous caught error that caused this one, if any.
|
|
247
247
|
* @param name The name of the exception. Default is `"PermissionException"`.
|
|
248
248
|
*/
|
|
249
|
-
constructor(e,
|
|
250
|
-
super(e,
|
|
249
|
+
constructor(e, t, s = "PermissionException") {
|
|
250
|
+
super(e, t, s);
|
|
251
251
|
a(this, Z, "PermissionException");
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
var U, ee;
|
|
255
|
-
class C extends (ee =
|
|
255
|
+
class C extends (ee = c, U = Symbol.toStringTag, ee) {
|
|
256
256
|
/**
|
|
257
257
|
* Initializes a new instance of the {@link ReferenceException} class.
|
|
258
258
|
*
|
|
@@ -269,13 +269,13 @@ class C extends (ee = u, U = Symbol.toStringTag, ee) {
|
|
|
269
269
|
* @param cause The previous caught error that caused this one, if any.
|
|
270
270
|
* @param name The name of the exception. Default is `"ReferenceException"`.
|
|
271
271
|
*/
|
|
272
|
-
constructor(e,
|
|
273
|
-
super(e,
|
|
272
|
+
constructor(e, t, s = "ReferenceException") {
|
|
273
|
+
super(e, t, s);
|
|
274
274
|
a(this, U, "ReferenceException");
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
277
|
var te, ne;
|
|
278
|
-
class
|
|
278
|
+
class p extends (ne = c, te = Symbol.toStringTag, ne) {
|
|
279
279
|
/**
|
|
280
280
|
* Initializes a new instance of the {@link RuntimeException} class.
|
|
281
281
|
*
|
|
@@ -292,13 +292,13 @@ class y extends (ne = u, te = Symbol.toStringTag, ne) {
|
|
|
292
292
|
* @param cause The previous caught error that caused this one, if any.
|
|
293
293
|
* @param name The name of the exception. Default is `"RuntimeException"`.
|
|
294
294
|
*/
|
|
295
|
-
constructor(e,
|
|
296
|
-
super(e,
|
|
295
|
+
constructor(e, t, s = "RuntimeException") {
|
|
296
|
+
super(e, t, s);
|
|
297
297
|
a(this, te, "RuntimeException");
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
var se, re;
|
|
301
|
-
class
|
|
301
|
+
class Ge extends (re = p, se = Symbol.toStringTag, re) {
|
|
302
302
|
/**
|
|
303
303
|
* Initializes a new instance of the {@link EnvironmentException} class.
|
|
304
304
|
*
|
|
@@ -315,13 +315,13 @@ class Je extends (re = y, se = Symbol.toStringTag, re) {
|
|
|
315
315
|
* @param cause The previous caught error that caused this one, if any.
|
|
316
316
|
* @param name The name of the exception. Default is `"EnvironmentException"`.
|
|
317
317
|
*/
|
|
318
|
-
constructor(e,
|
|
319
|
-
super(e,
|
|
318
|
+
constructor(e, t, s = "EnvironmentException") {
|
|
319
|
+
super(e, t, s);
|
|
320
320
|
a(this, se, "EnvironmentException");
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
323
|
var ie, oe;
|
|
324
|
-
class
|
|
324
|
+
class Ke extends (oe = c, ie = Symbol.toStringTag, oe) {
|
|
325
325
|
/**
|
|
326
326
|
* Initializes a new instance of the {@link TimeoutException} class.
|
|
327
327
|
*
|
|
@@ -338,13 +338,13 @@ class Ye extends (oe = u, ie = Symbol.toStringTag, oe) {
|
|
|
338
338
|
* @param cause The previous caught error that caused this one, if any.
|
|
339
339
|
* @param name The name of the exception. Default is `"TimeoutException"`.
|
|
340
340
|
*/
|
|
341
|
-
constructor(e,
|
|
342
|
-
super(e,
|
|
341
|
+
constructor(e, t, s = "TimeoutException") {
|
|
342
|
+
super(e, t, s);
|
|
343
343
|
a(this, ie, "TimeoutException");
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
var ae, le;
|
|
347
|
-
class
|
|
347
|
+
class lt extends (le = c, ae = Symbol.toStringTag, le) {
|
|
348
348
|
/**
|
|
349
349
|
* Initializes a new instance of the {@link TypeException} class.
|
|
350
350
|
*
|
|
@@ -361,13 +361,13 @@ class rt extends (le = u, ae = Symbol.toStringTag, le) {
|
|
|
361
361
|
* @param cause The previous caught error that caused this one, if any.
|
|
362
362
|
* @param name The name of the exception. Default is `"TypeException"`.
|
|
363
363
|
*/
|
|
364
|
-
constructor(e,
|
|
365
|
-
super(e,
|
|
364
|
+
constructor(e, t, s = "TypeException") {
|
|
365
|
+
super(e, t, s);
|
|
366
366
|
a(this, ae, "TypeException");
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
|
-
var
|
|
370
|
-
class d extends (
|
|
369
|
+
var ue, ce;
|
|
370
|
+
class d extends (ce = c, ue = Symbol.toStringTag, ce) {
|
|
371
371
|
/**
|
|
372
372
|
* Initializes a new instance of the {@link ValueException} class.
|
|
373
373
|
*
|
|
@@ -384,9 +384,9 @@ class d extends (ue = u, ce = Symbol.toStringTag, ue) {
|
|
|
384
384
|
* @param cause The previous caught error that caused this one, if any.
|
|
385
385
|
* @param name The name of the exception. Default is `"ValueException"`.
|
|
386
386
|
*/
|
|
387
|
-
constructor(e,
|
|
388
|
-
super(e,
|
|
389
|
-
a(this,
|
|
387
|
+
constructor(e, t, s = "ValueException") {
|
|
388
|
+
super(e, t, s);
|
|
389
|
+
a(this, ue, "ValueException");
|
|
390
390
|
}
|
|
391
391
|
}
|
|
392
392
|
var he, fe;
|
|
@@ -407,20 +407,20 @@ class b extends (fe = d, he = Symbol.toStringTag, fe) {
|
|
|
407
407
|
* @param cause The previous caught error that caused this one, if any.
|
|
408
408
|
* @param name The name of the exception. Default is `"RangeException"`.
|
|
409
409
|
*/
|
|
410
|
-
constructor(e,
|
|
411
|
-
super(e,
|
|
410
|
+
constructor(e, t, s = "RangeException") {
|
|
411
|
+
super(e, t, s);
|
|
412
412
|
a(this, he, "RangeException");
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
415
|
var de;
|
|
416
|
-
class
|
|
417
|
-
constructor(
|
|
416
|
+
class u {
|
|
417
|
+
constructor(n) {
|
|
418
418
|
/**
|
|
419
419
|
* The native {@link Iterator} object that is being wrapped by this instance.
|
|
420
420
|
*/
|
|
421
421
|
a(this, "_iterator");
|
|
422
422
|
a(this, de, "SmartIterator");
|
|
423
|
-
|
|
423
|
+
n instanceof Function ? this._iterator = n() : Symbol.iterator in n ? this._iterator = n[Symbol.iterator]() : this._iterator = n;
|
|
424
424
|
}
|
|
425
425
|
/**
|
|
426
426
|
* Determines whether all elements of the iterator satisfy a given condition.
|
|
@@ -451,13 +451,13 @@ class c {
|
|
|
451
451
|
*
|
|
452
452
|
* @returns `true` if all elements satisfy the condition, `false` otherwise.
|
|
453
453
|
*/
|
|
454
|
-
every(
|
|
454
|
+
every(n) {
|
|
455
455
|
let e = 0;
|
|
456
456
|
for (; ; ) {
|
|
457
|
-
const
|
|
458
|
-
if (
|
|
457
|
+
const t = this._iterator.next();
|
|
458
|
+
if (t.done)
|
|
459
459
|
return !0;
|
|
460
|
-
if (!t
|
|
460
|
+
if (!n(t.value, e))
|
|
461
461
|
return !1;
|
|
462
462
|
e += 1;
|
|
463
463
|
}
|
|
@@ -491,26 +491,26 @@ class c {
|
|
|
491
491
|
*
|
|
492
492
|
* @returns `true` if any element satisfies the condition, `false` otherwise.
|
|
493
493
|
*/
|
|
494
|
-
some(
|
|
494
|
+
some(n) {
|
|
495
495
|
let e = 0;
|
|
496
496
|
for (; ; ) {
|
|
497
|
-
const
|
|
498
|
-
if (
|
|
497
|
+
const t = this._iterator.next();
|
|
498
|
+
if (t.done)
|
|
499
499
|
return !1;
|
|
500
|
-
if (t
|
|
500
|
+
if (n(t.value, e))
|
|
501
501
|
return !0;
|
|
502
502
|
e += 1;
|
|
503
503
|
}
|
|
504
504
|
}
|
|
505
|
-
filter(
|
|
505
|
+
filter(n) {
|
|
506
506
|
const e = this._iterator;
|
|
507
|
-
return new
|
|
508
|
-
let
|
|
507
|
+
return new u(function* () {
|
|
508
|
+
let t = 0;
|
|
509
509
|
for (; ; ) {
|
|
510
510
|
const s = e.next();
|
|
511
511
|
if (s.done)
|
|
512
512
|
return s.value;
|
|
513
|
-
|
|
513
|
+
n(s.value, t) && (yield s.value), t += 1;
|
|
514
514
|
}
|
|
515
515
|
});
|
|
516
516
|
}
|
|
@@ -545,31 +545,31 @@ class c {
|
|
|
545
545
|
*
|
|
546
546
|
* @returns A new {@link SmartIterator} containing the transformed elements.
|
|
547
547
|
*/
|
|
548
|
-
map(
|
|
548
|
+
map(n) {
|
|
549
549
|
const e = this._iterator;
|
|
550
|
-
return new
|
|
551
|
-
let
|
|
550
|
+
return new u(function* () {
|
|
551
|
+
let t = 0;
|
|
552
552
|
for (; ; ) {
|
|
553
553
|
const s = e.next();
|
|
554
554
|
if (s.done)
|
|
555
555
|
return s.value;
|
|
556
|
-
yield
|
|
556
|
+
yield n(s.value, t), t += 1;
|
|
557
557
|
}
|
|
558
558
|
});
|
|
559
559
|
}
|
|
560
|
-
reduce(
|
|
561
|
-
let
|
|
560
|
+
reduce(n, e) {
|
|
561
|
+
let t = 0, s = e;
|
|
562
562
|
if (s === void 0) {
|
|
563
563
|
const r = this._iterator.next();
|
|
564
564
|
if (r.done)
|
|
565
565
|
throw new d("Cannot reduce an empty iterator without an initial value.");
|
|
566
|
-
s = r.value,
|
|
566
|
+
s = r.value, t += 1;
|
|
567
567
|
}
|
|
568
568
|
for (; ; ) {
|
|
569
569
|
const r = this._iterator.next();
|
|
570
570
|
if (r.done)
|
|
571
571
|
return s;
|
|
572
|
-
s =
|
|
572
|
+
s = n(s, r.value, t), t += 1;
|
|
573
573
|
}
|
|
574
574
|
}
|
|
575
575
|
/**
|
|
@@ -603,21 +603,21 @@ class c {
|
|
|
603
603
|
*
|
|
604
604
|
* @returns A new {@link SmartIterator} containing the flattened elements.
|
|
605
605
|
*/
|
|
606
|
-
flatMap(
|
|
606
|
+
flatMap(n) {
|
|
607
607
|
const e = this._iterator;
|
|
608
|
-
return new
|
|
609
|
-
let
|
|
608
|
+
return new u(function* () {
|
|
609
|
+
let t = 0;
|
|
610
610
|
for (; ; ) {
|
|
611
611
|
const s = e.next();
|
|
612
612
|
if (s.done)
|
|
613
613
|
return s.value;
|
|
614
|
-
const r =
|
|
614
|
+
const r = n(s.value, t);
|
|
615
615
|
if (r instanceof Array)
|
|
616
616
|
for (const o of r)
|
|
617
617
|
yield o;
|
|
618
618
|
else
|
|
619
619
|
yield r;
|
|
620
|
-
|
|
620
|
+
t += 1;
|
|
621
621
|
}
|
|
622
622
|
});
|
|
623
623
|
}
|
|
@@ -652,14 +652,14 @@ class c {
|
|
|
652
652
|
*
|
|
653
653
|
* @returns A new {@link SmartIterator} containing the remaining elements.
|
|
654
654
|
*/
|
|
655
|
-
drop(
|
|
655
|
+
drop(n) {
|
|
656
656
|
const e = this._iterator;
|
|
657
|
-
return new
|
|
658
|
-
let
|
|
659
|
-
for (;
|
|
657
|
+
return new u(function* () {
|
|
658
|
+
let t = 0;
|
|
659
|
+
for (; t < n; ) {
|
|
660
660
|
if (e.next().done)
|
|
661
661
|
return;
|
|
662
|
-
|
|
662
|
+
t += 1;
|
|
663
663
|
}
|
|
664
664
|
for (; ; ) {
|
|
665
665
|
const s = e.next();
|
|
@@ -701,26 +701,26 @@ class c {
|
|
|
701
701
|
*
|
|
702
702
|
* @returns A new {@link SmartIterator} containing the taken elements.
|
|
703
703
|
*/
|
|
704
|
-
take(
|
|
704
|
+
take(n) {
|
|
705
705
|
const e = this._iterator;
|
|
706
|
-
return new
|
|
707
|
-
let
|
|
708
|
-
for (;
|
|
706
|
+
return new u(function* () {
|
|
707
|
+
let t = 0;
|
|
708
|
+
for (; t < n; ) {
|
|
709
709
|
const s = e.next();
|
|
710
710
|
if (s.done)
|
|
711
711
|
return s.value;
|
|
712
|
-
yield s.value,
|
|
712
|
+
yield s.value, t += 1;
|
|
713
713
|
}
|
|
714
714
|
});
|
|
715
715
|
}
|
|
716
|
-
find(
|
|
716
|
+
find(n) {
|
|
717
717
|
let e = 0;
|
|
718
718
|
for (; ; ) {
|
|
719
|
-
const
|
|
720
|
-
if (
|
|
719
|
+
const t = this._iterator.next();
|
|
720
|
+
if (t.done)
|
|
721
721
|
return;
|
|
722
|
-
if (t
|
|
723
|
-
return
|
|
722
|
+
if (n(t.value, e))
|
|
723
|
+
return t.value;
|
|
724
724
|
e += 1;
|
|
725
725
|
}
|
|
726
726
|
}
|
|
@@ -750,7 +750,7 @@ class c {
|
|
|
750
750
|
* @returns A new {@link SmartIterator} containing the enumerated elements.
|
|
751
751
|
*/
|
|
752
752
|
enumerate() {
|
|
753
|
-
return this.map((
|
|
753
|
+
return this.map((n, e) => [e, n]);
|
|
754
754
|
}
|
|
755
755
|
/**
|
|
756
756
|
* Removes all duplicate elements from the iterator.
|
|
@@ -778,14 +778,14 @@ class c {
|
|
|
778
778
|
* @returns A new {@link SmartIterator} containing only the unique elements.
|
|
779
779
|
*/
|
|
780
780
|
unique() {
|
|
781
|
-
const
|
|
782
|
-
return new
|
|
781
|
+
const n = this._iterator;
|
|
782
|
+
return new u(function* () {
|
|
783
783
|
const e = /* @__PURE__ */ new Set();
|
|
784
784
|
for (; ; ) {
|
|
785
|
-
const
|
|
786
|
-
if (
|
|
787
|
-
return
|
|
788
|
-
e.has(
|
|
785
|
+
const t = n.next();
|
|
786
|
+
if (t.done)
|
|
787
|
+
return t.value;
|
|
788
|
+
e.has(t.value) || (e.add(t.value), yield t.value);
|
|
789
789
|
}
|
|
790
790
|
});
|
|
791
791
|
}
|
|
@@ -810,11 +810,11 @@ class c {
|
|
|
810
810
|
* @returns The number of elements in the iterator.
|
|
811
811
|
*/
|
|
812
812
|
count() {
|
|
813
|
-
let
|
|
813
|
+
let n = 0;
|
|
814
814
|
for (; ; ) {
|
|
815
815
|
if (this._iterator.next().done)
|
|
816
|
-
return
|
|
817
|
-
|
|
816
|
+
return n;
|
|
817
|
+
n += 1;
|
|
818
818
|
}
|
|
819
819
|
}
|
|
820
820
|
/**
|
|
@@ -839,13 +839,13 @@ class c {
|
|
|
839
839
|
*
|
|
840
840
|
* @param iteratee The function to apply to each element of the iterator.
|
|
841
841
|
*/
|
|
842
|
-
forEach(
|
|
842
|
+
forEach(n) {
|
|
843
843
|
let e = 0;
|
|
844
844
|
for (; ; ) {
|
|
845
|
-
const
|
|
846
|
-
if (
|
|
845
|
+
const t = this._iterator.next();
|
|
846
|
+
if (t.done)
|
|
847
847
|
return;
|
|
848
|
-
t
|
|
848
|
+
n(t.value, e), e += 1;
|
|
849
849
|
}
|
|
850
850
|
}
|
|
851
851
|
/**
|
|
@@ -877,8 +877,8 @@ class c {
|
|
|
877
877
|
*
|
|
878
878
|
* @returns The result of the iteration, containing the value of the operation.
|
|
879
879
|
*/
|
|
880
|
-
next(...
|
|
881
|
-
return this._iterator.next(...
|
|
880
|
+
next(...n) {
|
|
881
|
+
return this._iterator.next(...n);
|
|
882
882
|
}
|
|
883
883
|
/**
|
|
884
884
|
* An utility method that may be used to close the iterator gracefully,
|
|
@@ -912,8 +912,8 @@ class c {
|
|
|
912
912
|
*
|
|
913
913
|
* @returns The result of the iterator.
|
|
914
914
|
*/
|
|
915
|
-
return(
|
|
916
|
-
return this._iterator.return ? this._iterator.return(
|
|
915
|
+
return(n) {
|
|
916
|
+
return this._iterator.return ? this._iterator.return(n) : { done: !0, value: n };
|
|
917
917
|
}
|
|
918
918
|
/**
|
|
919
919
|
* An utility method that may be used to close the iterator due to an error,
|
|
@@ -956,10 +956,10 @@ class c {
|
|
|
956
956
|
*
|
|
957
957
|
* @returns The final result of the iterator.
|
|
958
958
|
*/
|
|
959
|
-
throw(
|
|
959
|
+
throw(n) {
|
|
960
960
|
if (this._iterator.throw)
|
|
961
|
-
return this._iterator.throw(
|
|
962
|
-
throw
|
|
961
|
+
return this._iterator.throw(n);
|
|
962
|
+
throw n;
|
|
963
963
|
}
|
|
964
964
|
/**
|
|
965
965
|
* An utility method that aggregates the elements of the iterator using a given key function.
|
|
@@ -991,8 +991,8 @@ class c {
|
|
|
991
991
|
*
|
|
992
992
|
* @returns A new instance of the {@link AggregatedIterator} class containing the grouped elements.
|
|
993
993
|
*/
|
|
994
|
-
groupBy(
|
|
995
|
-
return new
|
|
994
|
+
groupBy(n) {
|
|
995
|
+
return new x(this.map((e, t) => [n(e, t), e]));
|
|
996
996
|
}
|
|
997
997
|
/**
|
|
998
998
|
* Materializes the iterator into an array.
|
|
@@ -1026,14 +1026,14 @@ class c {
|
|
|
1026
1026
|
}
|
|
1027
1027
|
var we;
|
|
1028
1028
|
we = Symbol.toStringTag;
|
|
1029
|
-
const
|
|
1030
|
-
constructor(
|
|
1029
|
+
const _ = class _ {
|
|
1030
|
+
constructor(n) {
|
|
1031
1031
|
/**
|
|
1032
1032
|
* The internal {@link SmartIterator} object that holds the reduced elements.
|
|
1033
1033
|
*/
|
|
1034
1034
|
a(this, "_elements");
|
|
1035
1035
|
a(this, we, "ReducedIterator");
|
|
1036
|
-
this._elements = new
|
|
1036
|
+
this._elements = new u(n);
|
|
1037
1037
|
}
|
|
1038
1038
|
/**
|
|
1039
1039
|
* Determines whether all elements of the reduced iterator satisfy the given condition.
|
|
@@ -1066,9 +1066,9 @@ const p = class p {
|
|
|
1066
1066
|
*
|
|
1067
1067
|
* @returns `true` if all elements satisfy the condition, `false` otherwise.
|
|
1068
1068
|
*/
|
|
1069
|
-
every(
|
|
1070
|
-
for (const [e, [
|
|
1071
|
-
if (!t
|
|
1069
|
+
every(n) {
|
|
1070
|
+
for (const [e, [t, s]] of this._elements.enumerate())
|
|
1071
|
+
if (!n(t, s, e))
|
|
1072
1072
|
return !1;
|
|
1073
1073
|
return !0;
|
|
1074
1074
|
}
|
|
@@ -1103,17 +1103,17 @@ const p = class p {
|
|
|
1103
1103
|
*
|
|
1104
1104
|
* @returns `true` if any element satisfies the condition, `false` otherwise.
|
|
1105
1105
|
*/
|
|
1106
|
-
some(
|
|
1107
|
-
for (const [e, [
|
|
1108
|
-
if (t
|
|
1106
|
+
some(n) {
|
|
1107
|
+
for (const [e, [t, s]] of this._elements.enumerate())
|
|
1108
|
+
if (n(t, s, e))
|
|
1109
1109
|
return !0;
|
|
1110
1110
|
return !1;
|
|
1111
1111
|
}
|
|
1112
|
-
filter(
|
|
1112
|
+
filter(n) {
|
|
1113
1113
|
const e = this._elements.enumerate();
|
|
1114
|
-
return new
|
|
1115
|
-
for (const [
|
|
1116
|
-
|
|
1114
|
+
return new _(function* () {
|
|
1115
|
+
for (const [t, [s, r]] of e)
|
|
1116
|
+
n(s, r, t) && (yield [s, r]);
|
|
1117
1117
|
});
|
|
1118
1118
|
}
|
|
1119
1119
|
/**
|
|
@@ -1149,23 +1149,23 @@ const p = class p {
|
|
|
1149
1149
|
*
|
|
1150
1150
|
* @returns A new {@link ReducedIterator} containing the transformed elements.
|
|
1151
1151
|
*/
|
|
1152
|
-
map(
|
|
1152
|
+
map(n) {
|
|
1153
1153
|
const e = this._elements.enumerate();
|
|
1154
|
-
return new
|
|
1155
|
-
for (const [
|
|
1156
|
-
yield [s,
|
|
1154
|
+
return new _(function* () {
|
|
1155
|
+
for (const [t, [s, r]] of e)
|
|
1156
|
+
yield [s, n(s, r, t)];
|
|
1157
1157
|
});
|
|
1158
1158
|
}
|
|
1159
|
-
reduce(
|
|
1160
|
-
let
|
|
1159
|
+
reduce(n, e) {
|
|
1160
|
+
let t = 0, s = e;
|
|
1161
1161
|
if (s === void 0) {
|
|
1162
1162
|
const r = this._elements.next();
|
|
1163
1163
|
if (r.done)
|
|
1164
1164
|
throw new d("Cannot reduce an empty iterator without an initial value.");
|
|
1165
|
-
s = r.value[1],
|
|
1165
|
+
s = r.value[1], t += 1;
|
|
1166
1166
|
}
|
|
1167
1167
|
for (const [r, o] of this._elements)
|
|
1168
|
-
s =
|
|
1168
|
+
s = n(r, s, o, t), t += 1;
|
|
1169
1169
|
return s;
|
|
1170
1170
|
}
|
|
1171
1171
|
/**
|
|
@@ -1201,11 +1201,11 @@ const p = class p {
|
|
|
1201
1201
|
*
|
|
1202
1202
|
* @returns A new {@link AggregatedIterator} containing the flattened elements.
|
|
1203
1203
|
*/
|
|
1204
|
-
flatMap(
|
|
1204
|
+
flatMap(n) {
|
|
1205
1205
|
const e = this._elements.enumerate();
|
|
1206
|
-
return new
|
|
1207
|
-
for (const [
|
|
1208
|
-
const o =
|
|
1206
|
+
return new x(function* () {
|
|
1207
|
+
for (const [t, [s, r]] of e) {
|
|
1208
|
+
const o = n(s, r, t);
|
|
1209
1209
|
if (o instanceof Array)
|
|
1210
1210
|
for (const l of o)
|
|
1211
1211
|
yield [s, l];
|
|
@@ -1240,16 +1240,18 @@ const p = class p {
|
|
|
1240
1240
|
*
|
|
1241
1241
|
* console.log(results.toObject()); // { even: [0, 2, 6, 8] }
|
|
1242
1242
|
* ```
|
|
1243
|
-
*
|
|
1243
|
+
*
|
|
1244
|
+
* ---
|
|
1245
|
+
*
|
|
1244
1246
|
* @param count The number of elements to drop.
|
|
1245
1247
|
*
|
|
1246
1248
|
* @returns A new {@link ReducedIterator} containing the remaining elements.
|
|
1247
1249
|
*/
|
|
1248
|
-
drop(
|
|
1250
|
+
drop(n) {
|
|
1249
1251
|
const e = this._elements.enumerate();
|
|
1250
|
-
return new
|
|
1251
|
-
for (const [
|
|
1252
|
-
|
|
1252
|
+
return new _(function* () {
|
|
1253
|
+
for (const [t, [s, r]] of e)
|
|
1254
|
+
t >= n && (yield [s, r]);
|
|
1253
1255
|
});
|
|
1254
1256
|
}
|
|
1255
1257
|
/**
|
|
@@ -1287,19 +1289,19 @@ const p = class p {
|
|
|
1287
1289
|
*
|
|
1288
1290
|
* @returns A new {@link ReducedIterator} containing the taken elements.
|
|
1289
1291
|
*/
|
|
1290
|
-
take(
|
|
1292
|
+
take(n) {
|
|
1291
1293
|
const e = this._elements.enumerate();
|
|
1292
|
-
return new
|
|
1293
|
-
for (const [
|
|
1294
|
-
if (
|
|
1294
|
+
return new _(function* () {
|
|
1295
|
+
for (const [t, [s, r]] of e) {
|
|
1296
|
+
if (t >= n)
|
|
1295
1297
|
break;
|
|
1296
1298
|
yield [s, r];
|
|
1297
1299
|
}
|
|
1298
1300
|
});
|
|
1299
1301
|
}
|
|
1300
|
-
find(
|
|
1301
|
-
for (const [e, [
|
|
1302
|
-
if (t
|
|
1302
|
+
find(n) {
|
|
1303
|
+
for (const [e, [t, s]] of this._elements.enumerate())
|
|
1304
|
+
if (n(t, s, e))
|
|
1303
1305
|
return s;
|
|
1304
1306
|
}
|
|
1305
1307
|
/**
|
|
@@ -1330,7 +1332,7 @@ const p = class p {
|
|
|
1330
1332
|
* @returns A new {@link ReducedIterator} object containing the enumerated elements.
|
|
1331
1333
|
*/
|
|
1332
1334
|
enumerate() {
|
|
1333
|
-
return this.map((
|
|
1335
|
+
return this.map((n, e, t) => [t, e]);
|
|
1334
1336
|
}
|
|
1335
1337
|
/**
|
|
1336
1338
|
* Removes all duplicate elements from the reduced iterator.
|
|
@@ -1358,11 +1360,11 @@ const p = class p {
|
|
|
1358
1360
|
* @returns A new {@link ReducedIterator} containing only the unique elements.
|
|
1359
1361
|
*/
|
|
1360
1362
|
unique() {
|
|
1361
|
-
const
|
|
1362
|
-
return new
|
|
1363
|
+
const n = this._elements;
|
|
1364
|
+
return new _(function* () {
|
|
1363
1365
|
const e = /* @__PURE__ */ new Set();
|
|
1364
|
-
for (const [
|
|
1365
|
-
e.has(s) || (e.add(s), yield [
|
|
1366
|
+
for (const [t, s] of n)
|
|
1367
|
+
e.has(s) || (e.add(s), yield [t, s]);
|
|
1366
1368
|
});
|
|
1367
1369
|
}
|
|
1368
1370
|
/**
|
|
@@ -1388,10 +1390,10 @@ const p = class p {
|
|
|
1388
1390
|
* @returns The number of elements in the iterator.
|
|
1389
1391
|
*/
|
|
1390
1392
|
count() {
|
|
1391
|
-
let
|
|
1393
|
+
let n = 0;
|
|
1392
1394
|
for (const e of this._elements)
|
|
1393
|
-
|
|
1394
|
-
return
|
|
1395
|
+
n += 1;
|
|
1396
|
+
return n;
|
|
1395
1397
|
}
|
|
1396
1398
|
/**
|
|
1397
1399
|
* Iterates over all elements of the reduced iterator.
|
|
@@ -1407,7 +1409,7 @@ const p = class p {
|
|
|
1407
1409
|
* const reduced = new SmartIterator<number>([-3, -1, 0, 2, 3, 5, 6, 8])
|
|
1408
1410
|
* .groupBy((value) => value % 2 === 0 ? "even" : "odd")
|
|
1409
1411
|
* .reduce((key, accumulator, value) => accumulator + value);
|
|
1410
|
-
*
|
|
1412
|
+
*
|
|
1411
1413
|
* reduced.forEach((key, value, index) =>
|
|
1412
1414
|
* {
|
|
1413
1415
|
* console.log(`#${index} - ${key}: ${value}`); // "#0 - odd: 4", "#1 - even: 16"
|
|
@@ -1418,9 +1420,9 @@ const p = class p {
|
|
|
1418
1420
|
*
|
|
1419
1421
|
* @param iteratee The function to apply to each element of the reduced iterator.
|
|
1420
1422
|
*/
|
|
1421
|
-
forEach(
|
|
1422
|
-
for (const [e, [
|
|
1423
|
-
t
|
|
1423
|
+
forEach(n) {
|
|
1424
|
+
for (const [e, [t, s]] of this._elements.enumerate())
|
|
1425
|
+
n(t, s, e);
|
|
1424
1426
|
}
|
|
1425
1427
|
/**
|
|
1426
1428
|
* Reaggregates the elements of the reduced iterator.
|
|
@@ -1453,11 +1455,11 @@ const p = class p {
|
|
|
1453
1455
|
*
|
|
1454
1456
|
* @returns A new {@link AggregatedIterator} containing the elements reorganized by the new keys.
|
|
1455
1457
|
*/
|
|
1456
|
-
reorganizeBy(
|
|
1458
|
+
reorganizeBy(n) {
|
|
1457
1459
|
const e = this._elements.enumerate();
|
|
1458
|
-
return new
|
|
1459
|
-
for (const [
|
|
1460
|
-
yield [
|
|
1460
|
+
return new x(function* () {
|
|
1461
|
+
for (const [t, [s, r]] of e)
|
|
1462
|
+
yield [n(s, r, t), r];
|
|
1461
1463
|
});
|
|
1462
1464
|
}
|
|
1463
1465
|
/**
|
|
@@ -1488,9 +1490,9 @@ const p = class p {
|
|
|
1488
1490
|
* @returns A new {@link SmartIterator} containing all the keys of the iterator.
|
|
1489
1491
|
*/
|
|
1490
1492
|
keys() {
|
|
1491
|
-
const
|
|
1492
|
-
return new
|
|
1493
|
-
for (const [e] of
|
|
1493
|
+
const n = this._elements;
|
|
1494
|
+
return new u(function* () {
|
|
1495
|
+
for (const [e] of n)
|
|
1494
1496
|
yield e;
|
|
1495
1497
|
});
|
|
1496
1498
|
}
|
|
@@ -1553,10 +1555,10 @@ const p = class p {
|
|
|
1553
1555
|
* @returns A new {@link SmartIterator} containing all the values of the iterator.
|
|
1554
1556
|
*/
|
|
1555
1557
|
values() {
|
|
1556
|
-
const
|
|
1557
|
-
return new
|
|
1558
|
-
for (const [e,
|
|
1559
|
-
yield
|
|
1558
|
+
const n = this._elements;
|
|
1559
|
+
return new u(function* () {
|
|
1560
|
+
for (const [e, t] of n)
|
|
1561
|
+
yield t;
|
|
1560
1562
|
});
|
|
1561
1563
|
}
|
|
1562
1564
|
/**
|
|
@@ -1632,17 +1634,17 @@ const p = class p {
|
|
|
1632
1634
|
return Object.fromEntries(this.entries());
|
|
1633
1635
|
}
|
|
1634
1636
|
};
|
|
1635
|
-
let h =
|
|
1637
|
+
let h = _;
|
|
1636
1638
|
var me;
|
|
1637
1639
|
me = Symbol.toStringTag;
|
|
1638
1640
|
const w = class w {
|
|
1639
|
-
constructor(
|
|
1641
|
+
constructor(n) {
|
|
1640
1642
|
/**
|
|
1641
1643
|
* The internal {@link SmartAsyncIterator} object that holds the elements to aggregate.
|
|
1642
1644
|
*/
|
|
1643
1645
|
a(this, "_elements");
|
|
1644
1646
|
a(this, me, "AggregatedAsyncIterator");
|
|
1645
|
-
this._elements = new f(
|
|
1647
|
+
this._elements = new f(n);
|
|
1646
1648
|
}
|
|
1647
1649
|
/**
|
|
1648
1650
|
* Determines whether all elements of each group of the iterator satisfy a given condition.
|
|
@@ -1675,15 +1677,15 @@ const w = class w {
|
|
|
1675
1677
|
* @returns
|
|
1676
1678
|
* A {@link Promise} resolving to a new {@link ReducedIterator} containing the boolean results for each group.
|
|
1677
1679
|
*/
|
|
1678
|
-
async every(
|
|
1680
|
+
async every(n) {
|
|
1679
1681
|
const e = /* @__PURE__ */ new Map();
|
|
1680
|
-
for await (const [
|
|
1681
|
-
const [r, o] = e.get(
|
|
1682
|
-
o && e.set(
|
|
1682
|
+
for await (const [t, s] of this._elements) {
|
|
1683
|
+
const [r, o] = e.get(t) ?? [0, !0];
|
|
1684
|
+
o && e.set(t, [r + 1, await n(t, s, r)]);
|
|
1683
1685
|
}
|
|
1684
1686
|
return new h(function* () {
|
|
1685
|
-
for (const [
|
|
1686
|
-
yield [
|
|
1687
|
+
for (const [t, [s, r]] of e)
|
|
1688
|
+
yield [t, r];
|
|
1687
1689
|
});
|
|
1688
1690
|
}
|
|
1689
1691
|
/**
|
|
@@ -1717,24 +1719,24 @@ const w = class w {
|
|
|
1717
1719
|
* @returns
|
|
1718
1720
|
* A {@link Promise} resolving to a new {@link ReducedIterator} containing the boolean results for each group.
|
|
1719
1721
|
*/
|
|
1720
|
-
async some(
|
|
1722
|
+
async some(n) {
|
|
1721
1723
|
const e = /* @__PURE__ */ new Map();
|
|
1722
|
-
for await (const [
|
|
1723
|
-
const [r, o] = e.get(
|
|
1724
|
-
o || e.set(
|
|
1724
|
+
for await (const [t, s] of this._elements) {
|
|
1725
|
+
const [r, o] = e.get(t) ?? [0, !1];
|
|
1726
|
+
o || e.set(t, [r + 1, await n(t, s, r)]);
|
|
1725
1727
|
}
|
|
1726
1728
|
return new h(function* () {
|
|
1727
|
-
for (const [
|
|
1728
|
-
yield [
|
|
1729
|
+
for (const [t, [s, r]] of e)
|
|
1730
|
+
yield [t, r];
|
|
1729
1731
|
});
|
|
1730
1732
|
}
|
|
1731
|
-
filter(
|
|
1733
|
+
filter(n) {
|
|
1732
1734
|
const e = this._elements;
|
|
1733
1735
|
return new w(async function* () {
|
|
1734
|
-
const
|
|
1736
|
+
const t = /* @__PURE__ */ new Map();
|
|
1735
1737
|
for await (const [s, r] of e) {
|
|
1736
|
-
const o =
|
|
1737
|
-
await
|
|
1738
|
+
const o = t.get(s) ?? 0;
|
|
1739
|
+
await n(s, r, o) && (yield [s, r]), t.set(s, o + 1);
|
|
1738
1740
|
}
|
|
1739
1741
|
});
|
|
1740
1742
|
}
|
|
@@ -1770,32 +1772,32 @@ const w = class w {
|
|
|
1770
1772
|
*
|
|
1771
1773
|
* @returns A new {@link AggregatedAsyncIterator} containing the transformed elements.
|
|
1772
1774
|
*/
|
|
1773
|
-
map(
|
|
1775
|
+
map(n) {
|
|
1774
1776
|
const e = this._elements;
|
|
1775
1777
|
return new w(async function* () {
|
|
1776
|
-
const
|
|
1778
|
+
const t = /* @__PURE__ */ new Map();
|
|
1777
1779
|
for await (const [s, r] of e) {
|
|
1778
|
-
const o =
|
|
1779
|
-
yield [s, await
|
|
1780
|
+
const o = t.get(s) ?? 0;
|
|
1781
|
+
yield [s, await n(s, r, o)], t.set(s, o + 1);
|
|
1780
1782
|
}
|
|
1781
1783
|
});
|
|
1782
1784
|
}
|
|
1783
|
-
async reduce(
|
|
1784
|
-
const
|
|
1785
|
+
async reduce(n, e) {
|
|
1786
|
+
const t = /* @__PURE__ */ new Map();
|
|
1785
1787
|
for await (const [s, r] of this._elements) {
|
|
1786
1788
|
let o, l;
|
|
1787
|
-
if (
|
|
1788
|
-
[o, l] =
|
|
1789
|
+
if (t.has(s))
|
|
1790
|
+
[o, l] = t.get(s);
|
|
1789
1791
|
else if (e !== void 0)
|
|
1790
1792
|
o = 0, e instanceof Function ? l = await e(s) : l = await e;
|
|
1791
1793
|
else {
|
|
1792
|
-
|
|
1794
|
+
t.set(s, [0, r]);
|
|
1793
1795
|
continue;
|
|
1794
1796
|
}
|
|
1795
|
-
|
|
1797
|
+
t.set(s, [o + 1, await n(s, l, r, o)]);
|
|
1796
1798
|
}
|
|
1797
1799
|
return new h(function* () {
|
|
1798
|
-
for (const [s, [r, o]] of
|
|
1800
|
+
for (const [s, [r, o]] of t)
|
|
1799
1801
|
yield [s, o];
|
|
1800
1802
|
});
|
|
1801
1803
|
}
|
|
@@ -1835,18 +1837,18 @@ const w = class w {
|
|
|
1835
1837
|
*
|
|
1836
1838
|
* @returns A new {@link AggregatedAsyncIterator} containing the transformed elements.
|
|
1837
1839
|
*/
|
|
1838
|
-
flatMap(
|
|
1840
|
+
flatMap(n) {
|
|
1839
1841
|
const e = this._elements;
|
|
1840
1842
|
return new w(async function* () {
|
|
1841
|
-
const
|
|
1843
|
+
const t = /* @__PURE__ */ new Map();
|
|
1842
1844
|
for await (const [s, r] of e) {
|
|
1843
|
-
const o =
|
|
1845
|
+
const o = t.get(s) ?? 0, l = await n(s, r, o);
|
|
1844
1846
|
if (l instanceof Array)
|
|
1845
|
-
for (const
|
|
1846
|
-
yield [s,
|
|
1847
|
+
for (const k of l)
|
|
1848
|
+
yield [s, k];
|
|
1847
1849
|
else
|
|
1848
1850
|
yield [s, l];
|
|
1849
|
-
|
|
1851
|
+
t.set(s, o + 1);
|
|
1850
1852
|
}
|
|
1851
1853
|
});
|
|
1852
1854
|
}
|
|
@@ -1879,14 +1881,14 @@ const w = class w {
|
|
|
1879
1881
|
*
|
|
1880
1882
|
* @returns A new {@link AggregatedAsyncIterator} containing the remaining elements.
|
|
1881
1883
|
*/
|
|
1882
|
-
drop(
|
|
1884
|
+
drop(n) {
|
|
1883
1885
|
const e = this._elements;
|
|
1884
1886
|
return new w(async function* () {
|
|
1885
|
-
const
|
|
1887
|
+
const t = /* @__PURE__ */ new Map();
|
|
1886
1888
|
for await (const [s, r] of e) {
|
|
1887
|
-
const o =
|
|
1888
|
-
if (o <
|
|
1889
|
-
|
|
1889
|
+
const o = t.get(s) ?? 0;
|
|
1890
|
+
if (o < n) {
|
|
1891
|
+
t.set(s, o + 1);
|
|
1890
1892
|
continue;
|
|
1891
1893
|
}
|
|
1892
1894
|
yield [s, r];
|
|
@@ -1922,25 +1924,25 @@ const w = class w {
|
|
|
1922
1924
|
*
|
|
1923
1925
|
* @returns A new {@link AggregatedAsyncIterator} containing the taken elements.
|
|
1924
1926
|
*/
|
|
1925
|
-
take(
|
|
1927
|
+
take(n) {
|
|
1926
1928
|
const e = this._elements;
|
|
1927
1929
|
return new w(async function* () {
|
|
1928
|
-
const
|
|
1930
|
+
const t = /* @__PURE__ */ new Map();
|
|
1929
1931
|
for await (const [s, r] of e) {
|
|
1930
|
-
const o =
|
|
1931
|
-
o >=
|
|
1932
|
+
const o = t.get(s) ?? 0;
|
|
1933
|
+
o >= n || (yield [s, r], t.set(s, o + 1));
|
|
1932
1934
|
}
|
|
1933
1935
|
});
|
|
1934
1936
|
}
|
|
1935
|
-
async find(
|
|
1937
|
+
async find(n) {
|
|
1936
1938
|
const e = /* @__PURE__ */ new Map();
|
|
1937
|
-
for await (const [
|
|
1938
|
-
let [r, o] = e.get(
|
|
1939
|
-
o === void 0 && (await t
|
|
1939
|
+
for await (const [t, s] of this._elements) {
|
|
1940
|
+
let [r, o] = e.get(t) ?? [0, void 0];
|
|
1941
|
+
o === void 0 && (await n(t, s, r) && (o = s), e.set(t, [r + 1, o]));
|
|
1940
1942
|
}
|
|
1941
1943
|
return new h(function* () {
|
|
1942
|
-
for (const [
|
|
1943
|
-
yield [
|
|
1944
|
+
for (const [t, [s, r]] of e)
|
|
1945
|
+
yield [t, r];
|
|
1944
1946
|
});
|
|
1945
1947
|
}
|
|
1946
1948
|
/**
|
|
@@ -1970,7 +1972,7 @@ const w = class w {
|
|
|
1970
1972
|
* @returns A new {@link AggregatedAsyncIterator} containing the enumerated elements.
|
|
1971
1973
|
*/
|
|
1972
1974
|
enumerate() {
|
|
1973
|
-
return this.map((
|
|
1975
|
+
return this.map((n, e, t) => [t, e]);
|
|
1974
1976
|
}
|
|
1975
1977
|
/**
|
|
1976
1978
|
* Removes all duplicate elements from within each group of the iterator.
|
|
@@ -1999,12 +2001,12 @@ const w = class w {
|
|
|
1999
2001
|
* @returns A new {@link AggregatedAsyncIterator} containing only the unique elements.
|
|
2000
2002
|
*/
|
|
2001
2003
|
unique() {
|
|
2002
|
-
const
|
|
2004
|
+
const n = this._elements;
|
|
2003
2005
|
return new w(async function* () {
|
|
2004
2006
|
const e = /* @__PURE__ */ new Map();
|
|
2005
|
-
for await (const [
|
|
2006
|
-
const r = e.get(
|
|
2007
|
-
r.has(s) || (r.add(s), e.set(
|
|
2007
|
+
for await (const [t, s] of n) {
|
|
2008
|
+
const r = e.get(t) ?? /* @__PURE__ */ new Set();
|
|
2009
|
+
r.has(s) || (r.add(s), e.set(t, r), yield [t, s]);
|
|
2008
2010
|
}
|
|
2009
2011
|
});
|
|
2010
2012
|
}
|
|
@@ -2031,14 +2033,14 @@ const w = class w {
|
|
|
2031
2033
|
* A {@link Promise} resolving to a new {@link ReducedIterator} containing the number of elements for each group.
|
|
2032
2034
|
*/
|
|
2033
2035
|
async count() {
|
|
2034
|
-
const
|
|
2036
|
+
const n = /* @__PURE__ */ new Map();
|
|
2035
2037
|
for await (const [e] of this._elements) {
|
|
2036
|
-
const
|
|
2037
|
-
|
|
2038
|
+
const t = n.get(e) ?? 0;
|
|
2039
|
+
n.set(e, t + 1);
|
|
2038
2040
|
}
|
|
2039
2041
|
return new h(function* () {
|
|
2040
|
-
for (const [e,
|
|
2041
|
-
yield [e,
|
|
2042
|
+
for (const [e, t] of n)
|
|
2043
|
+
yield [e, t];
|
|
2042
2044
|
});
|
|
2043
2045
|
}
|
|
2044
2046
|
/**
|
|
@@ -2067,11 +2069,11 @@ const w = class w {
|
|
|
2067
2069
|
*
|
|
2068
2070
|
* @returns A {@link Promise} that will resolve once the iteration is complete.
|
|
2069
2071
|
*/
|
|
2070
|
-
async forEach(
|
|
2072
|
+
async forEach(n) {
|
|
2071
2073
|
const e = /* @__PURE__ */ new Map();
|
|
2072
|
-
for await (const [
|
|
2073
|
-
const r = e.get(
|
|
2074
|
-
await t
|
|
2074
|
+
for await (const [t, s] of this._elements) {
|
|
2075
|
+
const r = e.get(t) ?? 0;
|
|
2076
|
+
await n(t, s, r), e.set(t, r + 1);
|
|
2075
2077
|
}
|
|
2076
2078
|
}
|
|
2077
2079
|
/**
|
|
@@ -2105,13 +2107,13 @@ const w = class w {
|
|
|
2105
2107
|
*
|
|
2106
2108
|
* @returns A new {@link AggregatedAsyncIterator} containing the elements reorganized by the new keys.
|
|
2107
2109
|
*/
|
|
2108
|
-
reorganizeBy(
|
|
2110
|
+
reorganizeBy(n) {
|
|
2109
2111
|
const e = this._elements;
|
|
2110
2112
|
return new w(async function* () {
|
|
2111
|
-
const
|
|
2113
|
+
const t = /* @__PURE__ */ new Map();
|
|
2112
2114
|
for await (const [s, r] of e) {
|
|
2113
|
-
const o =
|
|
2114
|
-
yield [await
|
|
2115
|
+
const o = t.get(s) ?? 0;
|
|
2116
|
+
yield [await n(s, r, o), r], t.set(s, o + 1);
|
|
2115
2117
|
}
|
|
2116
2118
|
});
|
|
2117
2119
|
}
|
|
@@ -2142,11 +2144,11 @@ const w = class w {
|
|
|
2142
2144
|
* @returns A new {@link SmartAsyncIterator} containing all the keys of the iterator.
|
|
2143
2145
|
*/
|
|
2144
2146
|
keys() {
|
|
2145
|
-
const
|
|
2147
|
+
const n = this._elements;
|
|
2146
2148
|
return new f(async function* () {
|
|
2147
2149
|
const e = /* @__PURE__ */ new Set();
|
|
2148
|
-
for await (const [
|
|
2149
|
-
e.has(
|
|
2150
|
+
for await (const [t] of n)
|
|
2151
|
+
e.has(t) || (e.add(t), yield t);
|
|
2150
2152
|
});
|
|
2151
2153
|
}
|
|
2152
2154
|
/**
|
|
@@ -2206,10 +2208,10 @@ const w = class w {
|
|
|
2206
2208
|
* @returns A new {@link SmartAsyncIterator} containing all the values of the iterator.
|
|
2207
2209
|
*/
|
|
2208
2210
|
values() {
|
|
2209
|
-
const
|
|
2211
|
+
const n = this._elements;
|
|
2210
2212
|
return new f(async function* () {
|
|
2211
|
-
for await (const [e,
|
|
2212
|
-
yield
|
|
2213
|
+
for await (const [e, t] of n)
|
|
2214
|
+
yield t;
|
|
2213
2215
|
});
|
|
2214
2216
|
}
|
|
2215
2217
|
/**
|
|
@@ -2233,8 +2235,8 @@ const w = class w {
|
|
|
2233
2235
|
* @returns A {@link Promise} resolving to an {@link Array} containing all the values of the iterator.
|
|
2234
2236
|
*/
|
|
2235
2237
|
async toArray() {
|
|
2236
|
-
const
|
|
2237
|
-
return Array.from(
|
|
2238
|
+
const n = await this.toMap();
|
|
2239
|
+
return Array.from(n.values());
|
|
2238
2240
|
}
|
|
2239
2241
|
/**
|
|
2240
2242
|
* Materializes the iterator into a map.
|
|
@@ -2257,12 +2259,12 @@ const w = class w {
|
|
|
2257
2259
|
* @returns A {@link Promise} resolving to a {@link Map} containing all the entries of the iterator.
|
|
2258
2260
|
*/
|
|
2259
2261
|
async toMap() {
|
|
2260
|
-
const
|
|
2261
|
-
for await (const [e,
|
|
2262
|
-
const s =
|
|
2263
|
-
s.push(
|
|
2262
|
+
const n = /* @__PURE__ */ new Map();
|
|
2263
|
+
for await (const [e, t] of this._elements) {
|
|
2264
|
+
const s = n.get(e) ?? [];
|
|
2265
|
+
s.push(t), n.set(e, s);
|
|
2264
2266
|
}
|
|
2265
|
-
return
|
|
2267
|
+
return n;
|
|
2266
2268
|
}
|
|
2267
2269
|
/**
|
|
2268
2270
|
* Materializes the iterator into an object.
|
|
@@ -2285,54 +2287,54 @@ const w = class w {
|
|
|
2285
2287
|
* @returns A {@link Promise} resolving to an object containing all the entries of the iterator.
|
|
2286
2288
|
*/
|
|
2287
2289
|
async toObject() {
|
|
2288
|
-
const
|
|
2289
|
-
for await (const [e,
|
|
2290
|
-
const s =
|
|
2291
|
-
s.push(
|
|
2290
|
+
const n = {};
|
|
2291
|
+
for await (const [e, t] of this._elements) {
|
|
2292
|
+
const s = n[e] ?? [];
|
|
2293
|
+
s.push(t), n[e] = s;
|
|
2292
2294
|
}
|
|
2293
|
-
return
|
|
2295
|
+
return n;
|
|
2294
2296
|
}
|
|
2295
2297
|
};
|
|
2296
|
-
let
|
|
2297
|
-
var
|
|
2298
|
+
let E = w;
|
|
2299
|
+
var pe;
|
|
2298
2300
|
class f {
|
|
2299
|
-
constructor(
|
|
2301
|
+
constructor(n) {
|
|
2300
2302
|
/**
|
|
2301
2303
|
* The native {@link AsyncIterator} object that is being wrapped by this instance.
|
|
2302
2304
|
*/
|
|
2303
2305
|
a(this, "_iterator");
|
|
2304
|
-
a(this,
|
|
2305
|
-
if (
|
|
2306
|
-
const e =
|
|
2306
|
+
a(this, pe, "SmartAsyncIterator");
|
|
2307
|
+
if (n instanceof Function) {
|
|
2308
|
+
const e = n();
|
|
2307
2309
|
Symbol.asyncIterator in e ? this._iterator = e : this._iterator = async function* () {
|
|
2308
|
-
let
|
|
2310
|
+
let t = [];
|
|
2309
2311
|
for (; ; ) {
|
|
2310
|
-
const s = e.next(...
|
|
2312
|
+
const s = e.next(...t);
|
|
2311
2313
|
if (s.done)
|
|
2312
2314
|
return s.value;
|
|
2313
|
-
|
|
2315
|
+
t = [yield s.value];
|
|
2314
2316
|
}
|
|
2315
2317
|
}();
|
|
2316
|
-
} else if (Symbol.asyncIterator in
|
|
2317
|
-
this._iterator =
|
|
2318
|
-
else if (Symbol.iterator in
|
|
2319
|
-
const e =
|
|
2318
|
+
} else if (Symbol.asyncIterator in n)
|
|
2319
|
+
this._iterator = n[Symbol.asyncIterator]();
|
|
2320
|
+
else if (Symbol.iterator in n) {
|
|
2321
|
+
const e = n[Symbol.iterator]();
|
|
2320
2322
|
this._iterator = async function* () {
|
|
2321
2323
|
for (; ; ) {
|
|
2322
|
-
const
|
|
2323
|
-
if (
|
|
2324
|
-
return
|
|
2325
|
-
yield
|
|
2324
|
+
const t = e.next();
|
|
2325
|
+
if (t.done)
|
|
2326
|
+
return t.value;
|
|
2327
|
+
yield t.value;
|
|
2326
2328
|
}
|
|
2327
2329
|
}();
|
|
2328
2330
|
} else
|
|
2329
2331
|
this._iterator = async function* () {
|
|
2330
2332
|
let e = [];
|
|
2331
2333
|
for (; ; ) {
|
|
2332
|
-
const
|
|
2333
|
-
if (
|
|
2334
|
-
return
|
|
2335
|
-
e = [yield
|
|
2334
|
+
const t = await n.next(...e);
|
|
2335
|
+
if (t.done)
|
|
2336
|
+
return t.value;
|
|
2337
|
+
e = [yield t.value];
|
|
2336
2338
|
}
|
|
2337
2339
|
}();
|
|
2338
2340
|
}
|
|
@@ -2366,13 +2368,13 @@ class f {
|
|
|
2366
2368
|
* @returns
|
|
2367
2369
|
* A {@link Promise} that will resolve to `true` if all elements satisfy the condition, `false` otherwise.
|
|
2368
2370
|
*/
|
|
2369
|
-
async every(
|
|
2371
|
+
async every(n) {
|
|
2370
2372
|
let e = 0;
|
|
2371
2373
|
for (; ; ) {
|
|
2372
|
-
const
|
|
2373
|
-
if (
|
|
2374
|
+
const t = await this._iterator.next();
|
|
2375
|
+
if (t.done)
|
|
2374
2376
|
return !0;
|
|
2375
|
-
if (!await t
|
|
2377
|
+
if (!await n(t.value, e))
|
|
2376
2378
|
return !1;
|
|
2377
2379
|
e += 1;
|
|
2378
2380
|
}
|
|
@@ -2407,26 +2409,26 @@ class f {
|
|
|
2407
2409
|
* @returns
|
|
2408
2410
|
* A {@link Promise} that will resolve to `true` if any element satisfies the condition, `false` otherwise.
|
|
2409
2411
|
*/
|
|
2410
|
-
async some(
|
|
2412
|
+
async some(n) {
|
|
2411
2413
|
let e = 0;
|
|
2412
2414
|
for (; ; ) {
|
|
2413
|
-
const
|
|
2414
|
-
if (
|
|
2415
|
+
const t = await this._iterator.next();
|
|
2416
|
+
if (t.done)
|
|
2415
2417
|
return !1;
|
|
2416
|
-
if (await t
|
|
2418
|
+
if (await n(t.value, e))
|
|
2417
2419
|
return !0;
|
|
2418
2420
|
e += 1;
|
|
2419
2421
|
}
|
|
2420
2422
|
}
|
|
2421
|
-
filter(
|
|
2423
|
+
filter(n) {
|
|
2422
2424
|
const e = this._iterator;
|
|
2423
2425
|
return new f(async function* () {
|
|
2424
|
-
let
|
|
2426
|
+
let t = 0;
|
|
2425
2427
|
for (; ; ) {
|
|
2426
2428
|
const s = await e.next();
|
|
2427
2429
|
if (s.done)
|
|
2428
2430
|
return s.value;
|
|
2429
|
-
await
|
|
2431
|
+
await n(s.value, t) && (yield s.value), t += 1;
|
|
2430
2432
|
}
|
|
2431
2433
|
});
|
|
2432
2434
|
}
|
|
@@ -2461,31 +2463,31 @@ class f {
|
|
|
2461
2463
|
*
|
|
2462
2464
|
* @returns A new {@link SmartAsyncIterator} containing the transformed elements.
|
|
2463
2465
|
*/
|
|
2464
|
-
map(
|
|
2466
|
+
map(n) {
|
|
2465
2467
|
const e = this._iterator;
|
|
2466
2468
|
return new f(async function* () {
|
|
2467
|
-
let
|
|
2469
|
+
let t = 0;
|
|
2468
2470
|
for (; ; ) {
|
|
2469
2471
|
const s = await e.next();
|
|
2470
2472
|
if (s.done)
|
|
2471
2473
|
return s.value;
|
|
2472
|
-
yield await
|
|
2474
|
+
yield await n(s.value, t), t += 1;
|
|
2473
2475
|
}
|
|
2474
2476
|
});
|
|
2475
2477
|
}
|
|
2476
|
-
async reduce(
|
|
2477
|
-
let
|
|
2478
|
+
async reduce(n, e) {
|
|
2479
|
+
let t = 0, s = e;
|
|
2478
2480
|
if (s === void 0) {
|
|
2479
2481
|
const r = await this._iterator.next();
|
|
2480
2482
|
if (r.done)
|
|
2481
2483
|
throw new d("Cannot reduce an empty iterator without an initial value.");
|
|
2482
|
-
s = r.value,
|
|
2484
|
+
s = r.value, t += 1;
|
|
2483
2485
|
}
|
|
2484
2486
|
for (; ; ) {
|
|
2485
2487
|
const r = await this._iterator.next();
|
|
2486
2488
|
if (r.done)
|
|
2487
2489
|
return s;
|
|
2488
|
-
s = await
|
|
2490
|
+
s = await n(s, r.value, t), t += 1;
|
|
2489
2491
|
}
|
|
2490
2492
|
}
|
|
2491
2493
|
/**
|
|
@@ -2519,21 +2521,21 @@ class f {
|
|
|
2519
2521
|
*
|
|
2520
2522
|
* @returns A new {@link SmartAsyncIterator} containing the flattened elements.
|
|
2521
2523
|
*/
|
|
2522
|
-
flatMap(
|
|
2524
|
+
flatMap(n) {
|
|
2523
2525
|
const e = this._iterator;
|
|
2524
2526
|
return new f(async function* () {
|
|
2525
|
-
let
|
|
2527
|
+
let t = 0;
|
|
2526
2528
|
for (; ; ) {
|
|
2527
2529
|
const s = await e.next();
|
|
2528
2530
|
if (s.done)
|
|
2529
2531
|
return s.value;
|
|
2530
|
-
const r = await
|
|
2532
|
+
const r = await n(s.value, t);
|
|
2531
2533
|
if (r instanceof Array)
|
|
2532
2534
|
for (const o of r)
|
|
2533
2535
|
yield o;
|
|
2534
2536
|
else
|
|
2535
2537
|
yield r;
|
|
2536
|
-
|
|
2538
|
+
t += 1;
|
|
2537
2539
|
}
|
|
2538
2540
|
});
|
|
2539
2541
|
}
|
|
@@ -2568,14 +2570,14 @@ class f {
|
|
|
2568
2570
|
*
|
|
2569
2571
|
* @returns A new {@link SmartAsyncIterator} containing the remaining elements.
|
|
2570
2572
|
*/
|
|
2571
|
-
drop(
|
|
2573
|
+
drop(n) {
|
|
2572
2574
|
const e = this._iterator;
|
|
2573
2575
|
return new f(async function* () {
|
|
2574
|
-
let
|
|
2575
|
-
for (;
|
|
2576
|
+
let t = 0;
|
|
2577
|
+
for (; t < n; ) {
|
|
2576
2578
|
if ((await e.next()).done)
|
|
2577
2579
|
return;
|
|
2578
|
-
|
|
2580
|
+
t += 1;
|
|
2579
2581
|
}
|
|
2580
2582
|
for (; ; ) {
|
|
2581
2583
|
const s = await e.next();
|
|
@@ -2617,26 +2619,26 @@ class f {
|
|
|
2617
2619
|
*
|
|
2618
2620
|
* @returns A new {@link SmartAsyncIterator} containing the taken elements.
|
|
2619
2621
|
*/
|
|
2620
|
-
take(
|
|
2622
|
+
take(n) {
|
|
2621
2623
|
const e = this._iterator;
|
|
2622
2624
|
return new f(async function* () {
|
|
2623
|
-
let
|
|
2624
|
-
for (;
|
|
2625
|
+
let t = 0;
|
|
2626
|
+
for (; t < n; ) {
|
|
2625
2627
|
const s = await e.next();
|
|
2626
2628
|
if (s.done)
|
|
2627
2629
|
return s.value;
|
|
2628
|
-
yield s.value,
|
|
2630
|
+
yield s.value, t += 1;
|
|
2629
2631
|
}
|
|
2630
2632
|
});
|
|
2631
2633
|
}
|
|
2632
|
-
async find(
|
|
2634
|
+
async find(n) {
|
|
2633
2635
|
let e = 0;
|
|
2634
2636
|
for (; ; ) {
|
|
2635
|
-
const
|
|
2636
|
-
if (
|
|
2637
|
+
const t = await this._iterator.next();
|
|
2638
|
+
if (t.done)
|
|
2637
2639
|
return;
|
|
2638
|
-
if (await t
|
|
2639
|
-
return
|
|
2640
|
+
if (await n(t.value, e))
|
|
2641
|
+
return t.value;
|
|
2640
2642
|
e += 1;
|
|
2641
2643
|
}
|
|
2642
2644
|
}
|
|
@@ -2669,7 +2671,7 @@ class f {
|
|
|
2669
2671
|
* @returns A new {@link SmartAsyncIterator} containing the enumerated elements.
|
|
2670
2672
|
*/
|
|
2671
2673
|
enumerate() {
|
|
2672
|
-
return this.map((
|
|
2674
|
+
return this.map((n, e) => [e, n]);
|
|
2673
2675
|
}
|
|
2674
2676
|
/**
|
|
2675
2677
|
* Removes all duplicate elements from the iterator.
|
|
@@ -2697,14 +2699,14 @@ class f {
|
|
|
2697
2699
|
* @returns A new {@link SmartAsyncIterator} containing only the unique elements.
|
|
2698
2700
|
*/
|
|
2699
2701
|
unique() {
|
|
2700
|
-
const
|
|
2702
|
+
const n = this._iterator;
|
|
2701
2703
|
return new f(async function* () {
|
|
2702
2704
|
const e = /* @__PURE__ */ new Set();
|
|
2703
2705
|
for (; ; ) {
|
|
2704
|
-
const
|
|
2705
|
-
if (
|
|
2706
|
-
return
|
|
2707
|
-
e.has(
|
|
2706
|
+
const t = await n.next();
|
|
2707
|
+
if (t.done)
|
|
2708
|
+
return t.value;
|
|
2709
|
+
e.has(t.value) || (e.add(t.value), yield t.value);
|
|
2708
2710
|
}
|
|
2709
2711
|
});
|
|
2710
2712
|
}
|
|
@@ -2729,11 +2731,11 @@ class f {
|
|
|
2729
2731
|
* @returns A {@link Promise} that will resolve to the number of elements in the iterator.
|
|
2730
2732
|
*/
|
|
2731
2733
|
async count() {
|
|
2732
|
-
let
|
|
2734
|
+
let n = 0;
|
|
2733
2735
|
for (; ; ) {
|
|
2734
2736
|
if ((await this._iterator.next()).done)
|
|
2735
|
-
return
|
|
2736
|
-
|
|
2737
|
+
return n;
|
|
2738
|
+
n += 1;
|
|
2737
2739
|
}
|
|
2738
2740
|
}
|
|
2739
2741
|
/**
|
|
@@ -2760,13 +2762,13 @@ class f {
|
|
|
2760
2762
|
*
|
|
2761
2763
|
* @returns A {@link Promise} that will resolve once the iteration is complete.
|
|
2762
2764
|
*/
|
|
2763
|
-
async forEach(
|
|
2765
|
+
async forEach(n) {
|
|
2764
2766
|
let e = 0;
|
|
2765
2767
|
for (; ; ) {
|
|
2766
|
-
const
|
|
2767
|
-
if (
|
|
2768
|
+
const t = await this._iterator.next();
|
|
2769
|
+
if (t.done)
|
|
2768
2770
|
return;
|
|
2769
|
-
await t
|
|
2771
|
+
await n(t.value, e), e += 1;
|
|
2770
2772
|
}
|
|
2771
2773
|
}
|
|
2772
2774
|
/**
|
|
@@ -2799,8 +2801,8 @@ class f {
|
|
|
2799
2801
|
* @returns
|
|
2800
2802
|
* A {@link Promise} that will resolve to the result of the iteration, containing the value of the operation.
|
|
2801
2803
|
*/
|
|
2802
|
-
next(...
|
|
2803
|
-
return this._iterator.next(...
|
|
2804
|
+
next(...n) {
|
|
2805
|
+
return this._iterator.next(...n);
|
|
2804
2806
|
}
|
|
2805
2807
|
/**
|
|
2806
2808
|
* An utility method that may be used to close the iterator gracefully,
|
|
@@ -2834,8 +2836,8 @@ class f {
|
|
|
2834
2836
|
*
|
|
2835
2837
|
* @returns A {@link Promise} that will resolve to the final result of the iterator.
|
|
2836
2838
|
*/
|
|
2837
|
-
async return(
|
|
2838
|
-
const e = await
|
|
2839
|
+
async return(n) {
|
|
2840
|
+
const e = await n;
|
|
2839
2841
|
return this._iterator.return ? await this._iterator.return(e) : { done: !0, value: e };
|
|
2840
2842
|
}
|
|
2841
2843
|
/**
|
|
@@ -2879,10 +2881,10 @@ class f {
|
|
|
2879
2881
|
*
|
|
2880
2882
|
* @returns A {@link Promise} that will resolve to the final result of the iterator.
|
|
2881
2883
|
*/
|
|
2882
|
-
throw(
|
|
2884
|
+
throw(n) {
|
|
2883
2885
|
if (this._iterator.throw)
|
|
2884
|
-
return this._iterator.throw(
|
|
2885
|
-
throw
|
|
2886
|
+
return this._iterator.throw(n);
|
|
2887
|
+
throw n;
|
|
2886
2888
|
}
|
|
2887
2889
|
/**
|
|
2888
2890
|
* An utility method that aggregates the elements of the iterator using a given key function.
|
|
@@ -2914,8 +2916,8 @@ class f {
|
|
|
2914
2916
|
*
|
|
2915
2917
|
* @returns A new instance of the {@link AggregatedAsyncIterator} class containing the grouped elements.
|
|
2916
2918
|
*/
|
|
2917
|
-
groupBy(
|
|
2918
|
-
return new
|
|
2919
|
+
groupBy(n) {
|
|
2920
|
+
return new E(this.map(async (e, t) => [await n(e, t), e]));
|
|
2919
2921
|
}
|
|
2920
2922
|
/**
|
|
2921
2923
|
* Materializes the iterator into an array.
|
|
@@ -2943,20 +2945,20 @@ class f {
|
|
|
2943
2945
|
toArray() {
|
|
2944
2946
|
return Array.fromAsync(this);
|
|
2945
2947
|
}
|
|
2946
|
-
[(
|
|
2948
|
+
[(pe = Symbol.toStringTag, Symbol.asyncIterator)]() {
|
|
2947
2949
|
return this;
|
|
2948
2950
|
}
|
|
2949
2951
|
}
|
|
2950
|
-
var
|
|
2951
|
-
|
|
2952
|
+
var ye;
|
|
2953
|
+
ye = Symbol.toStringTag;
|
|
2952
2954
|
const m = class m {
|
|
2953
|
-
constructor(
|
|
2955
|
+
constructor(n) {
|
|
2954
2956
|
/**
|
|
2955
2957
|
* The internal {@link SmartIterator} object that holds the elements to aggregate.
|
|
2956
2958
|
*/
|
|
2957
2959
|
a(this, "_elements");
|
|
2958
|
-
a(this,
|
|
2959
|
-
this._elements = new
|
|
2960
|
+
a(this, ye, "AggregatedIterator");
|
|
2961
|
+
this._elements = new u(n);
|
|
2960
2962
|
}
|
|
2961
2963
|
/**
|
|
2962
2964
|
* Determines whether all elements of each group of the iterator satisfy a given condition.
|
|
@@ -2988,15 +2990,15 @@ const m = class m {
|
|
|
2988
2990
|
*
|
|
2989
2991
|
* @returns A new {@link ReducedIterator} containing the boolean results for each group.
|
|
2990
2992
|
*/
|
|
2991
|
-
every(
|
|
2993
|
+
every(n) {
|
|
2992
2994
|
const e = /* @__PURE__ */ new Map();
|
|
2993
|
-
for (const [
|
|
2994
|
-
const [r, o] = e.get(
|
|
2995
|
-
o && e.set(
|
|
2995
|
+
for (const [t, s] of this._elements) {
|
|
2996
|
+
const [r, o] = e.get(t) ?? [0, !0];
|
|
2997
|
+
o && e.set(t, [r + 1, n(t, s, r)]);
|
|
2996
2998
|
}
|
|
2997
2999
|
return new h(function* () {
|
|
2998
|
-
for (const [
|
|
2999
|
-
yield [
|
|
3000
|
+
for (const [t, [s, r]] of e)
|
|
3001
|
+
yield [t, r];
|
|
3000
3002
|
});
|
|
3001
3003
|
}
|
|
3002
3004
|
/**
|
|
@@ -3029,24 +3031,24 @@ const m = class m {
|
|
|
3029
3031
|
*
|
|
3030
3032
|
* @returns A {@link ReducedIterator} containing the boolean results for each group.
|
|
3031
3033
|
*/
|
|
3032
|
-
some(
|
|
3034
|
+
some(n) {
|
|
3033
3035
|
const e = /* @__PURE__ */ new Map();
|
|
3034
|
-
for (const [
|
|
3035
|
-
const [r, o] = e.get(
|
|
3036
|
-
o || e.set(
|
|
3036
|
+
for (const [t, s] of this._elements) {
|
|
3037
|
+
const [r, o] = e.get(t) ?? [0, !1];
|
|
3038
|
+
o || e.set(t, [r + 1, n(t, s, r)]);
|
|
3037
3039
|
}
|
|
3038
3040
|
return new h(function* () {
|
|
3039
|
-
for (const [
|
|
3040
|
-
yield [
|
|
3041
|
+
for (const [t, [s, r]] of e)
|
|
3042
|
+
yield [t, r];
|
|
3041
3043
|
});
|
|
3042
3044
|
}
|
|
3043
|
-
filter(
|
|
3045
|
+
filter(n) {
|
|
3044
3046
|
const e = this._elements;
|
|
3045
3047
|
return new m(function* () {
|
|
3046
|
-
const
|
|
3048
|
+
const t = /* @__PURE__ */ new Map();
|
|
3047
3049
|
for (const [s, r] of e) {
|
|
3048
|
-
const o =
|
|
3049
|
-
|
|
3050
|
+
const o = t.get(s) ?? 0;
|
|
3051
|
+
n(s, r, o) && (yield [s, r]), t.set(s, o + 1);
|
|
3050
3052
|
}
|
|
3051
3053
|
});
|
|
3052
3054
|
}
|
|
@@ -3082,32 +3084,32 @@ const m = class m {
|
|
|
3082
3084
|
*
|
|
3083
3085
|
* @returns A new {@link AggregatedIterator} containing the transformed elements.
|
|
3084
3086
|
*/
|
|
3085
|
-
map(
|
|
3087
|
+
map(n) {
|
|
3086
3088
|
const e = this._elements;
|
|
3087
3089
|
return new m(function* () {
|
|
3088
|
-
const
|
|
3090
|
+
const t = /* @__PURE__ */ new Map();
|
|
3089
3091
|
for (const [s, r] of e) {
|
|
3090
|
-
const o =
|
|
3091
|
-
yield [s,
|
|
3092
|
+
const o = t.get(s) ?? 0;
|
|
3093
|
+
yield [s, n(s, r, o)], t.set(s, o + 1);
|
|
3092
3094
|
}
|
|
3093
3095
|
});
|
|
3094
3096
|
}
|
|
3095
|
-
reduce(
|
|
3096
|
-
const
|
|
3097
|
+
reduce(n, e) {
|
|
3098
|
+
const t = /* @__PURE__ */ new Map();
|
|
3097
3099
|
for (const [s, r] of this._elements) {
|
|
3098
3100
|
let o, l;
|
|
3099
|
-
if (
|
|
3100
|
-
[o, l] =
|
|
3101
|
+
if (t.has(s))
|
|
3102
|
+
[o, l] = t.get(s);
|
|
3101
3103
|
else if (e !== void 0)
|
|
3102
3104
|
o = 0, e instanceof Function ? l = e(s) : l = e;
|
|
3103
3105
|
else {
|
|
3104
|
-
|
|
3106
|
+
t.set(s, [0, r]);
|
|
3105
3107
|
continue;
|
|
3106
3108
|
}
|
|
3107
|
-
|
|
3109
|
+
t.set(s, [o + 1, n(s, l, r, o)]);
|
|
3108
3110
|
}
|
|
3109
3111
|
return new h(function* () {
|
|
3110
|
-
for (const [s, [r, o]] of
|
|
3112
|
+
for (const [s, [r, o]] of t)
|
|
3111
3113
|
yield [s, o];
|
|
3112
3114
|
});
|
|
3113
3115
|
}
|
|
@@ -3147,18 +3149,18 @@ const m = class m {
|
|
|
3147
3149
|
*
|
|
3148
3150
|
* @returns A new {@link AggregatedIterator} containing the transformed elements.
|
|
3149
3151
|
*/
|
|
3150
|
-
flatMap(
|
|
3152
|
+
flatMap(n) {
|
|
3151
3153
|
const e = this._elements;
|
|
3152
3154
|
return new m(function* () {
|
|
3153
|
-
const
|
|
3155
|
+
const t = /* @__PURE__ */ new Map();
|
|
3154
3156
|
for (const [s, r] of e) {
|
|
3155
|
-
const o =
|
|
3157
|
+
const o = t.get(s) ?? 0, l = n(s, r, o);
|
|
3156
3158
|
if (l instanceof Array)
|
|
3157
|
-
for (const
|
|
3158
|
-
yield [s,
|
|
3159
|
+
for (const k of l)
|
|
3160
|
+
yield [s, k];
|
|
3159
3161
|
else
|
|
3160
3162
|
yield [s, l];
|
|
3161
|
-
|
|
3163
|
+
t.set(s, o + 1);
|
|
3162
3164
|
}
|
|
3163
3165
|
});
|
|
3164
3166
|
}
|
|
@@ -3191,14 +3193,14 @@ const m = class m {
|
|
|
3191
3193
|
*
|
|
3192
3194
|
* @returns A new {@link AggregatedIterator} containing the remaining elements.
|
|
3193
3195
|
*/
|
|
3194
|
-
drop(
|
|
3196
|
+
drop(n) {
|
|
3195
3197
|
const e = this._elements;
|
|
3196
3198
|
return new m(function* () {
|
|
3197
|
-
const
|
|
3199
|
+
const t = /* @__PURE__ */ new Map();
|
|
3198
3200
|
for (const [s, r] of e) {
|
|
3199
|
-
const o =
|
|
3200
|
-
if (o <
|
|
3201
|
-
|
|
3201
|
+
const o = t.get(s) ?? 0;
|
|
3202
|
+
if (o < n) {
|
|
3203
|
+
t.set(s, o + 1);
|
|
3202
3204
|
continue;
|
|
3203
3205
|
}
|
|
3204
3206
|
yield [s, r];
|
|
@@ -3234,25 +3236,25 @@ const m = class m {
|
|
|
3234
3236
|
*
|
|
3235
3237
|
* @returns A new {@link AggregatedIterator} containing the taken elements.
|
|
3236
3238
|
*/
|
|
3237
|
-
take(
|
|
3239
|
+
take(n) {
|
|
3238
3240
|
const e = this._elements;
|
|
3239
3241
|
return new m(function* () {
|
|
3240
|
-
const
|
|
3242
|
+
const t = /* @__PURE__ */ new Map();
|
|
3241
3243
|
for (const [s, r] of e) {
|
|
3242
|
-
const o =
|
|
3243
|
-
o >=
|
|
3244
|
+
const o = t.get(s) ?? 0;
|
|
3245
|
+
o >= n || (yield [s, r], t.set(s, o + 1));
|
|
3244
3246
|
}
|
|
3245
3247
|
});
|
|
3246
3248
|
}
|
|
3247
|
-
find(
|
|
3249
|
+
find(n) {
|
|
3248
3250
|
const e = /* @__PURE__ */ new Map();
|
|
3249
|
-
for (const [
|
|
3250
|
-
let [r, o] = e.get(
|
|
3251
|
-
o === void 0 && (t
|
|
3251
|
+
for (const [t, s] of this._elements) {
|
|
3252
|
+
let [r, o] = e.get(t) ?? [0, void 0];
|
|
3253
|
+
o === void 0 && (n(t, s, r) && (o = s), e.set(t, [r + 1, o]));
|
|
3252
3254
|
}
|
|
3253
3255
|
return new h(function* () {
|
|
3254
|
-
for (const [
|
|
3255
|
-
yield [
|
|
3256
|
+
for (const [t, [s, r]] of e)
|
|
3257
|
+
yield [t, r];
|
|
3256
3258
|
});
|
|
3257
3259
|
}
|
|
3258
3260
|
/**
|
|
@@ -3282,7 +3284,7 @@ const m = class m {
|
|
|
3282
3284
|
* @returns A new {@link AggregatedIterator} containing the enumerated elements.
|
|
3283
3285
|
*/
|
|
3284
3286
|
enumerate() {
|
|
3285
|
-
return this.map((
|
|
3287
|
+
return this.map((n, e, t) => [t, e]);
|
|
3286
3288
|
}
|
|
3287
3289
|
/**
|
|
3288
3290
|
* Removes all duplicate elements from within each group of the iterator.
|
|
@@ -3311,12 +3313,12 @@ const m = class m {
|
|
|
3311
3313
|
* @returns A new {@link AggregatedIterator} containing only the unique elements.
|
|
3312
3314
|
*/
|
|
3313
3315
|
unique() {
|
|
3314
|
-
const
|
|
3316
|
+
const n = this._elements;
|
|
3315
3317
|
return new m(function* () {
|
|
3316
3318
|
const e = /* @__PURE__ */ new Map();
|
|
3317
|
-
for (const [
|
|
3318
|
-
const r = e.get(
|
|
3319
|
-
r.has(s) || (r.add(s), e.set(
|
|
3319
|
+
for (const [t, s] of n) {
|
|
3320
|
+
const r = e.get(t) ?? /* @__PURE__ */ new Set();
|
|
3321
|
+
r.has(s) || (r.add(s), e.set(t, r), yield [t, s]);
|
|
3320
3322
|
}
|
|
3321
3323
|
});
|
|
3322
3324
|
}
|
|
@@ -3342,14 +3344,14 @@ const m = class m {
|
|
|
3342
3344
|
* @returns A new {@link ReducedIterator} containing the number of elements for each group.
|
|
3343
3345
|
*/
|
|
3344
3346
|
count() {
|
|
3345
|
-
const
|
|
3347
|
+
const n = /* @__PURE__ */ new Map();
|
|
3346
3348
|
for (const [e] of this._elements) {
|
|
3347
|
-
const
|
|
3348
|
-
|
|
3349
|
+
const t = n.get(e) ?? 0;
|
|
3350
|
+
n.set(e, t + 1);
|
|
3349
3351
|
}
|
|
3350
3352
|
return new h(function* () {
|
|
3351
|
-
for (const [e,
|
|
3352
|
-
yield [e,
|
|
3353
|
+
for (const [e, t] of n)
|
|
3354
|
+
yield [e, t];
|
|
3353
3355
|
});
|
|
3354
3356
|
}
|
|
3355
3357
|
/**
|
|
@@ -3376,11 +3378,11 @@ const m = class m {
|
|
|
3376
3378
|
*
|
|
3377
3379
|
* @param iteratee The function to execute for each element of the iterator.
|
|
3378
3380
|
*/
|
|
3379
|
-
forEach(
|
|
3381
|
+
forEach(n) {
|
|
3380
3382
|
const e = /* @__PURE__ */ new Map();
|
|
3381
|
-
for (const [
|
|
3382
|
-
const r = e.get(
|
|
3383
|
-
t
|
|
3383
|
+
for (const [t, s] of this._elements) {
|
|
3384
|
+
const r = e.get(t) ?? 0;
|
|
3385
|
+
n(t, s, r), e.set(t, r + 1);
|
|
3384
3386
|
}
|
|
3385
3387
|
}
|
|
3386
3388
|
/**
|
|
@@ -3414,13 +3416,13 @@ const m = class m {
|
|
|
3414
3416
|
*
|
|
3415
3417
|
* @returns A new {@link AggregatedIterator} containing the elements reorganized by the new keys.
|
|
3416
3418
|
*/
|
|
3417
|
-
reorganizeBy(
|
|
3419
|
+
reorganizeBy(n) {
|
|
3418
3420
|
const e = this._elements;
|
|
3419
3421
|
return new m(function* () {
|
|
3420
|
-
const
|
|
3422
|
+
const t = /* @__PURE__ */ new Map();
|
|
3421
3423
|
for (const [s, r] of e) {
|
|
3422
|
-
const o =
|
|
3423
|
-
yield [
|
|
3424
|
+
const o = t.get(s) ?? 0;
|
|
3425
|
+
yield [n(s, r, o), r], t.set(s, o + 1);
|
|
3424
3426
|
}
|
|
3425
3427
|
});
|
|
3426
3428
|
}
|
|
@@ -3451,11 +3453,11 @@ const m = class m {
|
|
|
3451
3453
|
* @returns A new {@link SmartIterator} containing all the keys of the iterator.
|
|
3452
3454
|
*/
|
|
3453
3455
|
keys() {
|
|
3454
|
-
const
|
|
3455
|
-
return new
|
|
3456
|
+
const n = this._elements;
|
|
3457
|
+
return new u(function* () {
|
|
3456
3458
|
const e = /* @__PURE__ */ new Set();
|
|
3457
|
-
for (const [
|
|
3458
|
-
e.has(
|
|
3459
|
+
for (const [t] of n)
|
|
3460
|
+
e.has(t) || (e.add(t), yield t);
|
|
3459
3461
|
});
|
|
3460
3462
|
}
|
|
3461
3463
|
/**
|
|
@@ -3515,10 +3517,10 @@ const m = class m {
|
|
|
3515
3517
|
* @returns A new {@link SmartIterator} containing all the values of the iterator.
|
|
3516
3518
|
*/
|
|
3517
3519
|
values() {
|
|
3518
|
-
const
|
|
3519
|
-
return new
|
|
3520
|
-
for (const [e,
|
|
3521
|
-
yield
|
|
3520
|
+
const n = this._elements;
|
|
3521
|
+
return new u(function* () {
|
|
3522
|
+
for (const [e, t] of n)
|
|
3523
|
+
yield t;
|
|
3522
3524
|
});
|
|
3523
3525
|
}
|
|
3524
3526
|
/**
|
|
@@ -3542,8 +3544,8 @@ const m = class m {
|
|
|
3542
3544
|
* @returns An {@link Array} of arrays containing the elements of the iterator.
|
|
3543
3545
|
*/
|
|
3544
3546
|
toArray() {
|
|
3545
|
-
const
|
|
3546
|
-
return Array.from(
|
|
3547
|
+
const n = this.toMap();
|
|
3548
|
+
return Array.from(n.values());
|
|
3547
3549
|
}
|
|
3548
3550
|
/**
|
|
3549
3551
|
* Materializes the iterator into a map.
|
|
@@ -3566,12 +3568,12 @@ const m = class m {
|
|
|
3566
3568
|
* @returns A {@link Map} containing the elements of the iterator.
|
|
3567
3569
|
*/
|
|
3568
3570
|
toMap() {
|
|
3569
|
-
const
|
|
3570
|
-
for (const [e,
|
|
3571
|
-
const s =
|
|
3572
|
-
s.push(
|
|
3571
|
+
const n = /* @__PURE__ */ new Map();
|
|
3572
|
+
for (const [e, t] of this._elements) {
|
|
3573
|
+
const s = n.get(e) ?? [];
|
|
3574
|
+
s.push(t), n.set(e, s);
|
|
3573
3575
|
}
|
|
3574
|
-
return
|
|
3576
|
+
return n;
|
|
3575
3577
|
}
|
|
3576
3578
|
/**
|
|
3577
3579
|
* Materializes the iterator into an object.
|
|
@@ -3594,31 +3596,31 @@ const m = class m {
|
|
|
3594
3596
|
* @returns An {@link Object} containing the elements of the iterator.
|
|
3595
3597
|
*/
|
|
3596
3598
|
toObject() {
|
|
3597
|
-
const
|
|
3598
|
-
for (const [e,
|
|
3599
|
-
const s =
|
|
3600
|
-
s.push(
|
|
3599
|
+
const n = {};
|
|
3600
|
+
for (const [e, t] of this._elements) {
|
|
3601
|
+
const s = n[e] ?? [];
|
|
3602
|
+
s.push(t), n[e] = s;
|
|
3601
3603
|
}
|
|
3602
|
-
return
|
|
3604
|
+
return n;
|
|
3603
3605
|
}
|
|
3604
3606
|
};
|
|
3605
|
-
let
|
|
3606
|
-
const
|
|
3607
|
-
var
|
|
3608
|
-
class
|
|
3607
|
+
let x = m;
|
|
3608
|
+
const He = Function;
|
|
3609
|
+
var _e, be;
|
|
3610
|
+
class Qe extends (be = He, _e = Symbol.toStringTag, be) {
|
|
3609
3611
|
/**
|
|
3610
3612
|
* Initializes a new instance of the {@link CallableObject} class.
|
|
3611
3613
|
*/
|
|
3612
3614
|
constructor() {
|
|
3613
3615
|
super("return this._invoke(...arguments);");
|
|
3614
|
-
a(this,
|
|
3616
|
+
a(this, _e, "CallableObject");
|
|
3615
3617
|
const e = this.bind(this);
|
|
3616
3618
|
return Object.setPrototypeOf(this, e), e;
|
|
3617
3619
|
}
|
|
3618
3620
|
}
|
|
3619
|
-
var
|
|
3620
|
-
|
|
3621
|
-
class
|
|
3621
|
+
var ge;
|
|
3622
|
+
ge = Symbol.toStringTag;
|
|
3623
|
+
class v {
|
|
3622
3624
|
/**
|
|
3623
3625
|
* Initializes a new instance of the {@link Publisher} class.
|
|
3624
3626
|
*
|
|
@@ -3637,7 +3639,7 @@ class E {
|
|
|
3637
3639
|
* The values are the arrays of the subscribers themselves.
|
|
3638
3640
|
*/
|
|
3639
3641
|
a(this, "_subscribers");
|
|
3640
|
-
a(this,
|
|
3642
|
+
a(this, ge, "Publisher");
|
|
3641
3643
|
this._subscribers = /* @__PURE__ */ new Map();
|
|
3642
3644
|
}
|
|
3643
3645
|
/**
|
|
@@ -3686,12 +3688,12 @@ class E {
|
|
|
3686
3688
|
*
|
|
3687
3689
|
* @returns An array containing the return values of all the subscribers.
|
|
3688
3690
|
*/
|
|
3689
|
-
publish(
|
|
3690
|
-
const
|
|
3691
|
-
return
|
|
3691
|
+
publish(n, ...e) {
|
|
3692
|
+
const t = this._subscribers.get(n);
|
|
3693
|
+
return t ? t.slice().map((s) => s(...e)) : [];
|
|
3692
3694
|
}
|
|
3693
3695
|
/**
|
|
3694
|
-
* Subscribes a
|
|
3696
|
+
* Subscribes to an event and adds a subscriber to be executed when the event is published.
|
|
3695
3697
|
*
|
|
3696
3698
|
* ---
|
|
3697
3699
|
*
|
|
@@ -3710,22 +3712,22 @@ class E {
|
|
|
3710
3712
|
* @template K The key of the map containing the callback signature to subscribe.
|
|
3711
3713
|
*
|
|
3712
3714
|
* @param event The name of the event to subscribe to.
|
|
3713
|
-
* @param subscriber The subscriber to
|
|
3715
|
+
* @param subscriber The subscriber to execute when the event is published.
|
|
3714
3716
|
*
|
|
3715
|
-
* @returns A function that can be used to unsubscribe the subscriber.
|
|
3717
|
+
* @returns A function that can be used to unsubscribe the subscriber from the event.
|
|
3716
3718
|
*/
|
|
3717
|
-
subscribe(
|
|
3718
|
-
this._subscribers.has(
|
|
3719
|
-
const
|
|
3720
|
-
return
|
|
3721
|
-
const s =
|
|
3719
|
+
subscribe(n, e) {
|
|
3720
|
+
this._subscribers.has(n) || this._subscribers.set(n, []);
|
|
3721
|
+
const t = this._subscribers.get(n);
|
|
3722
|
+
return t.push(e), () => {
|
|
3723
|
+
const s = t.indexOf(e);
|
|
3722
3724
|
if (s < 0)
|
|
3723
3725
|
throw new C("Unable to unsubscribe the required subscriber. The subscription was already unsubscribed.");
|
|
3724
|
-
|
|
3726
|
+
t.splice(s, 1);
|
|
3725
3727
|
};
|
|
3726
3728
|
}
|
|
3727
3729
|
/**
|
|
3728
|
-
* Unsubscribes a subscriber from
|
|
3730
|
+
* Unsubscribes from an event and removes a subscriber from being executed when the event is published.
|
|
3729
3731
|
*
|
|
3730
3732
|
* ---
|
|
3731
3733
|
*
|
|
@@ -3744,21 +3746,21 @@ class E {
|
|
|
3744
3746
|
* @param event The name of the event to unsubscribe from.
|
|
3745
3747
|
* @param subscriber The subscriber to remove from the event.
|
|
3746
3748
|
*/
|
|
3747
|
-
unsubscribe(
|
|
3748
|
-
const
|
|
3749
|
-
if (!
|
|
3749
|
+
unsubscribe(n, e) {
|
|
3750
|
+
const t = this._subscribers.get(n);
|
|
3751
|
+
if (!t)
|
|
3750
3752
|
return;
|
|
3751
|
-
const s =
|
|
3753
|
+
const s = t.indexOf(e);
|
|
3752
3754
|
if (s < 0)
|
|
3753
3755
|
throw new C("Unable to unsubscribe the required subscriber. The subscription was already unsubscribed or was never subscribed.");
|
|
3754
|
-
|
|
3756
|
+
t.splice(s, 1);
|
|
3755
3757
|
}
|
|
3756
3758
|
}
|
|
3757
|
-
const
|
|
3759
|
+
const Xe = () => {
|
|
3758
3760
|
};
|
|
3759
|
-
var
|
|
3760
|
-
class
|
|
3761
|
-
constructor(e,
|
|
3761
|
+
var xe, ve;
|
|
3762
|
+
class ut extends (ve = Qe, xe = Symbol.toStringTag, ve) {
|
|
3763
|
+
constructor(e, t = "default") {
|
|
3762
3764
|
super();
|
|
3763
3765
|
/**
|
|
3764
3766
|
* The currently selected implementation of the callback.
|
|
@@ -3790,12 +3792,12 @@ class it extends (ve = Ge, ge = Symbol.toStringTag, ve) {
|
|
|
3790
3792
|
* The function that will be called by the extended class when the object is invoked as a function.
|
|
3791
3793
|
*/
|
|
3792
3794
|
a(this, "_invoke");
|
|
3793
|
-
a(this,
|
|
3794
|
-
this._callbacks = /* @__PURE__ */ new Map(), this._isEnabled = !0, e ? this._callbacks.set(
|
|
3795
|
-
throw new
|
|
3795
|
+
a(this, xe, "SwitchableCallback");
|
|
3796
|
+
this._callbacks = /* @__PURE__ */ new Map(), this._isEnabled = !0, e ? this._callbacks.set(t, e) : (t = "", e = () => {
|
|
3797
|
+
throw new Ve(
|
|
3796
3798
|
"The `SwitchableCallback` has no callback defined yet. Did you forget to call the `register` method?"
|
|
3797
3799
|
);
|
|
3798
|
-
}), this._key =
|
|
3800
|
+
}), this._key = t, this._callback = e, this._invoke = (...s) => this._callback(...s);
|
|
3799
3801
|
}
|
|
3800
3802
|
/**
|
|
3801
3803
|
* A flag indicating whether the callback is enabled or not.
|
|
@@ -3828,23 +3830,25 @@ class it extends (ve = Ge, ge = Symbol.toStringTag, ve) {
|
|
|
3828
3830
|
* window.addEventListener("pointerdown", () => { onPointerMove.enable(); });
|
|
3829
3831
|
* window.addEventListener("pointermove", onPointerMove);
|
|
3830
3832
|
* ```
|
|
3831
|
-
*
|
|
3833
|
+
*
|
|
3834
|
+
* ---
|
|
3835
|
+
*
|
|
3832
3836
|
* @param key
|
|
3833
3837
|
* The key that is associated with the implementation to enable. Default is the currently selected implementation.
|
|
3834
3838
|
*/
|
|
3835
3839
|
enable(e) {
|
|
3836
3840
|
if (e === void 0) {
|
|
3837
3841
|
if (!this._key)
|
|
3838
|
-
throw new
|
|
3842
|
+
throw new y(
|
|
3839
3843
|
"The `SwitchableCallback` has no callback defined yet. Did you forget to call the `register` method?"
|
|
3840
3844
|
);
|
|
3841
3845
|
e = this._key;
|
|
3842
3846
|
} else if (e) {
|
|
3843
3847
|
if (!this._callbacks.has(e))
|
|
3844
|
-
throw new
|
|
3845
|
-
} else throw new
|
|
3848
|
+
throw new y(`The key '${e}' doesn't yet have any associated callback.`);
|
|
3849
|
+
} else throw new y("The key must be a non-empty string.");
|
|
3846
3850
|
if (this._isEnabled)
|
|
3847
|
-
throw new
|
|
3851
|
+
throw new p("The `SwitchableCallback` is already enabled.");
|
|
3848
3852
|
this._callback = this._callbacks.get(e), this._isEnabled = !0;
|
|
3849
3853
|
}
|
|
3850
3854
|
/**
|
|
@@ -3862,8 +3866,8 @@ class it extends (ve = Ge, ge = Symbol.toStringTag, ve) {
|
|
|
3862
3866
|
*/
|
|
3863
3867
|
disable() {
|
|
3864
3868
|
if (!this._isEnabled)
|
|
3865
|
-
throw new
|
|
3866
|
-
this._callback =
|
|
3869
|
+
throw new p("The `SwitchableCallback` is already disabled.");
|
|
3870
|
+
this._callback = Xe, this._isEnabled = !1;
|
|
3867
3871
|
}
|
|
3868
3872
|
/**
|
|
3869
3873
|
* Registers a new implementation for the callback.
|
|
@@ -3885,12 +3889,12 @@ class it extends (ve = Ge, ge = Symbol.toStringTag, ve) {
|
|
|
3885
3889
|
* @param key The key that will be associated with the implementation.
|
|
3886
3890
|
* @param callback The implementation to register.
|
|
3887
3891
|
*/
|
|
3888
|
-
register(e,
|
|
3892
|
+
register(e, t) {
|
|
3889
3893
|
if (this._callbacks.size === 0)
|
|
3890
|
-
this._key = e, this._callback =
|
|
3894
|
+
this._key = e, this._callback = t;
|
|
3891
3895
|
else if (this._callbacks.has(e))
|
|
3892
|
-
throw new
|
|
3893
|
-
this._callbacks.set(e,
|
|
3896
|
+
throw new y(`The key '${e}' has already been used for another callback.`);
|
|
3897
|
+
this._callbacks.set(e, t);
|
|
3894
3898
|
}
|
|
3895
3899
|
/**
|
|
3896
3900
|
* Unregisters an implementation for the callback.
|
|
@@ -3912,9 +3916,9 @@ class it extends (ve = Ge, ge = Symbol.toStringTag, ve) {
|
|
|
3912
3916
|
*/
|
|
3913
3917
|
unregister(e) {
|
|
3914
3918
|
if (this._key === e)
|
|
3915
|
-
throw new
|
|
3919
|
+
throw new y("Unable to unregister the currently selected callback.");
|
|
3916
3920
|
if (!this._callbacks.has(e))
|
|
3917
|
-
throw new
|
|
3921
|
+
throw new y(`The key '${e}' doesn't yet have any associated callback.`);
|
|
3918
3922
|
this._callbacks.delete(e);
|
|
3919
3923
|
}
|
|
3920
3924
|
/**
|
|
@@ -3937,13 +3941,320 @@ class it extends (ve = Ge, ge = Symbol.toStringTag, ve) {
|
|
|
3937
3941
|
*/
|
|
3938
3942
|
switch(e) {
|
|
3939
3943
|
if (!this._callbacks.has(e))
|
|
3940
|
-
throw new
|
|
3941
|
-
this._key = e, this._isEnabled && (this._callback = this._callbacks.get(e));
|
|
3944
|
+
throw new y(`The key '${e}' doesn't yet have any associated callback.`);
|
|
3945
|
+
this._key !== e && (this._key = e, this._isEnabled && (this._callback = this._callbacks.get(e)));
|
|
3942
3946
|
}
|
|
3943
3947
|
}
|
|
3944
|
-
var ke;
|
|
3945
|
-
ke = Symbol.toStringTag
|
|
3946
|
-
|
|
3948
|
+
var ke, Se;
|
|
3949
|
+
class ct extends (Se = Map, ke = Symbol.toStringTag, Se) {
|
|
3950
|
+
/**
|
|
3951
|
+
* Initializes a new instance of the {@link MapView} class.
|
|
3952
|
+
*
|
|
3953
|
+
* ---
|
|
3954
|
+
*
|
|
3955
|
+
* @example
|
|
3956
|
+
* ```ts
|
|
3957
|
+
* const map = new MapView<string, number>([["key1", 2], ["key2", 4], ["key3", 8]]);
|
|
3958
|
+
* ```
|
|
3959
|
+
*
|
|
3960
|
+
* ---
|
|
3961
|
+
*
|
|
3962
|
+
* @param iterable An optional iterable of key-value pairs to initialize the {@link Map} with.
|
|
3963
|
+
*/
|
|
3964
|
+
constructor(e) {
|
|
3965
|
+
super();
|
|
3966
|
+
/**
|
|
3967
|
+
* The internal {@link Publisher} instance used to publish events.
|
|
3968
|
+
*/
|
|
3969
|
+
a(this, "_publisher");
|
|
3970
|
+
a(this, ke, "MapView");
|
|
3971
|
+
if (this._publisher = new v(), e)
|
|
3972
|
+
for (const [t, s] of e)
|
|
3973
|
+
this.set(t, s);
|
|
3974
|
+
}
|
|
3975
|
+
/**
|
|
3976
|
+
* Adds a new entry with a specified key and value to the {@link Map}.
|
|
3977
|
+
* If an entry with the same key already exists, the entry will be overwritten with the new value.
|
|
3978
|
+
*
|
|
3979
|
+
* ---
|
|
3980
|
+
*
|
|
3981
|
+
* @example
|
|
3982
|
+
* ```ts
|
|
3983
|
+
* const map = new MapView<string, number>();
|
|
3984
|
+
* map.set("key1", 2)
|
|
3985
|
+
* .set("key2", 4)
|
|
3986
|
+
* .set("key3", 8);
|
|
3987
|
+
*
|
|
3988
|
+
* console.log(map); // MapView { "key1" => 2, "key2" => 4, "key3" => 8 }
|
|
3989
|
+
* ```
|
|
3990
|
+
*
|
|
3991
|
+
* ---
|
|
3992
|
+
*
|
|
3993
|
+
* @param key The key of the entry to add.
|
|
3994
|
+
* @param value The value of the entry to add.
|
|
3995
|
+
*
|
|
3996
|
+
* @returns The current instance of the {@link MapView} class.
|
|
3997
|
+
*/
|
|
3998
|
+
set(e, t) {
|
|
3999
|
+
return super.set(e, t), this._publisher.publish("entry:add", e, t), this;
|
|
4000
|
+
}
|
|
4001
|
+
/**
|
|
4002
|
+
* Removes an entry with a specified key from the {@link Map}.
|
|
4003
|
+
*
|
|
4004
|
+
* ---
|
|
4005
|
+
*
|
|
4006
|
+
* @example
|
|
4007
|
+
* ```ts
|
|
4008
|
+
* const map = new MapView<string, number>([["key1", 2], ["key2", 4], ["key3", 8]]);
|
|
4009
|
+
* map.delete("key2"); // true
|
|
4010
|
+
* map.delete("key4"); // false
|
|
4011
|
+
*
|
|
4012
|
+
* console.log(map); // MapView { "key1" => 2, "key3" => 8 }
|
|
4013
|
+
* ```
|
|
4014
|
+
*
|
|
4015
|
+
* ---
|
|
4016
|
+
*
|
|
4017
|
+
* @param key The key of the entry to remove.
|
|
4018
|
+
*
|
|
4019
|
+
* @returns `true` if the entry existed and has been removed; otherwise `false` if the entry doesn't exist.
|
|
4020
|
+
*/
|
|
4021
|
+
delete(e) {
|
|
4022
|
+
const t = super.delete(e);
|
|
4023
|
+
return t && this._publisher.publish("entry:remove", e), t;
|
|
4024
|
+
}
|
|
4025
|
+
/**
|
|
4026
|
+
* Removes all entries from the {@link Map}.
|
|
4027
|
+
*
|
|
4028
|
+
* ---
|
|
4029
|
+
*
|
|
4030
|
+
* @example
|
|
4031
|
+
* ```ts
|
|
4032
|
+
* const map = new MapView<string, number>([["key1", 2], ["key2", 4], ["key3", 8]]);
|
|
4033
|
+
* map.clear();
|
|
4034
|
+
*
|
|
4035
|
+
* console.log(map); // MapView { }
|
|
4036
|
+
* ```
|
|
4037
|
+
*/
|
|
4038
|
+
clear() {
|
|
4039
|
+
const e = this.size;
|
|
4040
|
+
super.clear(), e > 0 && this._publisher.publish("collection:clear");
|
|
4041
|
+
}
|
|
4042
|
+
/**
|
|
4043
|
+
* Subscribes to an event and adds a callback to be executed when the event is published.
|
|
4044
|
+
*
|
|
4045
|
+
* ---
|
|
4046
|
+
*
|
|
4047
|
+
* @example
|
|
4048
|
+
* ```ts
|
|
4049
|
+
* const map = new MapView<string, number>();
|
|
4050
|
+
* const unsubscribe = map.subscribe("entry:add", (key: string, value: number) =>
|
|
4051
|
+
* {
|
|
4052
|
+
* if (key === "answer") { unsubscribe(); }
|
|
4053
|
+
* console.log(`Added ${key}: ${value}`);
|
|
4054
|
+
* });
|
|
4055
|
+
*
|
|
4056
|
+
* map.set("key1", 2); // Added key1: 2
|
|
4057
|
+
* map.set("answer", 42); // Added answer: 42
|
|
4058
|
+
* map.set("key2", 4);
|
|
4059
|
+
* map.set("key3", 8);
|
|
4060
|
+
* ```
|
|
4061
|
+
*
|
|
4062
|
+
* ---
|
|
4063
|
+
*
|
|
4064
|
+
* @template T The key of the map containing the callback signature to subscribe.
|
|
4065
|
+
*
|
|
4066
|
+
* @param event The name of the event to subscribe to.
|
|
4067
|
+
* @param callback The callback to execute when the event is published.
|
|
4068
|
+
*
|
|
4069
|
+
* @returns A function that can be used to unsubscribe the callback from the event.
|
|
4070
|
+
*/
|
|
4071
|
+
subscribe(e, t) {
|
|
4072
|
+
return this._publisher.subscribe(e, t);
|
|
4073
|
+
}
|
|
4074
|
+
/**
|
|
4075
|
+
* Unsubscribes from an event and removes a callback from being executed when the event is published.
|
|
4076
|
+
*
|
|
4077
|
+
* ---
|
|
4078
|
+
*
|
|
4079
|
+
* @example
|
|
4080
|
+
* ```ts
|
|
4081
|
+
* const callback = (key: string, value: number) => console.log(`Added ${key}: ${value}`);
|
|
4082
|
+
* const map = new MapView<string, number>();
|
|
4083
|
+
*
|
|
4084
|
+
* map.subscribe("entry:add", callback);
|
|
4085
|
+
* map.set("key1", 2); // Added key1: 2
|
|
4086
|
+
*
|
|
4087
|
+
* map.unsubscribe("entry:add", callback);
|
|
4088
|
+
* map.set("key2", 4);
|
|
4089
|
+
* ```
|
|
4090
|
+
*
|
|
4091
|
+
* ---
|
|
4092
|
+
*
|
|
4093
|
+
* @template T The key of the map containing the callback signature to unsubscribe.
|
|
4094
|
+
*
|
|
4095
|
+
* @param event The name of the event to unsubscribe from.
|
|
4096
|
+
* @param callback The callback to remove from the event.
|
|
4097
|
+
*/
|
|
4098
|
+
unsubscribe(e, t) {
|
|
4099
|
+
this._publisher.unsubscribe(e, t);
|
|
4100
|
+
}
|
|
4101
|
+
}
|
|
4102
|
+
var Te, Ee;
|
|
4103
|
+
class ht extends (Ee = Set, Te = Symbol.toStringTag, Ee) {
|
|
4104
|
+
/**
|
|
4105
|
+
* Initializes a new instance of the {@link SetView} class.
|
|
4106
|
+
*
|
|
4107
|
+
* ---
|
|
4108
|
+
*
|
|
4109
|
+
* @example
|
|
4110
|
+
* ```ts
|
|
4111
|
+
* const set = new SetView<number>([2, 4, 8]);
|
|
4112
|
+
* ```
|
|
4113
|
+
*
|
|
4114
|
+
* ---
|
|
4115
|
+
*
|
|
4116
|
+
* @param iterable An optional iterable of values to initialize the {@link Set} with.
|
|
4117
|
+
*/
|
|
4118
|
+
constructor(e) {
|
|
4119
|
+
super();
|
|
4120
|
+
/**
|
|
4121
|
+
* The internal {@link Publisher} instance used to publish events.
|
|
4122
|
+
*/
|
|
4123
|
+
a(this, "_publisher");
|
|
4124
|
+
a(this, Te, "SetView");
|
|
4125
|
+
if (this._publisher = new v(), e)
|
|
4126
|
+
for (const t of e)
|
|
4127
|
+
this.add(t);
|
|
4128
|
+
}
|
|
4129
|
+
/**
|
|
4130
|
+
* Appends a new element with a specified value to the end of the {@link Set}.
|
|
4131
|
+
* If the value already exists, it will not be added again.
|
|
4132
|
+
*
|
|
4133
|
+
* ---
|
|
4134
|
+
*
|
|
4135
|
+
* @example
|
|
4136
|
+
* ```ts
|
|
4137
|
+
* const set = new SetView<number>();
|
|
4138
|
+
* set.add(2)
|
|
4139
|
+
* .add(4)
|
|
4140
|
+
* .add(8);
|
|
4141
|
+
*
|
|
4142
|
+
* console.log(set); // SetView(4) { 2, 4, 8 }
|
|
4143
|
+
* ```
|
|
4144
|
+
*
|
|
4145
|
+
* ---
|
|
4146
|
+
*
|
|
4147
|
+
* @param value The value to add.
|
|
4148
|
+
*
|
|
4149
|
+
* @returns The current instance of the {@link SetView} class.
|
|
4150
|
+
*/
|
|
4151
|
+
add(e) {
|
|
4152
|
+
return super.add(e), this._publisher.publish("entry:add", e), this;
|
|
4153
|
+
}
|
|
4154
|
+
/**
|
|
4155
|
+
* Removes the specified value from the {@link Set}.
|
|
4156
|
+
*
|
|
4157
|
+
* ---
|
|
4158
|
+
*
|
|
4159
|
+
* @example
|
|
4160
|
+
* ```ts
|
|
4161
|
+
* const set = new SetView<number>([2, 4, 8]);
|
|
4162
|
+
* set.delete(4); // true
|
|
4163
|
+
* set.delete(16); // false
|
|
4164
|
+
*
|
|
4165
|
+
* console.log(set); // SetView(2) { 2, 8 }
|
|
4166
|
+
* ```
|
|
4167
|
+
*
|
|
4168
|
+
* ---
|
|
4169
|
+
*
|
|
4170
|
+
* @param value The value to remove.
|
|
4171
|
+
*
|
|
4172
|
+
* @returns `true` if the entry existed and has been removed; otherwise `false` if the entry doesn't exist.
|
|
4173
|
+
*/
|
|
4174
|
+
delete(e) {
|
|
4175
|
+
const t = super.delete(e);
|
|
4176
|
+
return t && this._publisher.publish("entry:remove", e), t;
|
|
4177
|
+
}
|
|
4178
|
+
/**
|
|
4179
|
+
* Removes all entries from the {@link Set}.
|
|
4180
|
+
*
|
|
4181
|
+
* ---
|
|
4182
|
+
*
|
|
4183
|
+
* @example
|
|
4184
|
+
* ```ts
|
|
4185
|
+
* const set = new SetView<number>([2, 4, 8]);
|
|
4186
|
+
* set.clear();
|
|
4187
|
+
*
|
|
4188
|
+
* console.log(set); // SetView(0) { }
|
|
4189
|
+
* ```
|
|
4190
|
+
*/
|
|
4191
|
+
clear() {
|
|
4192
|
+
const e = this.size;
|
|
4193
|
+
super.clear(), e > 0 && this._publisher.publish("collection:clear");
|
|
4194
|
+
}
|
|
4195
|
+
/**
|
|
4196
|
+
* Subscribes to an event and adds a callback to be executed when the event is published.
|
|
4197
|
+
*
|
|
4198
|
+
* ---
|
|
4199
|
+
*
|
|
4200
|
+
* @example
|
|
4201
|
+
* ```ts
|
|
4202
|
+
* const set = new SetView<number>();
|
|
4203
|
+
* const unsubscribe = set.subscribe("entry:add", (value: number) =>
|
|
4204
|
+
* {
|
|
4205
|
+
* if (value === 42) { unsubscribe(); }
|
|
4206
|
+
* console.log(`Added ${value}`);
|
|
4207
|
+
* });
|
|
4208
|
+
*
|
|
4209
|
+
* set.add(2); // Added 2
|
|
4210
|
+
* set.add(42); // Added 42
|
|
4211
|
+
* set.add(4);
|
|
4212
|
+
* set.add(8);
|
|
4213
|
+
* ```
|
|
4214
|
+
*
|
|
4215
|
+
* ---
|
|
4216
|
+
*
|
|
4217
|
+
* @template K The key of the map containing the callback signature to subscribe.
|
|
4218
|
+
*
|
|
4219
|
+
* @param event The name of the event to subscribe to.
|
|
4220
|
+
* @param callback The callback to execute when the event is published.
|
|
4221
|
+
*
|
|
4222
|
+
* @returns A function that can be used to unsubscribe the callback from the event.
|
|
4223
|
+
*/
|
|
4224
|
+
subscribe(e, t) {
|
|
4225
|
+
return this._publisher.subscribe(e, t);
|
|
4226
|
+
}
|
|
4227
|
+
/**
|
|
4228
|
+
* Unsubscribes from an event and removes a callback from being executed when the event is published.
|
|
4229
|
+
*
|
|
4230
|
+
* ---
|
|
4231
|
+
*
|
|
4232
|
+
* @example
|
|
4233
|
+
* ```ts
|
|
4234
|
+
* const callback = (value: number) => console.log(`Added ${value}`);
|
|
4235
|
+
* const set = new SetView<number>();
|
|
4236
|
+
*
|
|
4237
|
+
* set.subscribe("entry:add", callback);
|
|
4238
|
+
* set.add(2); // Added 2
|
|
4239
|
+
*
|
|
4240
|
+
* set.unsubscribe("entry:add", callback);
|
|
4241
|
+
* set.add(4);
|
|
4242
|
+
* ```
|
|
4243
|
+
*
|
|
4244
|
+
* ---
|
|
4245
|
+
*
|
|
4246
|
+
* @template K The key of the map containing the callback signature to unsubscribe.
|
|
4247
|
+
*
|
|
4248
|
+
* @param event The name of the event to unsubscribe from.
|
|
4249
|
+
* @param callback The callback to remove from the event.
|
|
4250
|
+
*/
|
|
4251
|
+
unsubscribe(e, t) {
|
|
4252
|
+
this._publisher.unsubscribe(e, t);
|
|
4253
|
+
}
|
|
4254
|
+
}
|
|
4255
|
+
var Me;
|
|
4256
|
+
Me = Symbol.toStringTag;
|
|
4257
|
+
class ft {
|
|
3947
4258
|
/**
|
|
3948
4259
|
* Initializes a new instance of the {@link JSONStorage} class.
|
|
3949
4260
|
* It cannot be instantiated outside of a browser environment or an {@link EnvironmentException} is thrown.
|
|
@@ -3961,7 +4272,7 @@ class ot {
|
|
|
3961
4272
|
* Whether to prefer the {@link localStorage} over the {@link sessionStorage} when calling an ambivalent method.
|
|
3962
4273
|
* If omitted, it defaults to `true` to prefer the persistent storage.
|
|
3963
4274
|
*/
|
|
3964
|
-
constructor(
|
|
4275
|
+
constructor(n = !0) {
|
|
3965
4276
|
/**
|
|
3966
4277
|
* Whether to prefer the {@link localStorage} over the {@link sessionStorage} when calling an ambivalent method.
|
|
3967
4278
|
*
|
|
@@ -3977,41 +4288,41 @@ class ot {
|
|
|
3977
4288
|
* A reference to the persistent {@link localStorage} storage.
|
|
3978
4289
|
*/
|
|
3979
4290
|
a(this, "_persistent");
|
|
3980
|
-
a(this,
|
|
3981
|
-
if (!
|
|
3982
|
-
throw new
|
|
4291
|
+
a(this, Me, "JSONStorage");
|
|
4292
|
+
if (!De)
|
|
4293
|
+
throw new Ge(
|
|
3983
4294
|
"The `JSONStorage` class can only be instantiated within a browser environment."
|
|
3984
4295
|
);
|
|
3985
|
-
this._preferPersistence =
|
|
4296
|
+
this._preferPersistence = n, this._volatile = window.sessionStorage, this._persistent = window.localStorage;
|
|
3986
4297
|
}
|
|
3987
|
-
_get(
|
|
3988
|
-
const s =
|
|
4298
|
+
_get(n, e, t) {
|
|
4299
|
+
const s = n.getItem(e);
|
|
3989
4300
|
if (s)
|
|
3990
4301
|
try {
|
|
3991
4302
|
return JSON.parse(s);
|
|
3992
4303
|
} catch {
|
|
3993
4304
|
console.warn(
|
|
3994
4305
|
`The "${s}" value for "${e}" property cannot be parsed. Clearing the storage...`
|
|
3995
|
-
),
|
|
4306
|
+
), n.removeItem(e);
|
|
3996
4307
|
}
|
|
3997
|
-
return
|
|
4308
|
+
return t;
|
|
3998
4309
|
}
|
|
3999
|
-
_set(
|
|
4000
|
-
const s = JSON.stringify(
|
|
4001
|
-
s ?
|
|
4310
|
+
_set(n, e, t) {
|
|
4311
|
+
const s = JSON.stringify(t);
|
|
4312
|
+
s ? n.setItem(e, s) : n.removeItem(e);
|
|
4002
4313
|
}
|
|
4003
|
-
get(
|
|
4004
|
-
const s =
|
|
4005
|
-
return this._get(s,
|
|
4314
|
+
get(n, e, t = this._preferPersistence) {
|
|
4315
|
+
const s = t ? this._persistent : this._volatile;
|
|
4316
|
+
return this._get(s, n, e);
|
|
4006
4317
|
}
|
|
4007
|
-
recall(
|
|
4008
|
-
return this._get(this._volatile,
|
|
4318
|
+
recall(n, e) {
|
|
4319
|
+
return this._get(this._volatile, n, e);
|
|
4009
4320
|
}
|
|
4010
|
-
retrieve(
|
|
4011
|
-
return this.recall(
|
|
4321
|
+
retrieve(n, e) {
|
|
4322
|
+
return this.recall(n) ?? this.read(n, e);
|
|
4012
4323
|
}
|
|
4013
|
-
read(
|
|
4014
|
-
return this._get(this._persistent,
|
|
4324
|
+
read(n, e) {
|
|
4325
|
+
return this._get(this._persistent, n, e);
|
|
4015
4326
|
}
|
|
4016
4327
|
/**
|
|
4017
4328
|
* Checks whether the value with the specified key exists within the default storage.
|
|
@@ -4035,8 +4346,8 @@ class ot {
|
|
|
4035
4346
|
*
|
|
4036
4347
|
* @returns `true` if the key exists, `false` otherwise.
|
|
4037
4348
|
*/
|
|
4038
|
-
has(
|
|
4039
|
-
return (e ? this._persistent : this._volatile).getItem(
|
|
4349
|
+
has(n, e) {
|
|
4350
|
+
return (e ? this._persistent : this._volatile).getItem(n) !== null;
|
|
4040
4351
|
}
|
|
4041
4352
|
/**
|
|
4042
4353
|
* Checks whether the value with the specified key exists within the volatile {@link sessionStorage}.
|
|
@@ -4057,8 +4368,8 @@ class ot {
|
|
|
4057
4368
|
*
|
|
4058
4369
|
* @returns `true` if the key exists, `false` otherwise.
|
|
4059
4370
|
*/
|
|
4060
|
-
knows(
|
|
4061
|
-
return this._volatile.getItem(
|
|
4371
|
+
knows(n) {
|
|
4372
|
+
return this._volatile.getItem(n) !== null;
|
|
4062
4373
|
}
|
|
4063
4374
|
/**
|
|
4064
4375
|
* Checks whether the value with the specified key exists looking first in the
|
|
@@ -4080,8 +4391,8 @@ class ot {
|
|
|
4080
4391
|
*
|
|
4081
4392
|
* @returns `true` if the key exists, `false` otherwise.
|
|
4082
4393
|
*/
|
|
4083
|
-
find(
|
|
4084
|
-
return this.knows(
|
|
4394
|
+
find(n) {
|
|
4395
|
+
return this.knows(n) ?? this.exists(n);
|
|
4085
4396
|
}
|
|
4086
4397
|
/**
|
|
4087
4398
|
* Checks whether the value with the specified key exists within the persistent {@link localStorage}.
|
|
@@ -4102,8 +4413,8 @@ class ot {
|
|
|
4102
4413
|
*
|
|
4103
4414
|
* @returns `true` if the key exists, `false` otherwise.
|
|
4104
4415
|
*/
|
|
4105
|
-
exists(
|
|
4106
|
-
return this._persistent.getItem(
|
|
4416
|
+
exists(n) {
|
|
4417
|
+
return this._persistent.getItem(n) !== null;
|
|
4107
4418
|
}
|
|
4108
4419
|
/**
|
|
4109
4420
|
* Sets the value with the specified key in the default storage.
|
|
@@ -4128,9 +4439,9 @@ class ot {
|
|
|
4128
4439
|
* Whether to prefer the persistent {@link localStorage} over the volatile {@link sessionStorage}.
|
|
4129
4440
|
* If omitted, it defaults to the `preferPersistence` value set in the constructor.
|
|
4130
4441
|
*/
|
|
4131
|
-
set(
|
|
4132
|
-
const s =
|
|
4133
|
-
this._set(s,
|
|
4442
|
+
set(n, e, t = this._preferPersistence) {
|
|
4443
|
+
const s = t ? this._persistent : this._volatile;
|
|
4444
|
+
this._set(s, n, e);
|
|
4134
4445
|
}
|
|
4135
4446
|
/**
|
|
4136
4447
|
* Sets the value with the specified key in the volatile {@link sessionStorage}.
|
|
@@ -4152,8 +4463,8 @@ class ot {
|
|
|
4152
4463
|
* @param key The key of the value to set.
|
|
4153
4464
|
* @param newValue The new value to set. If it's `undefined` or omitted, the key is removed instead.
|
|
4154
4465
|
*/
|
|
4155
|
-
remember(
|
|
4156
|
-
this._set(this._volatile,
|
|
4466
|
+
remember(n, e) {
|
|
4467
|
+
this._set(this._volatile, n, e);
|
|
4157
4468
|
}
|
|
4158
4469
|
/**
|
|
4159
4470
|
* Sets the value with the specified key in the persistent {@link localStorage}.
|
|
@@ -4175,8 +4486,8 @@ class ot {
|
|
|
4175
4486
|
* @param key The key of the value to set.
|
|
4176
4487
|
* @param newValue The new value to set. If it's `undefined` or omitted, the key is removed instead.
|
|
4177
4488
|
*/
|
|
4178
|
-
write(
|
|
4179
|
-
this._set(this._persistent,
|
|
4489
|
+
write(n, e) {
|
|
4490
|
+
this._set(this._persistent, n, e);
|
|
4180
4491
|
}
|
|
4181
4492
|
/**
|
|
4182
4493
|
* Removes the value with the specified key from the default storage.
|
|
@@ -4195,8 +4506,8 @@ class ot {
|
|
|
4195
4506
|
* Whether to prefer the persistent {@link localStorage} over the volatile {@link sessionStorage}.
|
|
4196
4507
|
* If omitted, it defaults to the `preferPersistence` value set in the constructor.
|
|
4197
4508
|
*/
|
|
4198
|
-
delete(
|
|
4199
|
-
(e ? this._persistent : this._volatile).removeItem(
|
|
4509
|
+
delete(n, e) {
|
|
4510
|
+
(e ? this._persistent : this._volatile).removeItem(n);
|
|
4200
4511
|
}
|
|
4201
4512
|
/**
|
|
4202
4513
|
* Removes the value with the specified key from the volatile {@link sessionStorage}.
|
|
@@ -4212,8 +4523,8 @@ class ot {
|
|
|
4212
4523
|
*
|
|
4213
4524
|
* @param key The key of the value to remove.
|
|
4214
4525
|
*/
|
|
4215
|
-
forget(
|
|
4216
|
-
this._volatile.removeItem(
|
|
4526
|
+
forget(n) {
|
|
4527
|
+
this._volatile.removeItem(n);
|
|
4217
4528
|
}
|
|
4218
4529
|
/**
|
|
4219
4530
|
* Removes the value with the specified key from the persistent {@link localStorage}.
|
|
@@ -4229,8 +4540,8 @@ class ot {
|
|
|
4229
4540
|
*
|
|
4230
4541
|
* @param key The key of the value to remove.
|
|
4231
4542
|
*/
|
|
4232
|
-
erase(
|
|
4233
|
-
this._persistent.removeItem(
|
|
4543
|
+
erase(n) {
|
|
4544
|
+
this._persistent.removeItem(n);
|
|
4234
4545
|
}
|
|
4235
4546
|
/**
|
|
4236
4547
|
* Removes the value with the specified key from both the
|
|
@@ -4247,12 +4558,12 @@ class ot {
|
|
|
4247
4558
|
*
|
|
4248
4559
|
* @param key The key of the value to remove.
|
|
4249
4560
|
*/
|
|
4250
|
-
clear(
|
|
4251
|
-
this._volatile.removeItem(
|
|
4561
|
+
clear(n) {
|
|
4562
|
+
this._volatile.removeItem(n), this._persistent.removeItem(n);
|
|
4252
4563
|
}
|
|
4253
4564
|
}
|
|
4254
|
-
var
|
|
4255
|
-
|
|
4565
|
+
var Re;
|
|
4566
|
+
Re = Symbol.toStringTag;
|
|
4256
4567
|
const R = class R {
|
|
4257
4568
|
/**
|
|
4258
4569
|
* Initializes a new instance of the {@link SmartPromise} class.
|
|
@@ -4273,7 +4584,7 @@ const R = class R {
|
|
|
4273
4584
|
* The function responsible for eventually resolving or rejecting the promise.
|
|
4274
4585
|
* Similarly to the native {@link Promise} object, it's immediately executed after the promise is created.
|
|
4275
4586
|
*/
|
|
4276
|
-
constructor(
|
|
4587
|
+
constructor(n) {
|
|
4277
4588
|
/**
|
|
4278
4589
|
* A flag indicating whether the promise is still pending or not.
|
|
4279
4590
|
*
|
|
@@ -4299,12 +4610,12 @@ const R = class R {
|
|
|
4299
4610
|
* The native {@link Promise} object wrapped by this instance.
|
|
4300
4611
|
*/
|
|
4301
4612
|
a(this, "_promise");
|
|
4302
|
-
a(this,
|
|
4613
|
+
a(this, Re, "SmartPromise");
|
|
4303
4614
|
this._isPending = !0, this._isFulfilled = !1, this._isRejected = !1;
|
|
4304
|
-
const e = (s) => (this._isPending = !1, this._isFulfilled = !0, s),
|
|
4615
|
+
const e = (s) => (this._isPending = !1, this._isFulfilled = !0, s), t = (s) => {
|
|
4305
4616
|
throw this._isPending = !1, this._isRejected = !0, s;
|
|
4306
4617
|
};
|
|
4307
|
-
this._promise = new Promise(
|
|
4618
|
+
this._promise = new Promise(n).then(e, t);
|
|
4308
4619
|
}
|
|
4309
4620
|
/**
|
|
4310
4621
|
* Wraps a new {@link SmartPromise} object around an existing native {@link Promise} object.
|
|
@@ -4329,8 +4640,8 @@ const R = class R {
|
|
|
4329
4640
|
*
|
|
4330
4641
|
* @returns A new {@link SmartPromise} object that wraps the provided promise.
|
|
4331
4642
|
*/
|
|
4332
|
-
static FromPromise(
|
|
4333
|
-
return new R((e,
|
|
4643
|
+
static FromPromise(n) {
|
|
4644
|
+
return new R((e, t) => n.then(e, t));
|
|
4334
4645
|
}
|
|
4335
4646
|
/**
|
|
4336
4647
|
* A flag indicating whether the promise is still pending or not.
|
|
@@ -4350,11 +4661,11 @@ const R = class R {
|
|
|
4350
4661
|
get isRejected() {
|
|
4351
4662
|
return this._isRejected;
|
|
4352
4663
|
}
|
|
4353
|
-
then(
|
|
4354
|
-
return this._promise.then(
|
|
4664
|
+
then(n, e) {
|
|
4665
|
+
return this._promise.then(n, e);
|
|
4355
4666
|
}
|
|
4356
|
-
catch(
|
|
4357
|
-
return this._promise.catch(
|
|
4667
|
+
catch(n) {
|
|
4668
|
+
return this._promise.catch(n);
|
|
4358
4669
|
}
|
|
4359
4670
|
/**
|
|
4360
4671
|
* Attaches a callback that executes right after the promise is settled, regardless of the outcome.
|
|
@@ -4382,13 +4693,13 @@ const R = class R {
|
|
|
4382
4693
|
*
|
|
4383
4694
|
* @returns A new {@link Promise} that executes the callback once the promise is settled.
|
|
4384
4695
|
*/
|
|
4385
|
-
finally(
|
|
4386
|
-
return this._promise.finally(
|
|
4696
|
+
finally(n) {
|
|
4697
|
+
return this._promise.finally(n);
|
|
4387
4698
|
}
|
|
4388
4699
|
};
|
|
4389
|
-
let
|
|
4390
|
-
var
|
|
4391
|
-
class
|
|
4700
|
+
let S = R;
|
|
4701
|
+
var Fe, Pe;
|
|
4702
|
+
class Ze extends (Pe = S, Fe = Symbol.toStringTag, Pe) {
|
|
4392
4703
|
/**
|
|
4393
4704
|
* Initializes a new instance of the {@link DeferredPromise} class.
|
|
4394
4705
|
*
|
|
@@ -4404,7 +4715,7 @@ class He extends (Ee = k, Te = Symbol.toStringTag, Ee) {
|
|
|
4404
4715
|
* @param onFulfilled The callback to execute once the promise is fulfilled.
|
|
4405
4716
|
* @param onRejected The callback to execute once the promise is rejected.
|
|
4406
4717
|
*/
|
|
4407
|
-
constructor(e,
|
|
4718
|
+
constructor(e, t) {
|
|
4408
4719
|
let s, r;
|
|
4409
4720
|
super((o, l) => {
|
|
4410
4721
|
s = o, r = l;
|
|
@@ -4423,8 +4734,8 @@ class He extends (Ee = k, Te = Symbol.toStringTag, Ee) {
|
|
|
4423
4734
|
* If you're looking for the public and readonly property, use the {@link DeferredPromise.reject} getter instead.
|
|
4424
4735
|
*/
|
|
4425
4736
|
a(this, "_reject");
|
|
4426
|
-
a(this,
|
|
4427
|
-
this._promise = this._promise.then(e,
|
|
4737
|
+
a(this, Fe, "DeferredPromise");
|
|
4738
|
+
this._promise = this._promise.then(e, t), this._resolve = s, this._reject = r;
|
|
4428
4739
|
}
|
|
4429
4740
|
/**
|
|
4430
4741
|
* The exposed function that allows to reject the promise.
|
|
@@ -4462,8 +4773,8 @@ class He extends (Ee = k, Te = Symbol.toStringTag, Ee) {
|
|
|
4462
4773
|
return e.then(this.resolve, this.reject), this;
|
|
4463
4774
|
}
|
|
4464
4775
|
}
|
|
4465
|
-
var
|
|
4466
|
-
class
|
|
4776
|
+
var Ce, je;
|
|
4777
|
+
class dt extends (je = S, Ce = Symbol.toStringTag, je) {
|
|
4467
4778
|
/**
|
|
4468
4779
|
* Initializes a new instance of the {@link TimedPromise} class.
|
|
4469
4780
|
*
|
|
@@ -4486,52 +4797,52 @@ class at extends (Re = k, Me = Symbol.toStringTag, Re) {
|
|
|
4486
4797
|
*
|
|
4487
4798
|
* @param timeout The maximum time in milliseconds that the operation can take before timing out.
|
|
4488
4799
|
*/
|
|
4489
|
-
constructor(e,
|
|
4800
|
+
constructor(e, t) {
|
|
4490
4801
|
super((s, r) => {
|
|
4491
|
-
const o = (
|
|
4492
|
-
clearTimeout(P), s(
|
|
4493
|
-
}, l = (
|
|
4494
|
-
clearTimeout(P), r(
|
|
4495
|
-
}, P = setTimeout(() => l(new
|
|
4802
|
+
const o = (T) => {
|
|
4803
|
+
clearTimeout(P), s(T);
|
|
4804
|
+
}, l = (T) => {
|
|
4805
|
+
clearTimeout(P), r(T);
|
|
4806
|
+
}, P = setTimeout(() => l(new Ke("The operation has timed out.")), t);
|
|
4496
4807
|
e(o, l);
|
|
4497
4808
|
});
|
|
4498
|
-
a(this,
|
|
4809
|
+
a(this, Ce, "TimedPromise");
|
|
4499
4810
|
}
|
|
4500
4811
|
}
|
|
4501
|
-
var M = /* @__PURE__ */ ((i) => (i[i.Millisecond = 1] = "Millisecond", i[i.Second = 1e3] = "Second", i[i.Minute = 6e4] = "Minute", i[i.Hour = 36e5] = "Hour", i[i.Day = 864e5] = "Day", i[i.Week = 6048e5] = "Week", i[i.Month = 2592e6] = "Month", i[i.Year = 31536e6] = "Year", i))(M || {}),
|
|
4502
|
-
function
|
|
4503
|
-
let
|
|
4504
|
-
return i = new Date(i),
|
|
4812
|
+
var M = /* @__PURE__ */ ((i) => (i[i.Millisecond = 1] = "Millisecond", i[i.Second = 1e3] = "Second", i[i.Minute = 6e4] = "Minute", i[i.Hour = 36e5] = "Hour", i[i.Day = 864e5] = "Day", i[i.Week = 6048e5] = "Week", i[i.Month = 2592e6] = "Month", i[i.Year = 31536e6] = "Year", i))(M || {}), We = /* @__PURE__ */ ((i) => (i[i.Sunday = 0] = "Sunday", i[i.Monday = 1] = "Monday", i[i.Tuesday = 2] = "Tuesday", i[i.Wednesday = 3] = "Wednesday", i[i.Thursday = 4] = "Thursday", i[i.Friday = 5] = "Friday", i[i.Saturday = 6] = "Saturday", i))(We || {});
|
|
4813
|
+
function wt(i, n, e = 864e5) {
|
|
4814
|
+
let t;
|
|
4815
|
+
return i = new Date(i), n = new Date(n), i < n ? t = Math.floor : t = Math.ceil, t((n.getTime() - i.getTime()) / e);
|
|
4505
4816
|
}
|
|
4506
|
-
function
|
|
4507
|
-
if (i >=
|
|
4817
|
+
function mt(i, n, e = 864e5) {
|
|
4818
|
+
if (i = new Date(i), n = new Date(n), i >= n)
|
|
4508
4819
|
throw new b("The end date must be greater than the start date.");
|
|
4509
|
-
return new
|
|
4510
|
-
const
|
|
4511
|
-
let s =
|
|
4512
|
-
for (; s <
|
|
4820
|
+
return new u(function* () {
|
|
4821
|
+
const t = n.getTime();
|
|
4822
|
+
let s = i.getTime();
|
|
4823
|
+
for (; s < t; )
|
|
4513
4824
|
yield new Date(s), s += e;
|
|
4514
4825
|
});
|
|
4515
4826
|
}
|
|
4516
|
-
function
|
|
4517
|
-
if (
|
|
4827
|
+
function Ue(i, n = 864e5) {
|
|
4828
|
+
if (n <= 1)
|
|
4518
4829
|
throw new b(
|
|
4519
4830
|
"Rounding a timestamp by milliseconds or less makes no sense.Use the timestamp value directly instead."
|
|
4520
4831
|
);
|
|
4521
|
-
if (
|
|
4832
|
+
if (n > 864e5)
|
|
4522
4833
|
throw new b(
|
|
4523
4834
|
"Rounding by more than a day leads to unexpected results. Consider using other methods to round dates by weeks, months or years."
|
|
4524
4835
|
);
|
|
4525
|
-
return i = new Date(i), new Date(Math.floor(i.getTime() /
|
|
4836
|
+
return i = new Date(i), new Date(Math.floor(i.getTime() / n) * n);
|
|
4526
4837
|
}
|
|
4527
|
-
function
|
|
4838
|
+
function pt(i, n = 0) {
|
|
4528
4839
|
i = new Date(i);
|
|
4529
|
-
const e = 7 -
|
|
4530
|
-
return
|
|
4840
|
+
const e = 7 - n, t = (i.getUTCDay() + e) % 7, s = i.getTime() - 864e5 * t;
|
|
4841
|
+
return Ue(new Date(s));
|
|
4531
4842
|
}
|
|
4532
|
-
var
|
|
4533
|
-
|
|
4534
|
-
class
|
|
4843
|
+
var Ie;
|
|
4844
|
+
Ie = Symbol.toStringTag;
|
|
4845
|
+
class Je {
|
|
4535
4846
|
/**
|
|
4536
4847
|
* Initializes a new instance of the {@link GameLoop} class.
|
|
4537
4848
|
*
|
|
@@ -4548,7 +4859,7 @@ class qe {
|
|
|
4548
4859
|
* @param msIfNotBrowser
|
|
4549
4860
|
* The interval in milliseconds that will be used if the current environment isn't a browser. Default is `40`.
|
|
4550
4861
|
*/
|
|
4551
|
-
constructor(
|
|
4862
|
+
constructor(n, e = 40) {
|
|
4552
4863
|
/**
|
|
4553
4864
|
* The handle of the interval or the animation frame, depending on the environment.
|
|
4554
4865
|
* It's used to stop the game loop when the {@link GameLoop._stop} method is called.
|
|
@@ -4588,14 +4899,14 @@ class qe {
|
|
|
4588
4899
|
* {@link cancelAnimationFrame} or the {@link clearInterval} function.
|
|
4589
4900
|
*/
|
|
4590
4901
|
a(this, "_stop");
|
|
4591
|
-
a(this,
|
|
4592
|
-
this._startTime = 0, this._isRunning = !1,
|
|
4593
|
-
|
|
4902
|
+
a(this, Ie, "GameLoop");
|
|
4903
|
+
this._startTime = 0, this._isRunning = !1, De ? (this._start = () => {
|
|
4904
|
+
n(this.elapsedTime), this._handle = window.requestAnimationFrame(this._start);
|
|
4594
4905
|
}, this._stop = () => window.cancelAnimationFrame(this._handle)) : (console.warn(
|
|
4595
4906
|
`Not a browser environment detected. Using setInterval@${e}ms instead of requestAnimationFrame...`
|
|
4596
4907
|
), this._start = () => {
|
|
4597
|
-
this._handle = setInterval(() =>
|
|
4598
|
-
}, this._stop = () => clearInterval(this._handle)), this._publisher = new
|
|
4908
|
+
this._handle = setInterval(() => n(this.elapsedTime), e);
|
|
4909
|
+
}, this._stop = () => clearInterval(this._handle)), this._publisher = new v();
|
|
4599
4910
|
}
|
|
4600
4911
|
/**
|
|
4601
4912
|
* The time when the game loop has started.
|
|
@@ -4635,10 +4946,10 @@ class qe {
|
|
|
4635
4946
|
*
|
|
4636
4947
|
* @param elapsedTime The elapsed time to set as default when the game loop starts. Default is `0`.
|
|
4637
4948
|
*/
|
|
4638
|
-
start(
|
|
4949
|
+
start(n = 0) {
|
|
4639
4950
|
if (this._isRunning)
|
|
4640
|
-
throw new
|
|
4641
|
-
this._startTime = performance.now() -
|
|
4951
|
+
throw new p("The game loop has already been started.");
|
|
4952
|
+
this._startTime = performance.now() - n, this._start(), this._isRunning = !0, this._publisher.publish("start");
|
|
4642
4953
|
}
|
|
4643
4954
|
/**
|
|
4644
4955
|
* Stops the execution of the game loop.
|
|
@@ -4655,9 +4966,9 @@ class qe {
|
|
|
4655
4966
|
*/
|
|
4656
4967
|
stop() {
|
|
4657
4968
|
if (!this._isRunning)
|
|
4658
|
-
throw new
|
|
4969
|
+
throw new p("The game loop had already stopped or hadn't yet started.");
|
|
4659
4970
|
if (!this._handle)
|
|
4660
|
-
throw new
|
|
4971
|
+
throw new g();
|
|
4661
4972
|
this._stop(), this._handle = void 0, this._isRunning = !1, this._publisher.publish("stop");
|
|
4662
4973
|
}
|
|
4663
4974
|
/**
|
|
@@ -4676,8 +4987,8 @@ class qe {
|
|
|
4676
4987
|
*
|
|
4677
4988
|
* @returns A function that can be used to unsubscribe from the event.
|
|
4678
4989
|
*/
|
|
4679
|
-
onStart(
|
|
4680
|
-
return this._publisher.subscribe("start",
|
|
4990
|
+
onStart(n) {
|
|
4991
|
+
return this._publisher.subscribe("start", n);
|
|
4681
4992
|
}
|
|
4682
4993
|
/**
|
|
4683
4994
|
* Subscribes to the `stop` event of the game loop.
|
|
@@ -4695,12 +5006,12 @@ class qe {
|
|
|
4695
5006
|
*
|
|
4696
5007
|
* @returns A function that can be used to unsubscribe from the event.
|
|
4697
5008
|
*/
|
|
4698
|
-
onStop(
|
|
4699
|
-
return this._publisher.subscribe("stop",
|
|
5009
|
+
onStop(n) {
|
|
5010
|
+
return this._publisher.subscribe("stop", n);
|
|
4700
5011
|
}
|
|
4701
5012
|
}
|
|
4702
|
-
var
|
|
4703
|
-
class
|
|
5013
|
+
var Ae, Ne;
|
|
5014
|
+
class yt extends (Ne = Je, Ae = Symbol.toStringTag, Ne) {
|
|
4704
5015
|
/**
|
|
4705
5016
|
* Initializes a new instance of the {@link Clock} class.
|
|
4706
5017
|
*
|
|
@@ -4718,13 +5029,13 @@ class ht extends (Ce = qe, Pe = Symbol.toStringTag, Ce) {
|
|
|
4718
5029
|
* `TimeUnit.Second` by default.
|
|
4719
5030
|
*/
|
|
4720
5031
|
constructor(e = M.Second) {
|
|
4721
|
-
super((
|
|
5032
|
+
super((t) => this._publisher.publish("tick", t), e);
|
|
4722
5033
|
/**
|
|
4723
5034
|
* The {@link Publisher} object that will be used to publish the events of the clock.
|
|
4724
5035
|
*/
|
|
4725
5036
|
a(this, "_publisher");
|
|
4726
|
-
a(this,
|
|
4727
|
-
this._publisher = new
|
|
5037
|
+
a(this, Ae, "Clock");
|
|
5038
|
+
this._publisher = new v();
|
|
4728
5039
|
}
|
|
4729
5040
|
/**
|
|
4730
5041
|
* Starts the execution of the clock.
|
|
@@ -4745,7 +5056,7 @@ class ht extends (Ce = qe, Pe = Symbol.toStringTag, Ce) {
|
|
|
4745
5056
|
*/
|
|
4746
5057
|
start(e = 0) {
|
|
4747
5058
|
if (this._isRunning)
|
|
4748
|
-
throw new
|
|
5059
|
+
throw new p("The clock has already been started.");
|
|
4749
5060
|
this._startTime = performance.now() - e, this._start(), this._isRunning = !0, this._publisher.publish("start");
|
|
4750
5061
|
}
|
|
4751
5062
|
/**
|
|
@@ -4763,9 +5074,9 @@ class ht extends (Ce = qe, Pe = Symbol.toStringTag, Ce) {
|
|
|
4763
5074
|
*/
|
|
4764
5075
|
stop() {
|
|
4765
5076
|
if (!this._isRunning)
|
|
4766
|
-
throw new
|
|
5077
|
+
throw new p("The clock had already stopped or hadn't yet started.");
|
|
4767
5078
|
if (!this._handle)
|
|
4768
|
-
throw new
|
|
5079
|
+
throw new g();
|
|
4769
5080
|
this._stop(), this._handle = void 0, this._isRunning = !1, this._publisher.publish("stop");
|
|
4770
5081
|
}
|
|
4771
5082
|
/**
|
|
@@ -4792,19 +5103,19 @@ class ht extends (Ce = qe, Pe = Symbol.toStringTag, Ce) {
|
|
|
4792
5103
|
*
|
|
4793
5104
|
* @returns A function that can be used to unsubscribe from the event.
|
|
4794
5105
|
*/
|
|
4795
|
-
onTick(e,
|
|
4796
|
-
if (
|
|
5106
|
+
onTick(e, t = 0) {
|
|
5107
|
+
if (t < 0)
|
|
4797
5108
|
throw new b("The tick step must be a non-negative number.");
|
|
4798
|
-
if (
|
|
5109
|
+
if (t === 0)
|
|
4799
5110
|
return this._publisher.subscribe("tick", e);
|
|
4800
5111
|
let s = 0;
|
|
4801
5112
|
return this._publisher.subscribe("tick", (r) => {
|
|
4802
|
-
r - s <
|
|
5113
|
+
r - s < t || (e(r), s = r);
|
|
4803
5114
|
});
|
|
4804
5115
|
}
|
|
4805
5116
|
}
|
|
4806
|
-
var
|
|
4807
|
-
class
|
|
5117
|
+
var Oe, $e;
|
|
5118
|
+
class _t extends ($e = Je, Oe = Symbol.toStringTag, $e) {
|
|
4808
5119
|
/**
|
|
4809
5120
|
* Initializes a new instance of the {@link Countdown} class.
|
|
4810
5121
|
*
|
|
@@ -4824,11 +5135,11 @@ class ft extends (Ie = qe, je = Symbol.toStringTag, Ie) {
|
|
|
4824
5135
|
* The interval in milliseconds at which the countdown will tick if the environment is not a browser.
|
|
4825
5136
|
* `TimeUnit.Second` by default.
|
|
4826
5137
|
*/
|
|
4827
|
-
constructor(e,
|
|
5138
|
+
constructor(e, t = M.Second) {
|
|
4828
5139
|
super(() => {
|
|
4829
5140
|
const r = this.remainingTime;
|
|
4830
5141
|
r <= 0 ? (this._deferrerStop(), this._publisher.publish("tick", 0), this._publisher.publish("expire")) : this._publisher.publish("tick", r);
|
|
4831
|
-
},
|
|
5142
|
+
}, t);
|
|
4832
5143
|
/**
|
|
4833
5144
|
* The {@link Publisher} object that will be used to publish the events of the countdown.
|
|
4834
5145
|
*/
|
|
@@ -4844,8 +5155,8 @@ class ft extends (Ie = qe, je = Symbol.toStringTag, Ie) {
|
|
|
4844
5155
|
* The {@link DeferredPromise} that will be resolved or rejected when the countdown expires or stops.
|
|
4845
5156
|
*/
|
|
4846
5157
|
a(this, "_deferrer");
|
|
4847
|
-
a(this,
|
|
4848
|
-
this._publisher = new
|
|
5158
|
+
a(this, Oe, "Countdown");
|
|
5159
|
+
this._publisher = new v(), this._duration = e;
|
|
4849
5160
|
}
|
|
4850
5161
|
/**
|
|
4851
5162
|
* The total duration of the countdown in milliseconds.
|
|
@@ -4864,6 +5175,8 @@ class ft extends (Ie = qe, je = Symbol.toStringTag, Ie) {
|
|
|
4864
5175
|
* The internal method actually responsible for stopping the
|
|
4865
5176
|
* countdown and resolving or rejecting the {@link Countdown._deferrer} promise.
|
|
4866
5177
|
*
|
|
5178
|
+
* ---
|
|
5179
|
+
*
|
|
4867
5180
|
* @param reason
|
|
4868
5181
|
* The reason why the countdown has stopped.
|
|
4869
5182
|
*
|
|
@@ -4872,9 +5185,9 @@ class ft extends (Ie = qe, je = Symbol.toStringTag, Ie) {
|
|
|
4872
5185
|
*/
|
|
4873
5186
|
_deferrerStop(e) {
|
|
4874
5187
|
if (!this._isRunning)
|
|
4875
|
-
throw new
|
|
5188
|
+
throw new p("The countdown hadn't yet started.");
|
|
4876
5189
|
if (!this._deferrer)
|
|
4877
|
-
throw new
|
|
5190
|
+
throw new g();
|
|
4878
5191
|
this._stop(), this._handle = void 0, this._isRunning = !1, e !== void 0 ? this._deferrer.reject(e) : this._deferrer.resolve(), this._deferrer = void 0;
|
|
4879
5192
|
}
|
|
4880
5193
|
/**
|
|
@@ -4900,10 +5213,10 @@ class ft extends (Ie = qe, je = Symbol.toStringTag, Ie) {
|
|
|
4900
5213
|
*/
|
|
4901
5214
|
start(e = this.duration) {
|
|
4902
5215
|
if (this._isRunning)
|
|
4903
|
-
throw new
|
|
5216
|
+
throw new p("The countdown had already stopped or hadn't yet started.");
|
|
4904
5217
|
if (this._deferrer)
|
|
4905
|
-
throw new
|
|
4906
|
-
return this._deferrer = new
|
|
5218
|
+
throw new g();
|
|
5219
|
+
return this._deferrer = new Ze(), super.start(this.duration - e), this._publisher.publish("start"), this._deferrer;
|
|
4907
5220
|
}
|
|
4908
5221
|
/**
|
|
4909
5222
|
* Stops the execution of the countdown.
|
|
@@ -4973,22 +5286,22 @@ class ft extends (Ie = qe, je = Symbol.toStringTag, Ie) {
|
|
|
4973
5286
|
*
|
|
4974
5287
|
* @returns A function that can be used to unsubscribe from the event.
|
|
4975
5288
|
*/
|
|
4976
|
-
onTick(e,
|
|
4977
|
-
if (
|
|
5289
|
+
onTick(e, t = 0) {
|
|
5290
|
+
if (t < 0)
|
|
4978
5291
|
throw new b("The tick step must be a non-negative number.");
|
|
4979
|
-
if (
|
|
5292
|
+
if (t === 0)
|
|
4980
5293
|
return this._publisher.subscribe("tick", e);
|
|
4981
5294
|
let s = this.remainingTime;
|
|
4982
5295
|
return this._publisher.subscribe("tick", (r) => {
|
|
4983
|
-
s - r <
|
|
5296
|
+
s - r < t || (e(r), s = r);
|
|
4984
5297
|
});
|
|
4985
5298
|
}
|
|
4986
5299
|
}
|
|
4987
|
-
var
|
|
4988
|
-
|
|
4989
|
-
class
|
|
5300
|
+
var ze;
|
|
5301
|
+
ze = Symbol.toStringTag;
|
|
5302
|
+
class bt {
|
|
4990
5303
|
constructor() {
|
|
4991
|
-
a(this,
|
|
5304
|
+
a(this, ze, "Curve");
|
|
4992
5305
|
}
|
|
4993
5306
|
/**
|
|
4994
5307
|
* Generates a given number of values following a linear curve.
|
|
@@ -5010,11 +5323,11 @@ class dt {
|
|
|
5010
5323
|
*
|
|
5011
5324
|
* @returns A {@link SmartIterator} object that generates the values following a linear curve.
|
|
5012
5325
|
*/
|
|
5013
|
-
static Linear(
|
|
5014
|
-
const e =
|
|
5015
|
-
return new
|
|
5016
|
-
for (let
|
|
5017
|
-
yield
|
|
5326
|
+
static Linear(n) {
|
|
5327
|
+
const e = n - 1;
|
|
5328
|
+
return new u(function* () {
|
|
5329
|
+
for (let t = 0; t < n; t += 1)
|
|
5330
|
+
yield t / e;
|
|
5018
5331
|
});
|
|
5019
5332
|
}
|
|
5020
5333
|
/**
|
|
@@ -5045,21 +5358,21 @@ class dt {
|
|
|
5045
5358
|
*
|
|
5046
5359
|
* @returns A {@link SmartIterator} object that generates the values following an exponential curve.
|
|
5047
5360
|
*/
|
|
5048
|
-
static Exponential(
|
|
5361
|
+
static Exponential(n, e = 2) {
|
|
5049
5362
|
if (e < 0)
|
|
5050
5363
|
throw new d("The base of the exponential curve cannot be negative.");
|
|
5051
|
-
const
|
|
5052
|
-
return new
|
|
5053
|
-
for (let s = 0; s <
|
|
5054
|
-
yield Math.pow(s /
|
|
5364
|
+
const t = n - 1;
|
|
5365
|
+
return new u(function* () {
|
|
5366
|
+
for (let s = 0; s < n; s += 1)
|
|
5367
|
+
yield Math.pow(s / t, e);
|
|
5055
5368
|
});
|
|
5056
5369
|
}
|
|
5057
5370
|
}
|
|
5058
|
-
var
|
|
5059
|
-
|
|
5371
|
+
var qe;
|
|
5372
|
+
qe = Symbol.toStringTag;
|
|
5060
5373
|
const F = class F {
|
|
5061
5374
|
constructor() {
|
|
5062
|
-
a(this,
|
|
5375
|
+
a(this, qe, "Random");
|
|
5063
5376
|
}
|
|
5064
5377
|
/**
|
|
5065
5378
|
* Generates a random boolean value.
|
|
@@ -5083,18 +5396,20 @@ const F = class F {
|
|
|
5083
5396
|
*
|
|
5084
5397
|
* @returns A random boolean value.
|
|
5085
5398
|
*/
|
|
5086
|
-
static Boolean(
|
|
5087
|
-
return Math.random() <
|
|
5399
|
+
static Boolean(n = 0.5) {
|
|
5400
|
+
return Math.random() < n;
|
|
5088
5401
|
}
|
|
5089
|
-
static Integer(
|
|
5090
|
-
return Math.floor(e === void 0 ? Math.random() *
|
|
5402
|
+
static Integer(n, e) {
|
|
5403
|
+
return Math.floor(e === void 0 ? Math.random() * n : Math.random() * (e - n) + n);
|
|
5091
5404
|
}
|
|
5092
|
-
static Decimal(
|
|
5093
|
-
return
|
|
5405
|
+
static Decimal(n, e) {
|
|
5406
|
+
return n === void 0 ? Math.random() : e === void 0 ? Math.random() * n : Math.random() * (e - n) + n;
|
|
5094
5407
|
}
|
|
5095
5408
|
/**
|
|
5096
5409
|
* Picks a random valid index from a given array of elements.
|
|
5097
5410
|
*
|
|
5411
|
+
* ---
|
|
5412
|
+
*
|
|
5098
5413
|
* @template T The type of the elements in the array.
|
|
5099
5414
|
*
|
|
5100
5415
|
* @param elements
|
|
@@ -5104,14 +5419,16 @@ const F = class F {
|
|
|
5104
5419
|
*
|
|
5105
5420
|
* @returns A valid random index from the given array.
|
|
5106
5421
|
*/
|
|
5107
|
-
static Index(
|
|
5108
|
-
if (
|
|
5422
|
+
static Index(n) {
|
|
5423
|
+
if (n.length === 0)
|
|
5109
5424
|
throw new d("You must provide at least one element.");
|
|
5110
|
-
return this.Integer(
|
|
5425
|
+
return this.Integer(n.length);
|
|
5111
5426
|
}
|
|
5112
5427
|
/**
|
|
5113
5428
|
* Picks a random element from a given array of elements.
|
|
5114
5429
|
*
|
|
5430
|
+
* ---
|
|
5431
|
+
*
|
|
5115
5432
|
* @template T The type of the elements in the array.
|
|
5116
5433
|
*
|
|
5117
5434
|
* @param elements
|
|
@@ -5121,89 +5438,89 @@ const F = class F {
|
|
|
5121
5438
|
*
|
|
5122
5439
|
* @returns A random element from the given array.
|
|
5123
5440
|
*/
|
|
5124
|
-
static Choice(
|
|
5125
|
-
return
|
|
5441
|
+
static Choice(n) {
|
|
5442
|
+
return n[F.Index(n)];
|
|
5126
5443
|
}
|
|
5127
5444
|
};
|
|
5128
5445
|
let j = F;
|
|
5129
|
-
function
|
|
5130
|
-
return new Promise((
|
|
5446
|
+
function gt(i) {
|
|
5447
|
+
return new Promise((n) => setTimeout(n, i));
|
|
5131
5448
|
}
|
|
5132
|
-
function
|
|
5449
|
+
function xt() {
|
|
5133
5450
|
return new Promise((i) => requestAnimationFrame(() => i()));
|
|
5134
5451
|
}
|
|
5135
|
-
function
|
|
5452
|
+
function vt() {
|
|
5136
5453
|
return new Promise((i) => setTimeout(i));
|
|
5137
5454
|
}
|
|
5138
|
-
function
|
|
5139
|
-
return new Promise((e,
|
|
5455
|
+
function kt(i, n = "text/javascript") {
|
|
5456
|
+
return new Promise((e, t) => {
|
|
5140
5457
|
const s = document.createElement("script");
|
|
5141
|
-
s.async = !0, s.defer = !0, s.src = i, s.type =
|
|
5458
|
+
s.async = !0, s.defer = !0, s.src = i, s.type = n, s.onload = (r) => e(), s.onerror = (r) => t(r), document.body.appendChild(s);
|
|
5142
5459
|
});
|
|
5143
5460
|
}
|
|
5144
|
-
function
|
|
5145
|
-
return new
|
|
5146
|
-
for (const
|
|
5147
|
-
for (const e of
|
|
5461
|
+
function St(...i) {
|
|
5462
|
+
return new u(function* () {
|
|
5463
|
+
for (const n of i)
|
|
5464
|
+
for (const e of n)
|
|
5148
5465
|
yield e;
|
|
5149
5466
|
});
|
|
5150
5467
|
}
|
|
5151
|
-
function
|
|
5468
|
+
function Tt(i) {
|
|
5152
5469
|
if (i instanceof Array)
|
|
5153
5470
|
return i.length;
|
|
5154
|
-
let
|
|
5471
|
+
let n = 0;
|
|
5155
5472
|
for (const e of i)
|
|
5156
|
-
|
|
5157
|
-
return
|
|
5473
|
+
n += 1;
|
|
5474
|
+
return n;
|
|
5158
5475
|
}
|
|
5159
|
-
function
|
|
5160
|
-
return new
|
|
5161
|
-
let
|
|
5476
|
+
function Et(i) {
|
|
5477
|
+
return new u(function* () {
|
|
5478
|
+
let n = 0;
|
|
5162
5479
|
for (const e of i)
|
|
5163
|
-
yield [
|
|
5480
|
+
yield [n, e], n += 1;
|
|
5164
5481
|
});
|
|
5165
5482
|
}
|
|
5166
|
-
function
|
|
5483
|
+
function Mt(i, n, e = 1) {
|
|
5167
5484
|
if (e <= 0)
|
|
5168
5485
|
throw new b(
|
|
5169
5486
|
"Step must be always a positive number, even when generating numbers in reverse order."
|
|
5170
5487
|
);
|
|
5171
|
-
return
|
|
5172
|
-
for (let
|
|
5173
|
-
yield
|
|
5174
|
-
}) : new
|
|
5175
|
-
for (let
|
|
5176
|
-
yield
|
|
5488
|
+
return n === void 0 && (n = i, i = 0), i > n ? new u(function* () {
|
|
5489
|
+
for (let t = i; t > n; t -= e)
|
|
5490
|
+
yield t;
|
|
5491
|
+
}) : new u(function* () {
|
|
5492
|
+
for (let t = i; t < n; t += e)
|
|
5493
|
+
yield t;
|
|
5177
5494
|
});
|
|
5178
5495
|
}
|
|
5179
|
-
function
|
|
5180
|
-
const
|
|
5181
|
-
for (let e =
|
|
5182
|
-
const
|
|
5183
|
-
[
|
|
5496
|
+
function Rt(i) {
|
|
5497
|
+
const n = Array.from(i);
|
|
5498
|
+
for (let e = n.length - 1; e > 0; e -= 1) {
|
|
5499
|
+
const t = Math.floor(Math.random() * (e + 1));
|
|
5500
|
+
[n[e], n[t]] = [n[t], n[e]];
|
|
5184
5501
|
}
|
|
5185
|
-
return
|
|
5502
|
+
return n;
|
|
5186
5503
|
}
|
|
5187
|
-
function
|
|
5188
|
-
return new
|
|
5189
|
-
const
|
|
5504
|
+
function Ft(i) {
|
|
5505
|
+
return new u(function* () {
|
|
5506
|
+
const n = /* @__PURE__ */ new Set();
|
|
5190
5507
|
for (const e of i)
|
|
5191
|
-
|
|
5508
|
+
n.has(e) || (n.add(e), yield e);
|
|
5192
5509
|
});
|
|
5193
5510
|
}
|
|
5194
|
-
function
|
|
5195
|
-
const e = i[Symbol.iterator](),
|
|
5196
|
-
return new
|
|
5511
|
+
function et(i, n) {
|
|
5512
|
+
const e = i[Symbol.iterator](), t = n[Symbol.iterator]();
|
|
5513
|
+
return new u(function* () {
|
|
5197
5514
|
for (; ; ) {
|
|
5198
|
-
const s = e.next(), r =
|
|
5515
|
+
const s = e.next(), r = t.next();
|
|
5199
5516
|
if (s.done || r.done)
|
|
5200
5517
|
break;
|
|
5201
5518
|
yield [s.value, r.value];
|
|
5202
5519
|
}
|
|
5203
5520
|
});
|
|
5204
5521
|
}
|
|
5205
|
-
function
|
|
5206
|
-
if (
|
|
5522
|
+
function Pt(i, n) {
|
|
5523
|
+
if (n === void 0) {
|
|
5207
5524
|
let r = 0, o = 0;
|
|
5208
5525
|
for (const l of i)
|
|
5209
5526
|
r += l, o += 1;
|
|
@@ -5211,94 +5528,96 @@ function St(i, t) {
|
|
|
5211
5528
|
throw new d("You must provide at least one value.");
|
|
5212
5529
|
return r / o;
|
|
5213
5530
|
}
|
|
5214
|
-
let e = 0,
|
|
5215
|
-
for (const [r, o] of
|
|
5531
|
+
let e = 0, t = 0, s = 0;
|
|
5532
|
+
for (const [r, o] of et(i, n)) {
|
|
5216
5533
|
if (o <= 0)
|
|
5217
5534
|
throw new d(`The weight for the value #${s} must be greater than zero.`);
|
|
5218
|
-
e += r * o,
|
|
5535
|
+
e += r * o, t += o, s += 1;
|
|
5219
5536
|
}
|
|
5220
5537
|
if (s === 0)
|
|
5221
5538
|
throw new d("You must provide at least one value and weight.");
|
|
5222
|
-
if (
|
|
5539
|
+
if (t <= 0)
|
|
5223
5540
|
throw new d("The sum of weights must be greater than zero.");
|
|
5224
|
-
return e /
|
|
5541
|
+
return e / t;
|
|
5225
5542
|
}
|
|
5226
|
-
function
|
|
5227
|
-
let
|
|
5543
|
+
function Ct(i) {
|
|
5544
|
+
let n = 0;
|
|
5228
5545
|
for (let e = 0; e < i.length; e += 1) {
|
|
5229
|
-
const
|
|
5230
|
-
|
|
5546
|
+
const t = i.charCodeAt(e);
|
|
5547
|
+
n = (n << 5) - n + t, n |= 0;
|
|
5231
5548
|
}
|
|
5232
|
-
return
|
|
5549
|
+
return n;
|
|
5233
5550
|
}
|
|
5234
|
-
function
|
|
5235
|
-
let
|
|
5551
|
+
function jt(i) {
|
|
5552
|
+
let n = 0;
|
|
5236
5553
|
for (const e of i)
|
|
5237
|
-
|
|
5238
|
-
return
|
|
5554
|
+
n += e;
|
|
5555
|
+
return n;
|
|
5239
5556
|
}
|
|
5240
|
-
function
|
|
5557
|
+
function It(i) {
|
|
5241
5558
|
return `${i.charAt(0).toUpperCase()}${i.slice(1)}`;
|
|
5242
5559
|
}
|
|
5243
|
-
const
|
|
5560
|
+
const At = "2.1.0";
|
|
5244
5561
|
export {
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5562
|
+
E as AggregatedAsyncIterator,
|
|
5563
|
+
x as AggregatedIterator,
|
|
5564
|
+
Qe as CallableObject,
|
|
5565
|
+
yt as Clock,
|
|
5566
|
+
_t as Countdown,
|
|
5567
|
+
bt as Curve,
|
|
5568
|
+
Ze as DeferredPromise,
|
|
5569
|
+
Ge as EnvironmentException,
|
|
5570
|
+
c as Exception,
|
|
5571
|
+
g as FatalErrorException,
|
|
5572
|
+
Be as FileException,
|
|
5573
|
+
rt as FileExistsException,
|
|
5574
|
+
it as FileNotFoundException,
|
|
5575
|
+
Je as GameLoop,
|
|
5576
|
+
ft as JSONStorage,
|
|
5577
|
+
y as KeyException,
|
|
5578
|
+
ct as MapView,
|
|
5579
|
+
ot as NetworkException,
|
|
5580
|
+
Ve as NotImplementedException,
|
|
5581
|
+
at as PermissionException,
|
|
5582
|
+
v as Publisher,
|
|
5265
5583
|
j as Random,
|
|
5266
5584
|
b as RangeException,
|
|
5267
5585
|
h as ReducedIterator,
|
|
5268
5586
|
C as ReferenceException,
|
|
5269
|
-
|
|
5587
|
+
p as RuntimeException,
|
|
5588
|
+
ht as SetView,
|
|
5270
5589
|
f as SmartAsyncIterator,
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5590
|
+
u as SmartIterator,
|
|
5591
|
+
S as SmartPromise,
|
|
5592
|
+
ut as SwitchableCallback,
|
|
5274
5593
|
M as TimeUnit,
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5594
|
+
dt as TimedPromise,
|
|
5595
|
+
Ke as TimeoutException,
|
|
5596
|
+
lt as TypeException,
|
|
5597
|
+
At as VERSION,
|
|
5279
5598
|
d as ValueException,
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5599
|
+
We as WeekDay,
|
|
5600
|
+
Pt as average,
|
|
5601
|
+
It as capitalize,
|
|
5602
|
+
St as chain,
|
|
5603
|
+
Tt as count,
|
|
5604
|
+
wt as dateDifference,
|
|
5605
|
+
mt as dateRange,
|
|
5606
|
+
Ue as dateRound,
|
|
5607
|
+
gt as delay,
|
|
5608
|
+
Et as enumerate,
|
|
5609
|
+
pt as getWeek,
|
|
5610
|
+
Ct as hash,
|
|
5611
|
+
De as isBrowser,
|
|
5612
|
+
nt as isNode,
|
|
5613
|
+
st as isWorker,
|
|
5614
|
+
kt as loadScript,
|
|
5615
|
+
xt as nextAnimationFrame,
|
|
5616
|
+
Mt as range,
|
|
5617
|
+
Rt as shuffle,
|
|
5618
|
+
jt as sum,
|
|
5619
|
+
Ft as unique,
|
|
5620
|
+
vt as yieldToEventLoop,
|
|
5621
|
+
et as zip
|
|
5303
5622
|
};
|
|
5304
|
-
//# sourceMappingURL=core.js.map
|
|
5623
|
+
//# sourceMappingURL=core.esm.js.map
|