@byloth/core 2.2.2 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.esm.js +262 -220
- package/dist/core.esm.js.map +1 -1
- package/dist/core.global.js +1 -1
- package/dist/core.global.js.map +1 -1
- package/dist/core.umd.cjs +1 -1
- package/dist/core.umd.cjs.map +1 -1
- package/package.json +7 -7
- package/src/index.ts +1 -1
- package/src/models/aggregators/index.ts +3 -5
- package/src/models/callbacks/callback-chain.ts +8 -1
- package/src/models/callbacks/index.ts +4 -6
- package/src/models/callbacks/publisher.ts +8 -2
- package/src/models/collections/index.ts +2 -4
- package/src/models/iterators/index.ts +2 -4
- package/src/models/json/index.ts +1 -3
- package/src/models/promises/index.ts +4 -6
- package/src/models/timers/index.ts +3 -5
- package/src/utils/index.ts +2 -4
- package/src/utils/random.ts +121 -0
package/dist/core.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
class
|
|
1
|
+
const E = typeof window < "u" && typeof window.document < "u", B = typeof process < "u" && !!process.versions?.node, Y = typeof self == "object" && self.constructor?.name === "DedicatedWorkerGlobalScope";
|
|
2
|
+
class h extends Error {
|
|
3
3
|
/**
|
|
4
4
|
* A static method to convert a generic caught error, ensuring it's an instance of the {@link Exception} class.
|
|
5
5
|
*
|
|
@@ -23,13 +23,13 @@ class c extends Error {
|
|
|
23
23
|
* @returns An instance of the {@link Exception} class.
|
|
24
24
|
*/
|
|
25
25
|
static FromUnknown(e) {
|
|
26
|
-
if (e instanceof
|
|
26
|
+
if (e instanceof h)
|
|
27
27
|
return e;
|
|
28
28
|
if (e instanceof Error) {
|
|
29
|
-
const t = new
|
|
29
|
+
const t = new h(e.message);
|
|
30
30
|
return t.stack = e.stack, t.cause = e.cause, t.name = e.name, t;
|
|
31
31
|
}
|
|
32
|
-
return new
|
|
32
|
+
return new h(`${e}`);
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Initializes a new instance of the {@link Exception} class.
|
|
@@ -52,7 +52,7 @@ class c extends Error {
|
|
|
52
52
|
}
|
|
53
53
|
[Symbol.toStringTag] = "Exception";
|
|
54
54
|
}
|
|
55
|
-
class
|
|
55
|
+
class g extends h {
|
|
56
56
|
/**
|
|
57
57
|
* Initializes a new instance of the {@link FatalErrorException} class.
|
|
58
58
|
*
|
|
@@ -74,7 +74,7 @@ class x extends c {
|
|
|
74
74
|
}
|
|
75
75
|
[Symbol.toStringTag] = "FatalErrorException";
|
|
76
76
|
}
|
|
77
|
-
class
|
|
77
|
+
class j extends g {
|
|
78
78
|
/**
|
|
79
79
|
* Initializes a new instance of the {@link NotImplementedException} class.
|
|
80
80
|
*
|
|
@@ -96,7 +96,7 @@ class P extends x {
|
|
|
96
96
|
}
|
|
97
97
|
[Symbol.toStringTag] = "NotImplementedException";
|
|
98
98
|
}
|
|
99
|
-
class
|
|
99
|
+
class M extends h {
|
|
100
100
|
/**
|
|
101
101
|
* Initializes a new instance of the {@link FileException} class.
|
|
102
102
|
*
|
|
@@ -118,7 +118,7 @@ class E extends c {
|
|
|
118
118
|
}
|
|
119
119
|
[Symbol.toStringTag] = "FileException";
|
|
120
120
|
}
|
|
121
|
-
class J extends
|
|
121
|
+
class J extends M {
|
|
122
122
|
/**
|
|
123
123
|
* Initializes a new instance of the {@link FileExistsException} class.
|
|
124
124
|
*
|
|
@@ -140,7 +140,7 @@ class J extends E {
|
|
|
140
140
|
}
|
|
141
141
|
[Symbol.toStringTag] = "FileExistsException";
|
|
142
142
|
}
|
|
143
|
-
class
|
|
143
|
+
class L extends M {
|
|
144
144
|
/**
|
|
145
145
|
* Initializes a new instance of the {@link FileNotFoundException} class.
|
|
146
146
|
*
|
|
@@ -162,7 +162,7 @@ class Y extends E {
|
|
|
162
162
|
}
|
|
163
163
|
[Symbol.toStringTag] = "FileNotFoundException";
|
|
164
164
|
}
|
|
165
|
-
class
|
|
165
|
+
class b extends h {
|
|
166
166
|
/**
|
|
167
167
|
* Initializes a new instance of the {@link KeyException} class.
|
|
168
168
|
*
|
|
@@ -184,7 +184,7 @@ class p extends c {
|
|
|
184
184
|
}
|
|
185
185
|
[Symbol.toStringTag] = "KeyException";
|
|
186
186
|
}
|
|
187
|
-
class
|
|
187
|
+
class V extends h {
|
|
188
188
|
/**
|
|
189
189
|
* Initializes a new instance of the {@link NetworkException} class.
|
|
190
190
|
*
|
|
@@ -206,7 +206,7 @@ class L extends c {
|
|
|
206
206
|
}
|
|
207
207
|
[Symbol.toStringTag] = "NetworkException";
|
|
208
208
|
}
|
|
209
|
-
class
|
|
209
|
+
class G extends h {
|
|
210
210
|
/**
|
|
211
211
|
* Initializes a new instance of the {@link PermissionException} class.
|
|
212
212
|
*
|
|
@@ -228,7 +228,7 @@ class V extends c {
|
|
|
228
228
|
}
|
|
229
229
|
[Symbol.toStringTag] = "PermissionException";
|
|
230
230
|
}
|
|
231
|
-
class k extends
|
|
231
|
+
class k extends h {
|
|
232
232
|
/**
|
|
233
233
|
* Initializes a new instance of the {@link ReferenceException} class.
|
|
234
234
|
*
|
|
@@ -250,7 +250,7 @@ class k extends c {
|
|
|
250
250
|
}
|
|
251
251
|
[Symbol.toStringTag] = "ReferenceException";
|
|
252
252
|
}
|
|
253
|
-
class
|
|
253
|
+
class y extends h {
|
|
254
254
|
/**
|
|
255
255
|
* Initializes a new instance of the {@link RuntimeException} class.
|
|
256
256
|
*
|
|
@@ -272,7 +272,7 @@ class _ extends c {
|
|
|
272
272
|
}
|
|
273
273
|
[Symbol.toStringTag] = "RuntimeException";
|
|
274
274
|
}
|
|
275
|
-
class
|
|
275
|
+
class O extends y {
|
|
276
276
|
/**
|
|
277
277
|
* Initializes a new instance of the {@link EnvironmentException} class.
|
|
278
278
|
*
|
|
@@ -294,7 +294,7 @@ class j extends _ {
|
|
|
294
294
|
}
|
|
295
295
|
[Symbol.toStringTag] = "EnvironmentException";
|
|
296
296
|
}
|
|
297
|
-
class
|
|
297
|
+
class N extends h {
|
|
298
298
|
/**
|
|
299
299
|
* Initializes a new instance of the {@link TimeoutException} class.
|
|
300
300
|
*
|
|
@@ -316,7 +316,7 @@ class O extends c {
|
|
|
316
316
|
}
|
|
317
317
|
[Symbol.toStringTag] = "TimeoutException";
|
|
318
318
|
}
|
|
319
|
-
class
|
|
319
|
+
class K extends h {
|
|
320
320
|
/**
|
|
321
321
|
* Initializes a new instance of the {@link TypeException} class.
|
|
322
322
|
*
|
|
@@ -338,7 +338,7 @@ class G extends c {
|
|
|
338
338
|
}
|
|
339
339
|
[Symbol.toStringTag] = "TypeException";
|
|
340
340
|
}
|
|
341
|
-
class
|
|
341
|
+
class u extends h {
|
|
342
342
|
/**
|
|
343
343
|
* Initializes a new instance of the {@link ValueException} class.
|
|
344
344
|
*
|
|
@@ -360,7 +360,7 @@ class f extends c {
|
|
|
360
360
|
}
|
|
361
361
|
[Symbol.toStringTag] = "ValueException";
|
|
362
362
|
}
|
|
363
|
-
class
|
|
363
|
+
class x extends u {
|
|
364
364
|
/**
|
|
365
365
|
* Initializes a new instance of the {@link RangeException} class.
|
|
366
366
|
*
|
|
@@ -530,7 +530,7 @@ class l {
|
|
|
530
530
|
if (s === void 0) {
|
|
531
531
|
const r = this._iterator.next();
|
|
532
532
|
if (r.done)
|
|
533
|
-
throw new
|
|
533
|
+
throw new u("Cannot reduce an empty iterator without an initial value.");
|
|
534
534
|
s = r.value, n += 1;
|
|
535
535
|
}
|
|
536
536
|
for (; ; ) {
|
|
@@ -960,7 +960,7 @@ class l {
|
|
|
960
960
|
* @returns A new instance of the {@link AggregatedIterator} class containing the grouped elements.
|
|
961
961
|
*/
|
|
962
962
|
groupBy(e) {
|
|
963
|
-
return new
|
|
963
|
+
return new d(this.map((t, n) => [e(t, n), t]));
|
|
964
964
|
}
|
|
965
965
|
/**
|
|
966
966
|
* Materializes the iterator into an array.
|
|
@@ -993,7 +993,7 @@ class l {
|
|
|
993
993
|
return this;
|
|
994
994
|
}
|
|
995
995
|
}
|
|
996
|
-
class
|
|
996
|
+
class c {
|
|
997
997
|
/**
|
|
998
998
|
* The internal {@link SmartIterator} object that holds the reduced elements.
|
|
999
999
|
*/
|
|
@@ -1077,7 +1077,7 @@ class u {
|
|
|
1077
1077
|
}
|
|
1078
1078
|
filter(e) {
|
|
1079
1079
|
const t = this._elements.enumerate();
|
|
1080
|
-
return new
|
|
1080
|
+
return new c(function* () {
|
|
1081
1081
|
for (const [n, [s, r]] of t)
|
|
1082
1082
|
e(s, r, n) && (yield [s, r]);
|
|
1083
1083
|
});
|
|
@@ -1117,7 +1117,7 @@ class u {
|
|
|
1117
1117
|
*/
|
|
1118
1118
|
map(e) {
|
|
1119
1119
|
const t = this._elements.enumerate();
|
|
1120
|
-
return new
|
|
1120
|
+
return new c(function* () {
|
|
1121
1121
|
for (const [n, [s, r]] of t)
|
|
1122
1122
|
yield [s, e(s, r, n)];
|
|
1123
1123
|
});
|
|
@@ -1127,7 +1127,7 @@ class u {
|
|
|
1127
1127
|
if (s === void 0) {
|
|
1128
1128
|
const r = this._elements.next();
|
|
1129
1129
|
if (r.done)
|
|
1130
|
-
throw new
|
|
1130
|
+
throw new u("Cannot reduce an empty iterator without an initial value.");
|
|
1131
1131
|
s = r.value[1], n += 1;
|
|
1132
1132
|
}
|
|
1133
1133
|
for (const [r, o] of this._elements)
|
|
@@ -1169,7 +1169,7 @@ class u {
|
|
|
1169
1169
|
*/
|
|
1170
1170
|
flatMap(e) {
|
|
1171
1171
|
const t = this._elements.enumerate();
|
|
1172
|
-
return new
|
|
1172
|
+
return new d(function* () {
|
|
1173
1173
|
for (const [n, [s, r]] of t) {
|
|
1174
1174
|
const o = e(s, r, n);
|
|
1175
1175
|
if (o instanceof Array)
|
|
@@ -1215,7 +1215,7 @@ class u {
|
|
|
1215
1215
|
*/
|
|
1216
1216
|
drop(e) {
|
|
1217
1217
|
const t = this._elements.enumerate();
|
|
1218
|
-
return new
|
|
1218
|
+
return new c(function* () {
|
|
1219
1219
|
for (const [n, [s, r]] of t)
|
|
1220
1220
|
n >= e && (yield [s, r]);
|
|
1221
1221
|
});
|
|
@@ -1257,7 +1257,7 @@ class u {
|
|
|
1257
1257
|
*/
|
|
1258
1258
|
take(e) {
|
|
1259
1259
|
const t = this._elements.enumerate();
|
|
1260
|
-
return new
|
|
1260
|
+
return new c(function* () {
|
|
1261
1261
|
for (const [n, [s, r]] of t) {
|
|
1262
1262
|
if (n >= e)
|
|
1263
1263
|
break;
|
|
@@ -1327,7 +1327,7 @@ class u {
|
|
|
1327
1327
|
*/
|
|
1328
1328
|
unique() {
|
|
1329
1329
|
const e = this._elements;
|
|
1330
|
-
return new
|
|
1330
|
+
return new c(function* () {
|
|
1331
1331
|
const t = /* @__PURE__ */ new Set();
|
|
1332
1332
|
for (const [n, s] of e)
|
|
1333
1333
|
t.has(s) || (t.add(s), yield [n, s]);
|
|
@@ -1423,7 +1423,7 @@ class u {
|
|
|
1423
1423
|
*/
|
|
1424
1424
|
reorganizeBy(e) {
|
|
1425
1425
|
const t = this._elements.enumerate();
|
|
1426
|
-
return new
|
|
1426
|
+
return new d(function* () {
|
|
1427
1427
|
for (const [n, [s, r]] of t)
|
|
1428
1428
|
yield [e(s, r, n), r];
|
|
1429
1429
|
});
|
|
@@ -1601,13 +1601,13 @@ class u {
|
|
|
1601
1601
|
}
|
|
1602
1602
|
[Symbol.toStringTag] = "ReducedIterator";
|
|
1603
1603
|
}
|
|
1604
|
-
class
|
|
1604
|
+
class p {
|
|
1605
1605
|
/**
|
|
1606
1606
|
* The internal {@link SmartAsyncIterator} object that holds the elements to aggregate.
|
|
1607
1607
|
*/
|
|
1608
1608
|
_elements;
|
|
1609
1609
|
constructor(e) {
|
|
1610
|
-
this._elements = new
|
|
1610
|
+
this._elements = new w(e);
|
|
1611
1611
|
}
|
|
1612
1612
|
/**
|
|
1613
1613
|
* Determines whether all elements of each group of the iterator satisfy a given condition.
|
|
@@ -1646,7 +1646,7 @@ class w {
|
|
|
1646
1646
|
const [r, o] = t.get(n) ?? [0, !0];
|
|
1647
1647
|
o && t.set(n, [r + 1, await e(n, s, r)]);
|
|
1648
1648
|
}
|
|
1649
|
-
return new
|
|
1649
|
+
return new c(function* () {
|
|
1650
1650
|
for (const [n, [s, r]] of t)
|
|
1651
1651
|
yield [n, r];
|
|
1652
1652
|
});
|
|
@@ -1688,14 +1688,14 @@ class w {
|
|
|
1688
1688
|
const [r, o] = t.get(n) ?? [0, !1];
|
|
1689
1689
|
o || t.set(n, [r + 1, await e(n, s, r)]);
|
|
1690
1690
|
}
|
|
1691
|
-
return new
|
|
1691
|
+
return new c(function* () {
|
|
1692
1692
|
for (const [n, [s, r]] of t)
|
|
1693
1693
|
yield [n, r];
|
|
1694
1694
|
});
|
|
1695
1695
|
}
|
|
1696
1696
|
filter(e) {
|
|
1697
1697
|
const t = this._elements;
|
|
1698
|
-
return new
|
|
1698
|
+
return new p(async function* () {
|
|
1699
1699
|
const n = /* @__PURE__ */ new Map();
|
|
1700
1700
|
for await (const [s, r] of t) {
|
|
1701
1701
|
const o = n.get(s) ?? 0;
|
|
@@ -1737,7 +1737,7 @@ class w {
|
|
|
1737
1737
|
*/
|
|
1738
1738
|
map(e) {
|
|
1739
1739
|
const t = this._elements;
|
|
1740
|
-
return new
|
|
1740
|
+
return new p(async function* () {
|
|
1741
1741
|
const n = /* @__PURE__ */ new Map();
|
|
1742
1742
|
for await (const [s, r] of t) {
|
|
1743
1743
|
const o = n.get(s) ?? 0;
|
|
@@ -1759,7 +1759,7 @@ class w {
|
|
|
1759
1759
|
}
|
|
1760
1760
|
n.set(s, [o + 1, await e(s, a, r, o)]);
|
|
1761
1761
|
}
|
|
1762
|
-
return new
|
|
1762
|
+
return new c(function* () {
|
|
1763
1763
|
for (const [s, [r, o]] of n)
|
|
1764
1764
|
yield [s, o];
|
|
1765
1765
|
});
|
|
@@ -1802,13 +1802,13 @@ class w {
|
|
|
1802
1802
|
*/
|
|
1803
1803
|
flatMap(e) {
|
|
1804
1804
|
const t = this._elements;
|
|
1805
|
-
return new
|
|
1805
|
+
return new p(async function* () {
|
|
1806
1806
|
const n = /* @__PURE__ */ new Map();
|
|
1807
1807
|
for await (const [s, r] of t) {
|
|
1808
1808
|
const o = n.get(s) ?? 0, a = await e(s, r, o);
|
|
1809
1809
|
if (a instanceof Array)
|
|
1810
|
-
for (const
|
|
1811
|
-
yield [s,
|
|
1810
|
+
for (const f of a)
|
|
1811
|
+
yield [s, f];
|
|
1812
1812
|
else
|
|
1813
1813
|
yield [s, a];
|
|
1814
1814
|
n.set(s, o + 1);
|
|
@@ -1846,7 +1846,7 @@ class w {
|
|
|
1846
1846
|
*/
|
|
1847
1847
|
drop(e) {
|
|
1848
1848
|
const t = this._elements;
|
|
1849
|
-
return new
|
|
1849
|
+
return new p(async function* () {
|
|
1850
1850
|
const n = /* @__PURE__ */ new Map();
|
|
1851
1851
|
for await (const [s, r] of t) {
|
|
1852
1852
|
const o = n.get(s) ?? 0;
|
|
@@ -1889,7 +1889,7 @@ class w {
|
|
|
1889
1889
|
*/
|
|
1890
1890
|
take(e) {
|
|
1891
1891
|
const t = this._elements;
|
|
1892
|
-
return new
|
|
1892
|
+
return new p(async function* () {
|
|
1893
1893
|
const n = /* @__PURE__ */ new Map();
|
|
1894
1894
|
for await (const [s, r] of t) {
|
|
1895
1895
|
const o = n.get(s) ?? 0;
|
|
@@ -1903,7 +1903,7 @@ class w {
|
|
|
1903
1903
|
let [r, o] = t.get(n) ?? [0, void 0];
|
|
1904
1904
|
o === void 0 && (await e(n, s, r) && (o = s), t.set(n, [r + 1, o]));
|
|
1905
1905
|
}
|
|
1906
|
-
return new
|
|
1906
|
+
return new c(function* () {
|
|
1907
1907
|
for (const [n, [s, r]] of t)
|
|
1908
1908
|
yield [n, r];
|
|
1909
1909
|
});
|
|
@@ -1965,7 +1965,7 @@ class w {
|
|
|
1965
1965
|
*/
|
|
1966
1966
|
unique() {
|
|
1967
1967
|
const e = this._elements;
|
|
1968
|
-
return new
|
|
1968
|
+
return new p(async function* () {
|
|
1969
1969
|
const t = /* @__PURE__ */ new Map();
|
|
1970
1970
|
for await (const [n, s] of e) {
|
|
1971
1971
|
const r = t.get(n) ?? /* @__PURE__ */ new Set();
|
|
@@ -2001,7 +2001,7 @@ class w {
|
|
|
2001
2001
|
const n = e.get(t) ?? 0;
|
|
2002
2002
|
e.set(t, n + 1);
|
|
2003
2003
|
}
|
|
2004
|
-
return new
|
|
2004
|
+
return new c(function* () {
|
|
2005
2005
|
for (const [t, n] of e)
|
|
2006
2006
|
yield [t, n];
|
|
2007
2007
|
});
|
|
@@ -2072,7 +2072,7 @@ class w {
|
|
|
2072
2072
|
*/
|
|
2073
2073
|
reorganizeBy(e) {
|
|
2074
2074
|
const t = this._elements;
|
|
2075
|
-
return new
|
|
2075
|
+
return new p(async function* () {
|
|
2076
2076
|
const n = /* @__PURE__ */ new Map();
|
|
2077
2077
|
for await (const [s, r] of t) {
|
|
2078
2078
|
const o = n.get(s) ?? 0;
|
|
@@ -2108,7 +2108,7 @@ class w {
|
|
|
2108
2108
|
*/
|
|
2109
2109
|
keys() {
|
|
2110
2110
|
const e = this._elements;
|
|
2111
|
-
return new
|
|
2111
|
+
return new w(async function* () {
|
|
2112
2112
|
const t = /* @__PURE__ */ new Set();
|
|
2113
2113
|
for await (const [n] of e)
|
|
2114
2114
|
t.has(n) || (t.add(n), yield n);
|
|
@@ -2172,7 +2172,7 @@ class w {
|
|
|
2172
2172
|
*/
|
|
2173
2173
|
values() {
|
|
2174
2174
|
const e = this._elements;
|
|
2175
|
-
return new
|
|
2175
|
+
return new w(async function* () {
|
|
2176
2176
|
for await (const [t, n] of e)
|
|
2177
2177
|
yield n;
|
|
2178
2178
|
});
|
|
@@ -2259,7 +2259,7 @@ class w {
|
|
|
2259
2259
|
}
|
|
2260
2260
|
[Symbol.toStringTag] = "AggregatedAsyncIterator";
|
|
2261
2261
|
}
|
|
2262
|
-
class
|
|
2262
|
+
class w {
|
|
2263
2263
|
/**
|
|
2264
2264
|
* The native {@link AsyncIterator} object that is being wrapped by this instance.
|
|
2265
2265
|
*/
|
|
@@ -2383,7 +2383,7 @@ class d {
|
|
|
2383
2383
|
}
|
|
2384
2384
|
filter(e) {
|
|
2385
2385
|
const t = this._iterator;
|
|
2386
|
-
return new
|
|
2386
|
+
return new w(async function* () {
|
|
2387
2387
|
let n = 0;
|
|
2388
2388
|
for (; ; ) {
|
|
2389
2389
|
const s = await t.next();
|
|
@@ -2426,7 +2426,7 @@ class d {
|
|
|
2426
2426
|
*/
|
|
2427
2427
|
map(e) {
|
|
2428
2428
|
const t = this._iterator;
|
|
2429
|
-
return new
|
|
2429
|
+
return new w(async function* () {
|
|
2430
2430
|
let n = 0;
|
|
2431
2431
|
for (; ; ) {
|
|
2432
2432
|
const s = await t.next();
|
|
@@ -2441,7 +2441,7 @@ class d {
|
|
|
2441
2441
|
if (s === void 0) {
|
|
2442
2442
|
const r = await this._iterator.next();
|
|
2443
2443
|
if (r.done)
|
|
2444
|
-
throw new
|
|
2444
|
+
throw new u("Cannot reduce an empty iterator without an initial value.");
|
|
2445
2445
|
s = r.value, n += 1;
|
|
2446
2446
|
}
|
|
2447
2447
|
for (; ; ) {
|
|
@@ -2484,7 +2484,7 @@ class d {
|
|
|
2484
2484
|
*/
|
|
2485
2485
|
flatMap(e) {
|
|
2486
2486
|
const t = this._iterator;
|
|
2487
|
-
return new
|
|
2487
|
+
return new w(async function* () {
|
|
2488
2488
|
let n = 0;
|
|
2489
2489
|
for (; ; ) {
|
|
2490
2490
|
const s = await t.next();
|
|
@@ -2533,7 +2533,7 @@ class d {
|
|
|
2533
2533
|
*/
|
|
2534
2534
|
drop(e) {
|
|
2535
2535
|
const t = this._iterator;
|
|
2536
|
-
return new
|
|
2536
|
+
return new w(async function* () {
|
|
2537
2537
|
let n = 0;
|
|
2538
2538
|
for (; n < e; ) {
|
|
2539
2539
|
if ((await t.next()).done)
|
|
@@ -2582,7 +2582,7 @@ class d {
|
|
|
2582
2582
|
*/
|
|
2583
2583
|
take(e) {
|
|
2584
2584
|
const t = this._iterator;
|
|
2585
|
-
return new
|
|
2585
|
+
return new w(async function* () {
|
|
2586
2586
|
let n = 0;
|
|
2587
2587
|
for (; n < e; ) {
|
|
2588
2588
|
const s = await t.next();
|
|
@@ -2661,7 +2661,7 @@ class d {
|
|
|
2661
2661
|
*/
|
|
2662
2662
|
unique() {
|
|
2663
2663
|
const e = this._iterator;
|
|
2664
|
-
return new
|
|
2664
|
+
return new w(async function* () {
|
|
2665
2665
|
const t = /* @__PURE__ */ new Set();
|
|
2666
2666
|
for (; ; ) {
|
|
2667
2667
|
const n = await e.next();
|
|
@@ -2878,7 +2878,7 @@ class d {
|
|
|
2878
2878
|
* @returns A new instance of the {@link AggregatedAsyncIterator} class containing the grouped elements.
|
|
2879
2879
|
*/
|
|
2880
2880
|
groupBy(e) {
|
|
2881
|
-
return new
|
|
2881
|
+
return new p(this.map(async (t, n) => [await e(t, n), t]));
|
|
2882
2882
|
}
|
|
2883
2883
|
/**
|
|
2884
2884
|
* Materializes the iterator into an array.
|
|
@@ -2911,7 +2911,7 @@ class d {
|
|
|
2911
2911
|
return this;
|
|
2912
2912
|
}
|
|
2913
2913
|
}
|
|
2914
|
-
class
|
|
2914
|
+
class d {
|
|
2915
2915
|
/**
|
|
2916
2916
|
* The internal {@link SmartIterator} object that holds the elements to aggregate.
|
|
2917
2917
|
*/
|
|
@@ -2955,7 +2955,7 @@ class h {
|
|
|
2955
2955
|
const [r, o] = t.get(n) ?? [0, !0];
|
|
2956
2956
|
o && t.set(n, [r + 1, e(n, s, r)]);
|
|
2957
2957
|
}
|
|
2958
|
-
return new
|
|
2958
|
+
return new c(function* () {
|
|
2959
2959
|
for (const [n, [s, r]] of t)
|
|
2960
2960
|
yield [n, r];
|
|
2961
2961
|
});
|
|
@@ -2996,14 +2996,14 @@ class h {
|
|
|
2996
2996
|
const [r, o] = t.get(n) ?? [0, !1];
|
|
2997
2997
|
o || t.set(n, [r + 1, e(n, s, r)]);
|
|
2998
2998
|
}
|
|
2999
|
-
return new
|
|
2999
|
+
return new c(function* () {
|
|
3000
3000
|
for (const [n, [s, r]] of t)
|
|
3001
3001
|
yield [n, r];
|
|
3002
3002
|
});
|
|
3003
3003
|
}
|
|
3004
3004
|
filter(e) {
|
|
3005
3005
|
const t = this._elements;
|
|
3006
|
-
return new
|
|
3006
|
+
return new d(function* () {
|
|
3007
3007
|
const n = /* @__PURE__ */ new Map();
|
|
3008
3008
|
for (const [s, r] of t) {
|
|
3009
3009
|
const o = n.get(s) ?? 0;
|
|
@@ -3045,7 +3045,7 @@ class h {
|
|
|
3045
3045
|
*/
|
|
3046
3046
|
map(e) {
|
|
3047
3047
|
const t = this._elements;
|
|
3048
|
-
return new
|
|
3048
|
+
return new d(function* () {
|
|
3049
3049
|
const n = /* @__PURE__ */ new Map();
|
|
3050
3050
|
for (const [s, r] of t) {
|
|
3051
3051
|
const o = n.get(s) ?? 0;
|
|
@@ -3067,7 +3067,7 @@ class h {
|
|
|
3067
3067
|
}
|
|
3068
3068
|
n.set(s, [o + 1, e(s, a, r, o)]);
|
|
3069
3069
|
}
|
|
3070
|
-
return new
|
|
3070
|
+
return new c(function* () {
|
|
3071
3071
|
for (const [s, [r, o]] of n)
|
|
3072
3072
|
yield [s, o];
|
|
3073
3073
|
});
|
|
@@ -3110,13 +3110,13 @@ class h {
|
|
|
3110
3110
|
*/
|
|
3111
3111
|
flatMap(e) {
|
|
3112
3112
|
const t = this._elements;
|
|
3113
|
-
return new
|
|
3113
|
+
return new d(function* () {
|
|
3114
3114
|
const n = /* @__PURE__ */ new Map();
|
|
3115
3115
|
for (const [s, r] of t) {
|
|
3116
3116
|
const o = n.get(s) ?? 0, a = e(s, r, o);
|
|
3117
3117
|
if (a instanceof Array)
|
|
3118
|
-
for (const
|
|
3119
|
-
yield [s,
|
|
3118
|
+
for (const f of a)
|
|
3119
|
+
yield [s, f];
|
|
3120
3120
|
else
|
|
3121
3121
|
yield [s, a];
|
|
3122
3122
|
n.set(s, o + 1);
|
|
@@ -3154,7 +3154,7 @@ class h {
|
|
|
3154
3154
|
*/
|
|
3155
3155
|
drop(e) {
|
|
3156
3156
|
const t = this._elements;
|
|
3157
|
-
return new
|
|
3157
|
+
return new d(function* () {
|
|
3158
3158
|
const n = /* @__PURE__ */ new Map();
|
|
3159
3159
|
for (const [s, r] of t) {
|
|
3160
3160
|
const o = n.get(s) ?? 0;
|
|
@@ -3197,7 +3197,7 @@ class h {
|
|
|
3197
3197
|
*/
|
|
3198
3198
|
take(e) {
|
|
3199
3199
|
const t = this._elements;
|
|
3200
|
-
return new
|
|
3200
|
+
return new d(function* () {
|
|
3201
3201
|
const n = /* @__PURE__ */ new Map();
|
|
3202
3202
|
for (const [s, r] of t) {
|
|
3203
3203
|
const o = n.get(s) ?? 0;
|
|
@@ -3211,7 +3211,7 @@ class h {
|
|
|
3211
3211
|
let [r, o] = t.get(n) ?? [0, void 0];
|
|
3212
3212
|
o === void 0 && (e(n, s, r) && (o = s), t.set(n, [r + 1, o]));
|
|
3213
3213
|
}
|
|
3214
|
-
return new
|
|
3214
|
+
return new c(function* () {
|
|
3215
3215
|
for (const [n, [s, r]] of t)
|
|
3216
3216
|
yield [n, r];
|
|
3217
3217
|
});
|
|
@@ -3273,7 +3273,7 @@ class h {
|
|
|
3273
3273
|
*/
|
|
3274
3274
|
unique() {
|
|
3275
3275
|
const e = this._elements;
|
|
3276
|
-
return new
|
|
3276
|
+
return new d(function* () {
|
|
3277
3277
|
const t = /* @__PURE__ */ new Map();
|
|
3278
3278
|
for (const [n, s] of e) {
|
|
3279
3279
|
const r = t.get(n) ?? /* @__PURE__ */ new Set();
|
|
@@ -3308,7 +3308,7 @@ class h {
|
|
|
3308
3308
|
const n = e.get(t) ?? 0;
|
|
3309
3309
|
e.set(t, n + 1);
|
|
3310
3310
|
}
|
|
3311
|
-
return new
|
|
3311
|
+
return new c(function* () {
|
|
3312
3312
|
for (const [t, n] of e)
|
|
3313
3313
|
yield [t, n];
|
|
3314
3314
|
});
|
|
@@ -3377,7 +3377,7 @@ class h {
|
|
|
3377
3377
|
*/
|
|
3378
3378
|
reorganizeBy(e) {
|
|
3379
3379
|
const t = this._elements;
|
|
3380
|
-
return new
|
|
3380
|
+
return new d(function* () {
|
|
3381
3381
|
const n = /* @__PURE__ */ new Map();
|
|
3382
3382
|
for (const [s, r] of t) {
|
|
3383
3383
|
const o = n.get(s) ?? 0;
|
|
@@ -3564,8 +3564,8 @@ class h {
|
|
|
3564
3564
|
}
|
|
3565
3565
|
[Symbol.toStringTag] = "AggregatedIterator";
|
|
3566
3566
|
}
|
|
3567
|
-
const
|
|
3568
|
-
class
|
|
3567
|
+
const z = Function;
|
|
3568
|
+
class R extends z {
|
|
3569
3569
|
/**
|
|
3570
3570
|
* Initializes a new instance of the {@link CallableObject} class.
|
|
3571
3571
|
*/
|
|
@@ -3576,7 +3576,7 @@ class M extends N {
|
|
|
3576
3576
|
}
|
|
3577
3577
|
[Symbol.toStringTag] = "CallableObject";
|
|
3578
3578
|
}
|
|
3579
|
-
class
|
|
3579
|
+
class Q extends R {
|
|
3580
3580
|
/**
|
|
3581
3581
|
* The array containing all the functions in the chain.
|
|
3582
3582
|
*/
|
|
@@ -3614,7 +3614,10 @@ class K extends M {
|
|
|
3614
3614
|
* @returns An array containing the return values of all functions.
|
|
3615
3615
|
*/
|
|
3616
3616
|
_invoke(...e) {
|
|
3617
|
-
|
|
3617
|
+
const t = this._callbacks.length, n = new Array(t);
|
|
3618
|
+
for (let s = 0; s < t; s += 1)
|
|
3619
|
+
n[s] = this._callbacks[s](...e);
|
|
3620
|
+
return n;
|
|
3618
3621
|
}
|
|
3619
3622
|
/**
|
|
3620
3623
|
* Adds a function to the chain.
|
|
@@ -3683,7 +3686,7 @@ class K extends M {
|
|
|
3683
3686
|
}
|
|
3684
3687
|
[Symbol.toStringTag] = "CallbackChain";
|
|
3685
3688
|
}
|
|
3686
|
-
class
|
|
3689
|
+
class v {
|
|
3687
3690
|
/**
|
|
3688
3691
|
* A map containing all the subscribers for each event.
|
|
3689
3692
|
*
|
|
@@ -3739,14 +3742,21 @@ class g {
|
|
|
3739
3742
|
*/
|
|
3740
3743
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
3741
3744
|
createScope() {
|
|
3742
|
-
const e = new
|
|
3745
|
+
const e = new v();
|
|
3743
3746
|
return this.subscribe("__internals__:clear", () => e.clear()), this.subscribe("*", (t, ...n) => {
|
|
3744
3747
|
e.publish(t, ...n);
|
|
3745
3748
|
}), e;
|
|
3746
3749
|
}
|
|
3747
3750
|
publish(e, ...t) {
|
|
3748
3751
|
let n, s = this._subscribers.get(e);
|
|
3749
|
-
|
|
3752
|
+
if (s) {
|
|
3753
|
+
const r = s.slice(), o = r.length;
|
|
3754
|
+
n = new Array(o);
|
|
3755
|
+
for (let a = 0; a < o; a += 1)
|
|
3756
|
+
n[a] = r[a](...t);
|
|
3757
|
+
} else
|
|
3758
|
+
n = [];
|
|
3759
|
+
return e.startsWith("__") || (s = this._subscribers.get("*"), s && s.slice().forEach((r) => r(e, ...t))), n;
|
|
3750
3760
|
}
|
|
3751
3761
|
subscribe(e, t) {
|
|
3752
3762
|
const n = this._subscribers.get(e) ?? [];
|
|
@@ -3794,9 +3804,9 @@ class g {
|
|
|
3794
3804
|
}
|
|
3795
3805
|
[Symbol.toStringTag] = "Publisher";
|
|
3796
3806
|
}
|
|
3797
|
-
const
|
|
3807
|
+
const A = () => {
|
|
3798
3808
|
};
|
|
3799
|
-
class
|
|
3809
|
+
class H extends R {
|
|
3800
3810
|
/**
|
|
3801
3811
|
* The currently selected implementation of the callback.
|
|
3802
3812
|
*/
|
|
@@ -3844,7 +3854,7 @@ class Q extends M {
|
|
|
3844
3854
|
_invoke;
|
|
3845
3855
|
constructor(e, t = "default") {
|
|
3846
3856
|
super(), this._callbacks = /* @__PURE__ */ new Map(), this._isEnabled = !0, e ? this._callbacks.set(t, e) : (t = "", e = (() => {
|
|
3847
|
-
throw new
|
|
3857
|
+
throw new j(
|
|
3848
3858
|
"The `SwitchableCallback` has no callback defined yet. Did you forget to call the `register` method?"
|
|
3849
3859
|
);
|
|
3850
3860
|
})), this._key = t, this._callback = e, this._invoke = (...n) => this._callback(...n);
|
|
@@ -3874,16 +3884,16 @@ class Q extends M {
|
|
|
3874
3884
|
enable(e) {
|
|
3875
3885
|
if (e === void 0) {
|
|
3876
3886
|
if (!this._key)
|
|
3877
|
-
throw new
|
|
3887
|
+
throw new b(
|
|
3878
3888
|
"The `SwitchableCallback` has no callback defined yet. Did you forget to call the `register` method?"
|
|
3879
3889
|
);
|
|
3880
3890
|
e = this._key;
|
|
3881
3891
|
} else if (e) {
|
|
3882
3892
|
if (!this._callbacks.has(e))
|
|
3883
|
-
throw new
|
|
3884
|
-
} else throw new
|
|
3893
|
+
throw new b(`The key '${e}' doesn't yet have any associated callback.`);
|
|
3894
|
+
} else throw new b("The key must be a non-empty string.");
|
|
3885
3895
|
if (this._isEnabled)
|
|
3886
|
-
throw new
|
|
3896
|
+
throw new y("The `SwitchableCallback` is already enabled.");
|
|
3887
3897
|
this._callback = this._callbacks.get(e), this._isEnabled = !0;
|
|
3888
3898
|
}
|
|
3889
3899
|
/**
|
|
@@ -3901,8 +3911,8 @@ class Q extends M {
|
|
|
3901
3911
|
*/
|
|
3902
3912
|
disable() {
|
|
3903
3913
|
if (!this._isEnabled)
|
|
3904
|
-
throw new
|
|
3905
|
-
this._callback =
|
|
3914
|
+
throw new y("The `SwitchableCallback` is already disabled.");
|
|
3915
|
+
this._callback = A, this._isEnabled = !1;
|
|
3906
3916
|
}
|
|
3907
3917
|
/**
|
|
3908
3918
|
* Registers a new implementation for the callback.
|
|
@@ -3928,7 +3938,7 @@ class Q extends M {
|
|
|
3928
3938
|
if (this._callbacks.size === 0)
|
|
3929
3939
|
this._key = e, this._callback = t;
|
|
3930
3940
|
else if (this._callbacks.has(e))
|
|
3931
|
-
throw new
|
|
3941
|
+
throw new b(`The key '${e}' has already been used for another callback.`);
|
|
3932
3942
|
this._callbacks.set(e, t);
|
|
3933
3943
|
}
|
|
3934
3944
|
/**
|
|
@@ -3951,9 +3961,9 @@ class Q extends M {
|
|
|
3951
3961
|
*/
|
|
3952
3962
|
unregister(e) {
|
|
3953
3963
|
if (this._key === e)
|
|
3954
|
-
throw new
|
|
3964
|
+
throw new b("Unable to unregister the currently selected callback.");
|
|
3955
3965
|
if (!this._callbacks.has(e))
|
|
3956
|
-
throw new
|
|
3966
|
+
throw new b(`The key '${e}' doesn't yet have any associated callback.`);
|
|
3957
3967
|
this._callbacks.delete(e);
|
|
3958
3968
|
}
|
|
3959
3969
|
/**
|
|
@@ -3976,12 +3986,12 @@ class Q extends M {
|
|
|
3976
3986
|
*/
|
|
3977
3987
|
switch(e) {
|
|
3978
3988
|
if (!this._callbacks.has(e))
|
|
3979
|
-
throw new
|
|
3989
|
+
throw new b(`The key '${e}' doesn't yet have any associated callback.`);
|
|
3980
3990
|
this._key !== e && (this._key = e, this._isEnabled && (this._callback = this._callbacks.get(e)));
|
|
3981
3991
|
}
|
|
3982
3992
|
[Symbol.toStringTag] = "SwitchableCallback";
|
|
3983
3993
|
}
|
|
3984
|
-
class
|
|
3994
|
+
class X extends Map {
|
|
3985
3995
|
/**
|
|
3986
3996
|
* The internal {@link Publisher} instance used to publish events.
|
|
3987
3997
|
*/
|
|
@@ -4001,7 +4011,7 @@ class H extends Map {
|
|
|
4001
4011
|
* @param iterable An optional iterable of key-value pairs to initialize the {@link Map} with.
|
|
4002
4012
|
*/
|
|
4003
4013
|
constructor(e) {
|
|
4004
|
-
if (super(), this._publisher = new
|
|
4014
|
+
if (super(), this._publisher = new v(), e)
|
|
4005
4015
|
for (const [t, n] of e)
|
|
4006
4016
|
this.set(t, n);
|
|
4007
4017
|
}
|
|
@@ -4138,7 +4148,7 @@ class H extends Map {
|
|
|
4138
4148
|
}
|
|
4139
4149
|
[Symbol.toStringTag] = "MapView";
|
|
4140
4150
|
}
|
|
4141
|
-
class
|
|
4151
|
+
class Z extends Set {
|
|
4142
4152
|
/**
|
|
4143
4153
|
* The internal {@link Publisher} instance used to publish events.
|
|
4144
4154
|
*/
|
|
@@ -4158,7 +4168,7 @@ class X extends Set {
|
|
|
4158
4168
|
* @param iterable An optional iterable of values to initialize the {@link Set} with.
|
|
4159
4169
|
*/
|
|
4160
4170
|
constructor(e) {
|
|
4161
|
-
if (super(), this._publisher = new
|
|
4171
|
+
if (super(), this._publisher = new v(), e)
|
|
4162
4172
|
for (const t of e)
|
|
4163
4173
|
this.add(t);
|
|
4164
4174
|
}
|
|
@@ -4294,7 +4304,7 @@ class X extends Set {
|
|
|
4294
4304
|
}
|
|
4295
4305
|
[Symbol.toStringTag] = "SetView";
|
|
4296
4306
|
}
|
|
4297
|
-
class
|
|
4307
|
+
class W {
|
|
4298
4308
|
/**
|
|
4299
4309
|
* Whether to prefer the {@link localStorage} over the {@link sessionStorage} when calling an ambivalent method.
|
|
4300
4310
|
*
|
|
@@ -4328,8 +4338,8 @@ class Z {
|
|
|
4328
4338
|
* If omitted, it defaults to `true` to prefer the persistent storage.
|
|
4329
4339
|
*/
|
|
4330
4340
|
constructor(e = !0) {
|
|
4331
|
-
if (!
|
|
4332
|
-
throw new
|
|
4341
|
+
if (!E)
|
|
4342
|
+
throw new O(
|
|
4333
4343
|
"The `JSONStorage` class can only be instantiated within a browser environment."
|
|
4334
4344
|
);
|
|
4335
4345
|
this._preferPersistence = e, this._volatile = window.sessionStorage, this._persistent = window.localStorage;
|
|
@@ -4735,7 +4745,7 @@ class m {
|
|
|
4735
4745
|
}
|
|
4736
4746
|
[Symbol.toStringTag] = "SmartPromise";
|
|
4737
4747
|
}
|
|
4738
|
-
class
|
|
4748
|
+
class F extends m {
|
|
4739
4749
|
/**
|
|
4740
4750
|
* The exposed function that allows to resolve the promise.
|
|
4741
4751
|
*
|
|
@@ -4808,7 +4818,7 @@ class R extends m {
|
|
|
4808
4818
|
}
|
|
4809
4819
|
[Symbol.toStringTag] = "DeferredPromise";
|
|
4810
4820
|
}
|
|
4811
|
-
class
|
|
4821
|
+
class q extends m {
|
|
4812
4822
|
/**
|
|
4813
4823
|
* Initializes a new instance of the {@link TimedPromise} class.
|
|
4814
4824
|
*
|
|
@@ -4833,17 +4843,17 @@ class z extends m {
|
|
|
4833
4843
|
*/
|
|
4834
4844
|
constructor(e, t) {
|
|
4835
4845
|
super((n, s) => {
|
|
4836
|
-
const r = (
|
|
4837
|
-
clearTimeout(
|
|
4838
|
-
}, o = (
|
|
4839
|
-
clearTimeout(
|
|
4840
|
-
},
|
|
4846
|
+
const r = (_) => {
|
|
4847
|
+
clearTimeout(f), n(_);
|
|
4848
|
+
}, o = (_) => {
|
|
4849
|
+
clearTimeout(f), s(_);
|
|
4850
|
+
}, f = setTimeout(() => o(new N("The operation has timed out.")), t);
|
|
4841
4851
|
e(r, o);
|
|
4842
4852
|
});
|
|
4843
4853
|
}
|
|
4844
4854
|
[Symbol.toStringTag] = "TimedPromise";
|
|
4845
4855
|
}
|
|
4846
|
-
class
|
|
4856
|
+
class U extends m {
|
|
4847
4857
|
/**
|
|
4848
4858
|
* The number of promises currently in the queue.
|
|
4849
4859
|
*/
|
|
@@ -4867,7 +4877,7 @@ class W extends m {
|
|
|
4867
4877
|
* Accessing this property will always result in a {@link ValueException}.
|
|
4868
4878
|
*/
|
|
4869
4879
|
get isRejected() {
|
|
4870
|
-
throw new
|
|
4880
|
+
throw new u("`PromiseQueue` doesn't support rejection states.");
|
|
4871
4881
|
}
|
|
4872
4882
|
/**
|
|
4873
4883
|
* Initializes a new instance of the {@link PromiseQueue} class.
|
|
@@ -4876,7 +4886,7 @@ class W extends m {
|
|
|
4876
4886
|
super((e) => e()), this._count = 0, this._isPending = !1, this._isFulfilled = !1, this._isRejected = !1;
|
|
4877
4887
|
}
|
|
4878
4888
|
enqueue(e, t) {
|
|
4879
|
-
if (this._count += 1, e instanceof
|
|
4889
|
+
if (this._count += 1, e instanceof F) {
|
|
4880
4890
|
const s = e;
|
|
4881
4891
|
e = () => (s.resolve(), s);
|
|
4882
4892
|
}
|
|
@@ -4887,18 +4897,18 @@ class W extends m {
|
|
|
4887
4897
|
this._count -= 1, r(o);
|
|
4888
4898
|
});
|
|
4889
4899
|
};
|
|
4890
|
-
return t ? new
|
|
4900
|
+
return t ? new q(n, t) : new m(n);
|
|
4891
4901
|
}
|
|
4892
4902
|
[Symbol.toStringTag] = "PromiseQueue";
|
|
4893
4903
|
}
|
|
4894
|
-
var S = /* @__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))(S || {}),
|
|
4895
|
-
function
|
|
4904
|
+
var S = /* @__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))(S || {}), I = /* @__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))(I || {});
|
|
4905
|
+
function ee(i, e, t = 864e5) {
|
|
4896
4906
|
let n;
|
|
4897
4907
|
return i = new Date(i), e = new Date(e), i < e ? n = Math.floor : n = Math.ceil, n((e.getTime() - i.getTime()) / t);
|
|
4898
4908
|
}
|
|
4899
|
-
function
|
|
4909
|
+
function te(i, e, t = 864e5) {
|
|
4900
4910
|
if (i = new Date(i), e = new Date(e), i >= e)
|
|
4901
|
-
throw new
|
|
4911
|
+
throw new x("The end date must be greater than the start date.");
|
|
4902
4912
|
return new l(function* () {
|
|
4903
4913
|
const n = e.getTime();
|
|
4904
4914
|
let s = i.getTime();
|
|
@@ -4906,23 +4916,23 @@ function ee(i, e, t = 864e5) {
|
|
|
4906
4916
|
yield new Date(s), s += t;
|
|
4907
4917
|
});
|
|
4908
4918
|
}
|
|
4909
|
-
function
|
|
4919
|
+
function $(i, e = 864e5) {
|
|
4910
4920
|
if (e <= 1)
|
|
4911
|
-
throw new
|
|
4921
|
+
throw new x(
|
|
4912
4922
|
"Rounding a timestamp by milliseconds or less makes no sense.Use the timestamp value directly instead."
|
|
4913
4923
|
);
|
|
4914
4924
|
if (e > 864e5)
|
|
4915
|
-
throw new
|
|
4925
|
+
throw new x(
|
|
4916
4926
|
"Rounding by more than a day leads to unexpected results. Consider using other methods to round dates by weeks, months or years."
|
|
4917
4927
|
);
|
|
4918
4928
|
return i = new Date(i), new Date(Math.floor(i.getTime() / e) * e);
|
|
4919
4929
|
}
|
|
4920
|
-
function
|
|
4930
|
+
function ne(i, e = 0) {
|
|
4921
4931
|
i = new Date(i);
|
|
4922
4932
|
const t = 7 - e, n = (i.getUTCDay() + t) % 7, s = i.getTime() - 864e5 * n;
|
|
4923
|
-
return
|
|
4933
|
+
return $(new Date(s));
|
|
4924
4934
|
}
|
|
4925
|
-
class
|
|
4935
|
+
class C {
|
|
4926
4936
|
/**
|
|
4927
4937
|
* The handle of the interval or the animation frame, depending on the environment.
|
|
4928
4938
|
* It's used to stop the game loop when the {@link GameLoop._stop} method is called.
|
|
@@ -5000,13 +5010,13 @@ class F {
|
|
|
5000
5010
|
* The interval in milliseconds that will be used if the current environment isn't a browser. Default is `40`.
|
|
5001
5011
|
*/
|
|
5002
5012
|
constructor(e, t = 40) {
|
|
5003
|
-
this._startTime = 0, this._isRunning = !1,
|
|
5013
|
+
this._startTime = 0, this._isRunning = !1, E ? (this._start = () => {
|
|
5004
5014
|
e(this.elapsedTime), this._handle = window.requestAnimationFrame(this._start);
|
|
5005
5015
|
}, this._stop = () => window.cancelAnimationFrame(this._handle)) : (console.warn(
|
|
5006
5016
|
`Not a browser environment detected. Using setInterval@${t}ms instead of requestAnimationFrame...`
|
|
5007
5017
|
), this._start = () => {
|
|
5008
5018
|
this._handle = setInterval(() => e(this.elapsedTime), t);
|
|
5009
|
-
}, this._stop = () => clearInterval(this._handle)), this._publisher = new
|
|
5019
|
+
}, this._stop = () => clearInterval(this._handle)), this._publisher = new v();
|
|
5010
5020
|
}
|
|
5011
5021
|
/**
|
|
5012
5022
|
* Starts the execution of the game loop.
|
|
@@ -5027,7 +5037,7 @@ class F {
|
|
|
5027
5037
|
*/
|
|
5028
5038
|
start(e = 0) {
|
|
5029
5039
|
if (this._isRunning)
|
|
5030
|
-
throw new
|
|
5040
|
+
throw new y("The game loop has already been started.");
|
|
5031
5041
|
this._startTime = performance.now() - e, this._start(), this._isRunning = !0, this._publisher.publish("start");
|
|
5032
5042
|
}
|
|
5033
5043
|
/**
|
|
@@ -5045,9 +5055,9 @@ class F {
|
|
|
5045
5055
|
*/
|
|
5046
5056
|
stop() {
|
|
5047
5057
|
if (!this._isRunning)
|
|
5048
|
-
throw new
|
|
5058
|
+
throw new y("The game loop had already stopped or hadn't yet started.");
|
|
5049
5059
|
if (!this._handle)
|
|
5050
|
-
throw new
|
|
5060
|
+
throw new g();
|
|
5051
5061
|
this._stop(), this._handle = void 0, this._isRunning = !1, this._publisher.publish("stop");
|
|
5052
5062
|
}
|
|
5053
5063
|
/**
|
|
@@ -5090,7 +5100,7 @@ class F {
|
|
|
5090
5100
|
}
|
|
5091
5101
|
[Symbol.toStringTag] = "GameLoop";
|
|
5092
5102
|
}
|
|
5093
|
-
class
|
|
5103
|
+
class se extends C {
|
|
5094
5104
|
/**
|
|
5095
5105
|
* Initializes a new instance of the {@link Clock} class.
|
|
5096
5106
|
*
|
|
@@ -5129,7 +5139,7 @@ class ne extends F {
|
|
|
5129
5139
|
*/
|
|
5130
5140
|
start(e = 0) {
|
|
5131
5141
|
if (this._isRunning)
|
|
5132
|
-
throw new
|
|
5142
|
+
throw new y("The clock has already been started.");
|
|
5133
5143
|
this._startTime = performance.now() - e, this._start(), this._isRunning = !0, this._publisher.publish("start");
|
|
5134
5144
|
}
|
|
5135
5145
|
/**
|
|
@@ -5147,9 +5157,9 @@ class ne extends F {
|
|
|
5147
5157
|
*/
|
|
5148
5158
|
stop() {
|
|
5149
5159
|
if (!this._isRunning)
|
|
5150
|
-
throw new
|
|
5160
|
+
throw new y("The clock had already stopped or hadn't yet started.");
|
|
5151
5161
|
if (!this._handle)
|
|
5152
|
-
throw new
|
|
5162
|
+
throw new g();
|
|
5153
5163
|
this._stop(), this._handle = void 0, this._isRunning = !1, this._publisher.publish("stop");
|
|
5154
5164
|
}
|
|
5155
5165
|
/**
|
|
@@ -5178,7 +5188,7 @@ class ne extends F {
|
|
|
5178
5188
|
*/
|
|
5179
5189
|
onTick(e, t = 0) {
|
|
5180
5190
|
if (t < 0)
|
|
5181
|
-
throw new
|
|
5191
|
+
throw new x("The tick step must be a non-negative number.");
|
|
5182
5192
|
if (t === 0)
|
|
5183
5193
|
return this._publisher.subscribe("tick", e);
|
|
5184
5194
|
let n = 0;
|
|
@@ -5188,7 +5198,7 @@ class ne extends F {
|
|
|
5188
5198
|
}
|
|
5189
5199
|
[Symbol.toStringTag] = "Clock";
|
|
5190
5200
|
}
|
|
5191
|
-
class
|
|
5201
|
+
class re extends C {
|
|
5192
5202
|
/**
|
|
5193
5203
|
* The total duration of the countdown in milliseconds.
|
|
5194
5204
|
*
|
|
@@ -5253,9 +5263,9 @@ class se extends F {
|
|
|
5253
5263
|
*/
|
|
5254
5264
|
_deferrerStop(e) {
|
|
5255
5265
|
if (!this._isRunning)
|
|
5256
|
-
throw new
|
|
5266
|
+
throw new y("The countdown hadn't yet started.");
|
|
5257
5267
|
if (!this._deferrer)
|
|
5258
|
-
throw new
|
|
5268
|
+
throw new g();
|
|
5259
5269
|
this._stop(), this._handle = void 0, this._isRunning = !1, e !== void 0 ? this._deferrer.reject(e) : this._deferrer.resolve(), this._deferrer = void 0;
|
|
5260
5270
|
}
|
|
5261
5271
|
/**
|
|
@@ -5281,10 +5291,10 @@ class se extends F {
|
|
|
5281
5291
|
*/
|
|
5282
5292
|
start(e = this.duration) {
|
|
5283
5293
|
if (this._isRunning)
|
|
5284
|
-
throw new
|
|
5294
|
+
throw new y("The countdown had already stopped or hadn't yet started.");
|
|
5285
5295
|
if (this._deferrer)
|
|
5286
|
-
throw new
|
|
5287
|
-
return this._deferrer = new
|
|
5296
|
+
throw new g();
|
|
5297
|
+
return this._deferrer = new F(), super.start(this.duration - e), this._publisher.publish("start"), this._deferrer;
|
|
5288
5298
|
}
|
|
5289
5299
|
/**
|
|
5290
5300
|
* Stops the execution of the countdown.
|
|
@@ -5336,7 +5346,7 @@ class se extends F {
|
|
|
5336
5346
|
*/
|
|
5337
5347
|
onTick(e, t = 0) {
|
|
5338
5348
|
if (t < 0)
|
|
5339
|
-
throw new
|
|
5349
|
+
throw new x("The tick step must be a non-negative number.");
|
|
5340
5350
|
if (t === 0)
|
|
5341
5351
|
return this._publisher.subscribe("tick", e);
|
|
5342
5352
|
let n = this.remainingTime;
|
|
@@ -5366,7 +5376,7 @@ class se extends F {
|
|
|
5366
5376
|
}
|
|
5367
5377
|
[Symbol.toStringTag] = "Countdown";
|
|
5368
5378
|
}
|
|
5369
|
-
class
|
|
5379
|
+
class ie {
|
|
5370
5380
|
/**
|
|
5371
5381
|
* Generates a given number of values following a linear curve.
|
|
5372
5382
|
* The values are equally spaced and normalized between 0 and 1.
|
|
@@ -5424,7 +5434,7 @@ class re {
|
|
|
5424
5434
|
*/
|
|
5425
5435
|
static Exponential(e, t = 2) {
|
|
5426
5436
|
if (t < 0)
|
|
5427
|
-
throw new
|
|
5437
|
+
throw new u("The base of the exponential curve cannot be negative.");
|
|
5428
5438
|
const n = e - 1;
|
|
5429
5439
|
return new l(function* () {
|
|
5430
5440
|
for (let s = 0; s < e; s += 1)
|
|
@@ -5435,7 +5445,7 @@ class re {
|
|
|
5435
5445
|
}
|
|
5436
5446
|
[Symbol.toStringTag] = "Curve";
|
|
5437
5447
|
}
|
|
5438
|
-
class
|
|
5448
|
+
class P {
|
|
5439
5449
|
/**
|
|
5440
5450
|
* Generates a random boolean value.
|
|
5441
5451
|
*
|
|
@@ -5483,7 +5493,7 @@ class C {
|
|
|
5483
5493
|
*/
|
|
5484
5494
|
static Index(e) {
|
|
5485
5495
|
if (e.length === 0)
|
|
5486
|
-
throw new
|
|
5496
|
+
throw new u("You must provide at least one element.");
|
|
5487
5497
|
return this.Integer(e.length);
|
|
5488
5498
|
}
|
|
5489
5499
|
/**
|
|
@@ -5501,35 +5511,67 @@ class C {
|
|
|
5501
5511
|
* @returns A random element from the given array.
|
|
5502
5512
|
*/
|
|
5503
5513
|
static Choice(e) {
|
|
5504
|
-
return e[
|
|
5514
|
+
return e[P.Index(e)];
|
|
5515
|
+
}
|
|
5516
|
+
static Sample(e, t, n) {
|
|
5517
|
+
const s = e.length;
|
|
5518
|
+
if (s === 0)
|
|
5519
|
+
throw new u("You must provide at least one element.");
|
|
5520
|
+
if (t < 0)
|
|
5521
|
+
throw new u("Count must be non-negative.");
|
|
5522
|
+
if (t > s)
|
|
5523
|
+
throw new u("Count cannot exceed the number of elements.");
|
|
5524
|
+
if (t === 0)
|
|
5525
|
+
return [];
|
|
5526
|
+
if (n === void 0) {
|
|
5527
|
+
const a = [...e], f = new Array(t);
|
|
5528
|
+
for (let _ = 0; _ < t; _ += 1) {
|
|
5529
|
+
const T = this.Integer(_, s);
|
|
5530
|
+
f[_] = a[T], a[T] = a[_];
|
|
5531
|
+
}
|
|
5532
|
+
return f;
|
|
5533
|
+
}
|
|
5534
|
+
if (n.length !== s)
|
|
5535
|
+
throw new u("Weights array must have the same length as elements array.");
|
|
5536
|
+
const r = new Array(s);
|
|
5537
|
+
for (let a = 0; a < s; a += 1) {
|
|
5538
|
+
if (n[a] <= 0)
|
|
5539
|
+
throw new u(`Weight for element #${a} must be greater than zero.`);
|
|
5540
|
+
r[a] = { index: a, key: Math.pow(Math.random(), 1 / n[a]) };
|
|
5541
|
+
}
|
|
5542
|
+
r.sort((a, f) => f.key - a.key);
|
|
5543
|
+
const o = new Array(t);
|
|
5544
|
+
for (let a = 0; a < t; a += 1)
|
|
5545
|
+
o[a] = e[r[a].index];
|
|
5546
|
+
return o;
|
|
5505
5547
|
}
|
|
5506
5548
|
constructor() {
|
|
5507
5549
|
}
|
|
5508
5550
|
[Symbol.toStringTag] = "Random";
|
|
5509
5551
|
}
|
|
5510
|
-
function
|
|
5552
|
+
function oe(i) {
|
|
5511
5553
|
return new m((e) => setTimeout(e, i));
|
|
5512
5554
|
}
|
|
5513
|
-
function
|
|
5555
|
+
function ae() {
|
|
5514
5556
|
return new m((i) => requestAnimationFrame(() => i()));
|
|
5515
5557
|
}
|
|
5516
|
-
function
|
|
5558
|
+
function le() {
|
|
5517
5559
|
return new m((i) => setTimeout(i));
|
|
5518
5560
|
}
|
|
5519
|
-
function
|
|
5561
|
+
function ue(i, e = "text/javascript") {
|
|
5520
5562
|
return new m((t, n) => {
|
|
5521
5563
|
const s = document.createElement("script");
|
|
5522
5564
|
s.async = !0, s.defer = !0, s.src = i, s.type = e, s.onload = (r) => t(), s.onerror = (r) => n(r), document.body.appendChild(s);
|
|
5523
5565
|
});
|
|
5524
5566
|
}
|
|
5525
|
-
function
|
|
5567
|
+
function ce(...i) {
|
|
5526
5568
|
return new l(function* () {
|
|
5527
5569
|
for (const e of i)
|
|
5528
5570
|
for (const t of e)
|
|
5529
5571
|
yield t;
|
|
5530
5572
|
});
|
|
5531
5573
|
}
|
|
5532
|
-
function
|
|
5574
|
+
function he(i) {
|
|
5533
5575
|
if (i instanceof Array)
|
|
5534
5576
|
return i.length;
|
|
5535
5577
|
let e = 0;
|
|
@@ -5537,16 +5579,16 @@ function ce(i) {
|
|
|
5537
5579
|
e += 1;
|
|
5538
5580
|
return e;
|
|
5539
5581
|
}
|
|
5540
|
-
function
|
|
5582
|
+
function fe(i) {
|
|
5541
5583
|
return new l(function* () {
|
|
5542
5584
|
let e = 0;
|
|
5543
5585
|
for (const t of i)
|
|
5544
5586
|
yield [e, t], e += 1;
|
|
5545
5587
|
});
|
|
5546
5588
|
}
|
|
5547
|
-
function
|
|
5589
|
+
function de(i, e, t = 1) {
|
|
5548
5590
|
if (t <= 0)
|
|
5549
|
-
throw new
|
|
5591
|
+
throw new x(
|
|
5550
5592
|
"Step must be always a positive number, even when generating numbers in reverse order."
|
|
5551
5593
|
);
|
|
5552
5594
|
return e === void 0 && (e = i, i = 0), i > e ? new l(function* () {
|
|
@@ -5557,7 +5599,7 @@ function fe(i, e, t = 1) {
|
|
|
5557
5599
|
yield n;
|
|
5558
5600
|
});
|
|
5559
5601
|
}
|
|
5560
|
-
function
|
|
5602
|
+
function we(i) {
|
|
5561
5603
|
const e = Array.from(i);
|
|
5562
5604
|
for (let t = e.length - 1; t > 0; t -= 1) {
|
|
5563
5605
|
const n = Math.floor(Math.random() * (t + 1));
|
|
@@ -5572,7 +5614,7 @@ function me(i) {
|
|
|
5572
5614
|
e.has(t) || (e.add(t), yield t);
|
|
5573
5615
|
});
|
|
5574
5616
|
}
|
|
5575
|
-
function
|
|
5617
|
+
function D(i, e) {
|
|
5576
5618
|
const t = i[Symbol.iterator](), n = e[Symbol.iterator]();
|
|
5577
5619
|
return new l(function* () {
|
|
5578
5620
|
for (; ; ) {
|
|
@@ -5583,28 +5625,28 @@ function A(i, e) {
|
|
|
5583
5625
|
}
|
|
5584
5626
|
});
|
|
5585
5627
|
}
|
|
5586
|
-
function
|
|
5628
|
+
function _e(i, e) {
|
|
5587
5629
|
if (e === void 0) {
|
|
5588
5630
|
let r = 0, o = 0;
|
|
5589
5631
|
for (const a of i)
|
|
5590
5632
|
r += a, o += 1;
|
|
5591
5633
|
if (o === 0)
|
|
5592
|
-
throw new
|
|
5634
|
+
throw new u("You must provide at least one value.");
|
|
5593
5635
|
return r / o;
|
|
5594
5636
|
}
|
|
5595
5637
|
let t = 0, n = 0, s = 0;
|
|
5596
|
-
for (const [r, o] of
|
|
5638
|
+
for (const [r, o] of D(i, e)) {
|
|
5597
5639
|
if (o <= 0)
|
|
5598
|
-
throw new
|
|
5640
|
+
throw new u(`The weight for the value #${s} must be greater than zero.`);
|
|
5599
5641
|
t += r * o, n += o, s += 1;
|
|
5600
5642
|
}
|
|
5601
5643
|
if (s === 0)
|
|
5602
|
-
throw new
|
|
5644
|
+
throw new u("You must provide at least one value and weight.");
|
|
5603
5645
|
if (n <= 0)
|
|
5604
|
-
throw new
|
|
5646
|
+
throw new u("The sum of weights must be greater than zero.");
|
|
5605
5647
|
return t / n;
|
|
5606
5648
|
}
|
|
5607
|
-
function
|
|
5649
|
+
function pe(i) {
|
|
5608
5650
|
let e = 0;
|
|
5609
5651
|
for (let t = 0; t < i.length; t += 1) {
|
|
5610
5652
|
const n = i.charCodeAt(t);
|
|
@@ -5612,78 +5654,78 @@ function _e(i) {
|
|
|
5612
5654
|
}
|
|
5613
5655
|
return e;
|
|
5614
5656
|
}
|
|
5615
|
-
function
|
|
5657
|
+
function ye(i) {
|
|
5616
5658
|
let e = 0;
|
|
5617
5659
|
for (const t of i)
|
|
5618
5660
|
e += t;
|
|
5619
5661
|
return e;
|
|
5620
5662
|
}
|
|
5621
|
-
function
|
|
5663
|
+
function be(i) {
|
|
5622
5664
|
return `${i.charAt(0).toUpperCase()}${i.slice(1)}`;
|
|
5623
5665
|
}
|
|
5624
|
-
const
|
|
5666
|
+
const xe = "2.2.3";
|
|
5625
5667
|
export {
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5668
|
+
p as AggregatedAsyncIterator,
|
|
5669
|
+
d as AggregatedIterator,
|
|
5670
|
+
R as CallableObject,
|
|
5671
|
+
Q as CallbackChain,
|
|
5672
|
+
se as Clock,
|
|
5673
|
+
re as Countdown,
|
|
5674
|
+
ie as Curve,
|
|
5675
|
+
F as DeferredPromise,
|
|
5676
|
+
O as EnvironmentException,
|
|
5677
|
+
h as Exception,
|
|
5678
|
+
g as FatalErrorException,
|
|
5679
|
+
M as FileException,
|
|
5638
5680
|
J as FileExistsException,
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5681
|
+
L as FileNotFoundException,
|
|
5682
|
+
C as GameLoop,
|
|
5683
|
+
W as JSONStorage,
|
|
5684
|
+
b as KeyException,
|
|
5685
|
+
X as MapView,
|
|
5686
|
+
V as NetworkException,
|
|
5687
|
+
j as NotImplementedException,
|
|
5688
|
+
G as PermissionException,
|
|
5689
|
+
U as PromiseQueue,
|
|
5690
|
+
v as Publisher,
|
|
5691
|
+
P as Random,
|
|
5692
|
+
x as RangeException,
|
|
5693
|
+
c as ReducedIterator,
|
|
5652
5694
|
k as ReferenceException,
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5695
|
+
y as RuntimeException,
|
|
5696
|
+
Z as SetView,
|
|
5697
|
+
w as SmartAsyncIterator,
|
|
5656
5698
|
l as SmartIterator,
|
|
5657
5699
|
m as SmartPromise,
|
|
5658
|
-
|
|
5700
|
+
H as SwitchableCallback,
|
|
5659
5701
|
S as TimeUnit,
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5702
|
+
q as TimedPromise,
|
|
5703
|
+
N as TimeoutException,
|
|
5704
|
+
K as TypeException,
|
|
5705
|
+
xe as VERSION,
|
|
5706
|
+
u as ValueException,
|
|
5707
|
+
I as WeekDay,
|
|
5708
|
+
_e as average,
|
|
5709
|
+
be as capitalize,
|
|
5710
|
+
ce as chain,
|
|
5711
|
+
he as count,
|
|
5712
|
+
ee as dateDifference,
|
|
5713
|
+
te as dateRange,
|
|
5714
|
+
$ as dateRound,
|
|
5715
|
+
oe as delay,
|
|
5716
|
+
fe as enumerate,
|
|
5717
|
+
ne as getWeek,
|
|
5718
|
+
pe as hash,
|
|
5719
|
+
E as isBrowser,
|
|
5720
|
+
B as isNode,
|
|
5721
|
+
Y as isWorker,
|
|
5722
|
+
ue as loadScript,
|
|
5723
|
+
ae as nextAnimationFrame,
|
|
5724
|
+
de as range,
|
|
5725
|
+
we as shuffle,
|
|
5726
|
+
ye as sum,
|
|
5685
5727
|
me as unique,
|
|
5686
|
-
|
|
5687
|
-
|
|
5728
|
+
le as yieldToEventLoop,
|
|
5729
|
+
D as zip
|
|
5688
5730
|
};
|
|
5689
5731
|
//# sourceMappingURL=core.esm.js.map
|