@byloth/core 1.3.4 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.js +105 -50
- package/dist/core.js.map +1 -1
- package/dist/core.umd.cjs +2 -2
- package/dist/core.umd.cjs.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +5 -2
- package/src/models/aggregators/aggregated-iterator.ts +34 -1
- package/src/models/aggregators/index.ts +7 -2
- package/src/models/aggregators/reduced-iterator.ts +37 -4
- package/src/models/aggregators/types.ts +3 -0
- package/src/models/exception.ts +2 -0
- package/src/models/index.ts +1 -0
- package/src/models/json-storage.ts +2 -0
- package/src/models/smart-iterator.ts +5 -1
- package/src/models/subscribers.ts +2 -0
- package/src/types.ts +3 -0
package/dist/core.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var l = (s, e, t) => (
|
|
1
|
+
var y = Object.defineProperty;
|
|
2
|
+
var g = (s, e, t) => e in s ? y(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var l = (s, e, t) => (g(s, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
4
|
class h extends Error {
|
|
5
5
|
static FromUnknown(e) {
|
|
6
6
|
if (e instanceof h)
|
|
@@ -18,6 +18,9 @@ Caused by ${t.stack}` : this.stack += `
|
|
|
18
18
|
|
|
19
19
|
Caused by ${t}`);
|
|
20
20
|
}
|
|
21
|
+
get [Symbol.toStringTag]() {
|
|
22
|
+
return "Exception";
|
|
23
|
+
}
|
|
21
24
|
}
|
|
22
25
|
class u {
|
|
23
26
|
constructor(e) {
|
|
@@ -125,6 +128,9 @@ class u {
|
|
|
125
128
|
toArray() {
|
|
126
129
|
return Array.from(this);
|
|
127
130
|
}
|
|
131
|
+
get [Symbol.toStringTag]() {
|
|
132
|
+
return "SmartIterator";
|
|
133
|
+
}
|
|
128
134
|
[Symbol.iterator]() {
|
|
129
135
|
return this;
|
|
130
136
|
}
|
|
@@ -148,17 +154,37 @@ class f {
|
|
|
148
154
|
yield [r, e(r, i, n)];
|
|
149
155
|
});
|
|
150
156
|
}
|
|
157
|
+
keys() {
|
|
158
|
+
const e = this._elements;
|
|
159
|
+
return new u(function* () {
|
|
160
|
+
for (const [t] of e)
|
|
161
|
+
yield t;
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
items() {
|
|
165
|
+
return this._elements;
|
|
166
|
+
}
|
|
167
|
+
values() {
|
|
168
|
+
const e = this._elements;
|
|
169
|
+
return new u(function* () {
|
|
170
|
+
for (const [t, n] of e)
|
|
171
|
+
yield n;
|
|
172
|
+
});
|
|
173
|
+
}
|
|
151
174
|
toArray() {
|
|
152
|
-
return Array.from(this.
|
|
175
|
+
return Array.from(this.values());
|
|
153
176
|
}
|
|
154
177
|
toMap() {
|
|
155
|
-
return new Map(this.
|
|
178
|
+
return new Map(this.items());
|
|
156
179
|
}
|
|
157
180
|
toObject() {
|
|
158
|
-
return Object.fromEntries(this.
|
|
181
|
+
return Object.fromEntries(this.items());
|
|
182
|
+
}
|
|
183
|
+
get [Symbol.toStringTag]() {
|
|
184
|
+
return "ReducedIterator";
|
|
159
185
|
}
|
|
160
186
|
}
|
|
161
|
-
class
|
|
187
|
+
class m {
|
|
162
188
|
constructor(e) {
|
|
163
189
|
l(this, "_elements");
|
|
164
190
|
this._elements = new u(e);
|
|
@@ -187,7 +213,7 @@ class d {
|
|
|
187
213
|
}
|
|
188
214
|
filter(e) {
|
|
189
215
|
const t = this._elements;
|
|
190
|
-
return new
|
|
216
|
+
return new m(function* () {
|
|
191
217
|
const n = /* @__PURE__ */ new Map();
|
|
192
218
|
for (const [r, i] of t) {
|
|
193
219
|
const o = n.get(r) ?? 0;
|
|
@@ -197,7 +223,7 @@ class d {
|
|
|
197
223
|
}
|
|
198
224
|
map(e) {
|
|
199
225
|
const t = this._elements;
|
|
200
|
-
return new
|
|
226
|
+
return new m(function* () {
|
|
201
227
|
const n = /* @__PURE__ */ new Map();
|
|
202
228
|
for (const [r, i] of t) {
|
|
203
229
|
const o = n.get(r) ?? 0;
|
|
@@ -226,7 +252,7 @@ class d {
|
|
|
226
252
|
}
|
|
227
253
|
unique() {
|
|
228
254
|
const e = this._elements;
|
|
229
|
-
return new
|
|
255
|
+
return new m(function* () {
|
|
230
256
|
const t = /* @__PURE__ */ new Map();
|
|
231
257
|
for (const [n, r] of e) {
|
|
232
258
|
const i = t.get(n) ?? /* @__PURE__ */ new Set();
|
|
@@ -263,6 +289,23 @@ class d {
|
|
|
263
289
|
yield [t, n];
|
|
264
290
|
});
|
|
265
291
|
}
|
|
292
|
+
keys() {
|
|
293
|
+
const e = this._elements;
|
|
294
|
+
return new u(function* () {
|
|
295
|
+
for (const [t] of e)
|
|
296
|
+
yield t;
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
items() {
|
|
300
|
+
return this._elements;
|
|
301
|
+
}
|
|
302
|
+
values() {
|
|
303
|
+
const e = this._elements;
|
|
304
|
+
return new u(function* () {
|
|
305
|
+
for (const [t, n] of e)
|
|
306
|
+
yield n;
|
|
307
|
+
});
|
|
308
|
+
}
|
|
266
309
|
toArray() {
|
|
267
310
|
return Array.from(this.toMap().values());
|
|
268
311
|
}
|
|
@@ -282,23 +325,29 @@ class d {
|
|
|
282
325
|
}
|
|
283
326
|
return e;
|
|
284
327
|
}
|
|
328
|
+
get [Symbol.toStringTag]() {
|
|
329
|
+
return "AggregatedIterator";
|
|
330
|
+
}
|
|
285
331
|
}
|
|
286
|
-
class
|
|
332
|
+
class d {
|
|
287
333
|
constructor(e) {
|
|
288
334
|
l(this, "_elements");
|
|
289
335
|
this._elements = new u(e);
|
|
290
336
|
}
|
|
291
337
|
filter(e) {
|
|
292
|
-
return new
|
|
338
|
+
return new d(this._elements.filter(e));
|
|
293
339
|
}
|
|
294
340
|
map(e) {
|
|
295
|
-
return new
|
|
341
|
+
return new d(this._elements.map(e));
|
|
296
342
|
}
|
|
297
343
|
unique() {
|
|
298
|
-
return new
|
|
344
|
+
return new d(this._elements.unique());
|
|
299
345
|
}
|
|
300
|
-
|
|
301
|
-
return new
|
|
346
|
+
groupBy(e) {
|
|
347
|
+
return new m(this._elements.map((t, n) => [e(t, n), t]));
|
|
348
|
+
}
|
|
349
|
+
get [Symbol.toStringTag]() {
|
|
350
|
+
return "Aggregator";
|
|
302
351
|
}
|
|
303
352
|
}
|
|
304
353
|
class x {
|
|
@@ -435,6 +484,9 @@ class x {
|
|
|
435
484
|
clear(e) {
|
|
436
485
|
this._volatile.removeItem(e), this._persistent.removeItem(e);
|
|
437
486
|
}
|
|
487
|
+
get [Symbol.toStringTag]() {
|
|
488
|
+
return "JsonStorage";
|
|
489
|
+
}
|
|
438
490
|
}
|
|
439
491
|
class b {
|
|
440
492
|
constructor() {
|
|
@@ -453,8 +505,11 @@ class b {
|
|
|
453
505
|
call(...e) {
|
|
454
506
|
return this._subscribers.slice().map((t) => t(...e));
|
|
455
507
|
}
|
|
508
|
+
get [Symbol.toStringTag]() {
|
|
509
|
+
return "Subscribers";
|
|
510
|
+
}
|
|
456
511
|
}
|
|
457
|
-
class
|
|
512
|
+
class S {
|
|
458
513
|
constructor(e, t) {
|
|
459
514
|
l(this, "_isPending");
|
|
460
515
|
l(this, "_isFulfilled");
|
|
@@ -464,8 +519,8 @@ class k {
|
|
|
464
519
|
l(this, "_promise");
|
|
465
520
|
this._isPending = !0, this._isFulfilled = !1, this._isRejected = !1;
|
|
466
521
|
let n, r;
|
|
467
|
-
const i = (a,
|
|
468
|
-
n = a, r =
|
|
522
|
+
const i = (a, _) => {
|
|
523
|
+
n = a, r = _;
|
|
469
524
|
};
|
|
470
525
|
let o;
|
|
471
526
|
e ? o = (a) => (this._isPending = !1, this._isFulfilled = !0, e(a)) : o = (a) => (this._isPending = !1, this._isFulfilled = !0, a);
|
|
@@ -503,7 +558,7 @@ class k {
|
|
|
503
558
|
return "DeferredPromise";
|
|
504
559
|
}
|
|
505
560
|
}
|
|
506
|
-
class
|
|
561
|
+
class k {
|
|
507
562
|
constructor(e) {
|
|
508
563
|
l(this, "_isPending");
|
|
509
564
|
l(this, "_isFulfilled");
|
|
@@ -535,7 +590,7 @@ class M {
|
|
|
535
590
|
return "SmartPromise";
|
|
536
591
|
}
|
|
537
592
|
}
|
|
538
|
-
class
|
|
593
|
+
class M {
|
|
539
594
|
static Boolean(e = 0.5) {
|
|
540
595
|
return Math.random() < e;
|
|
541
596
|
}
|
|
@@ -552,17 +607,17 @@ class P {
|
|
|
552
607
|
constructor() {
|
|
553
608
|
}
|
|
554
609
|
}
|
|
555
|
-
async function
|
|
610
|
+
async function P(s) {
|
|
556
611
|
return new Promise((e, t) => setTimeout(e, s));
|
|
557
612
|
}
|
|
558
|
-
async function
|
|
613
|
+
async function j() {
|
|
559
614
|
return new Promise((s, e) => requestAnimationFrame(() => s()));
|
|
560
615
|
}
|
|
561
|
-
var
|
|
562
|
-
function
|
|
616
|
+
var w = /* @__PURE__ */ ((s) => (s[s.Second = 1e3] = "Second", s[s.Minute = 6e4] = "Minute", s[s.Hour = 36e5] = "Hour", s[s.Day = 864e5] = "Day", s[s.Week = 6048e5] = "Week", s[s.Month = 2592e6] = "Month", s[s.Year = 31536e6] = "Year", s))(w || {});
|
|
617
|
+
function T(s, e, t = 864e5) {
|
|
563
618
|
return Math.floor((e.getTime() - s.getTime()) / t);
|
|
564
619
|
}
|
|
565
|
-
function
|
|
620
|
+
function R(s, e, t = 864e5) {
|
|
566
621
|
return new u(function* () {
|
|
567
622
|
const n = e.getTime();
|
|
568
623
|
let r = s.getTime();
|
|
@@ -570,10 +625,10 @@ function F(s, e, t = 864e5) {
|
|
|
570
625
|
yield new Date(r), r += t;
|
|
571
626
|
});
|
|
572
627
|
}
|
|
573
|
-
function
|
|
628
|
+
function F(s, e = 864e5) {
|
|
574
629
|
return new Date(Math.floor(s.getTime() / e) * e);
|
|
575
630
|
}
|
|
576
|
-
async function
|
|
631
|
+
async function I(s, e = "text/javascript") {
|
|
577
632
|
return new Promise((t, n) => {
|
|
578
633
|
const r = document.createElement("script");
|
|
579
634
|
r.async = !0, r.defer = !0, r.src = s, r.type = e, r.onload = () => t(), r.onerror = () => n(), document.body.appendChild(r);
|
|
@@ -587,14 +642,14 @@ function A(s) {
|
|
|
587
642
|
e += 1;
|
|
588
643
|
return e;
|
|
589
644
|
}
|
|
590
|
-
function
|
|
645
|
+
function E(s, e, t = 1) {
|
|
591
646
|
return new u(function* () {
|
|
592
647
|
e === void 0 && (e = s, s = 0), s > e && (t = t ?? -1);
|
|
593
648
|
for (let n = s; n < e; n += t)
|
|
594
649
|
yield n;
|
|
595
650
|
});
|
|
596
651
|
}
|
|
597
|
-
function
|
|
652
|
+
function q(s) {
|
|
598
653
|
const e = Array.from(s);
|
|
599
654
|
for (let t = e.length - 1; t > 0; t -= 1) {
|
|
600
655
|
const n = Math.floor(Math.random() * (t + 1));
|
|
@@ -602,14 +657,14 @@ function C(s) {
|
|
|
602
657
|
}
|
|
603
658
|
return e;
|
|
604
659
|
}
|
|
605
|
-
function
|
|
660
|
+
function C(s) {
|
|
606
661
|
return new u(function* () {
|
|
607
662
|
const e = /* @__PURE__ */ new Set();
|
|
608
663
|
for (const t of s)
|
|
609
664
|
e.has(t) || (e.add(t), yield t);
|
|
610
665
|
});
|
|
611
666
|
}
|
|
612
|
-
function
|
|
667
|
+
function v(s, e) {
|
|
613
668
|
return new u(function* () {
|
|
614
669
|
const t = s[Symbol.iterator](), n = e[Symbol.iterator]();
|
|
615
670
|
for (; ; ) {
|
|
@@ -628,7 +683,7 @@ function O(s, e) {
|
|
|
628
683
|
return r / i;
|
|
629
684
|
}
|
|
630
685
|
let t = 0, n = 0;
|
|
631
|
-
for (const [r, i] of
|
|
686
|
+
for (const [r, i] of v(s, e))
|
|
632
687
|
t += r * i, n += i;
|
|
633
688
|
return t / n;
|
|
634
689
|
}
|
|
@@ -649,34 +704,34 @@ function J(s) {
|
|
|
649
704
|
function V(s) {
|
|
650
705
|
return `${s.charAt(0).toUpperCase()}${s.slice(1)}`;
|
|
651
706
|
}
|
|
652
|
-
const z = "1.
|
|
707
|
+
const z = "1.4.1";
|
|
653
708
|
export {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
709
|
+
m as AggregatedIterator,
|
|
710
|
+
d as Aggregator,
|
|
711
|
+
w as DateUnit,
|
|
712
|
+
S as DeferredPromise,
|
|
658
713
|
h as Exception,
|
|
659
714
|
x as JsonStorage,
|
|
660
|
-
|
|
715
|
+
M as Random,
|
|
661
716
|
f as ReducedIterator,
|
|
662
717
|
u as SmartIterator,
|
|
663
|
-
|
|
718
|
+
k as SmartPromise,
|
|
664
719
|
b as Subscribers,
|
|
665
720
|
z as VERSION,
|
|
666
721
|
O as average,
|
|
667
722
|
V as capitalize,
|
|
668
723
|
A as count,
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
724
|
+
T as dateDifference,
|
|
725
|
+
R as dateRange,
|
|
726
|
+
F as dateRound,
|
|
727
|
+
P as delay,
|
|
673
728
|
$ as hash,
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
729
|
+
I as loadScript,
|
|
730
|
+
j as nextAnimationFrame,
|
|
731
|
+
E as range,
|
|
732
|
+
q as shuffle,
|
|
678
733
|
J as sum,
|
|
679
|
-
|
|
680
|
-
|
|
734
|
+
C as unique,
|
|
735
|
+
v as zip
|
|
681
736
|
};
|
|
682
737
|
//# sourceMappingURL=core.js.map
|
package/dist/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sources":["../src/models/exception.ts","../src/models/smart-iterator.ts","../src/models/aggregators/reduced-iterator.ts","../src/models/aggregators/aggregated-iterator.ts","../src/models/aggregators/index.ts","../src/models/json-storage.ts","../src/models/subscribers.ts","../src/models/promises/deferred-promise.ts","../src/models/promises/smart-promise.ts","../src/utils/random.ts","../src/utils/async.ts","../src/utils/date.ts","../src/utils/dom.ts","../src/utils/iterator.ts","../src/utils/math.ts","../src/utils/string.ts","../src/index.ts"],"sourcesContent":["export default class Exception extends Error\n{\n public static FromUnknown(error: unknown): Exception\n {\n if (error instanceof Exception)\n {\n return error;\n }\n if (error instanceof Error)\n {\n const exc = new Exception(error.message);\n\n exc.stack = error.stack;\n exc.name = error.name;\n\n return exc;\n }\n\n return new Exception(`${error}`);\n }\n\n public constructor(message: string, cause?: unknown, name = \"Exception\")\n {\n super(message);\n\n this.cause = cause;\n this.name = name;\n\n if (cause)\n {\n if (cause instanceof Error)\n {\n this.stack += `\\n\\nCaused by ${cause.stack}`;\n }\n else\n {\n this.stack += `\\n\\nCaused by ${cause}`;\n }\n }\n }\n}\n","import type { GeneratorFunction, Iteratee, Reducer } from \"../types.js\";\n\nexport default class SmartIterator<T, R = void, N = undefined> implements Iterator<T, R, N>\n{\n protected _iterator: Iterator<T, R, N>;\n\n public return?: (value?: R) => IteratorResult<T, R>;\n public throw?: (error?: unknown) => IteratorResult<T, R>;\n\n public constructor(iterable: Iterable<T>);\n public constructor(iterator: Iterator<T, R, N>);\n public constructor(generatorFn: GeneratorFunction<T, R, N>);\n public constructor(argument: Iterable<T> | Iterator<T, R, N> | GeneratorFunction<T, R, N>);\n public constructor(argument: Iterable<T> | Iterator<T, R, N> | GeneratorFunction<T, R, N>)\n {\n if (argument instanceof Function)\n {\n this._iterator = argument();\n }\n else if (Symbol.iterator in argument)\n {\n this._iterator = argument[Symbol.iterator]() as Iterator<T, R, N>;\n }\n else\n {\n this._iterator = argument;\n }\n\n if (this._iterator.return) { this.return = (value?: R) => this._iterator.return!(value); }\n if (this._iterator.throw) { this.throw = (error?: unknown) => this._iterator.throw!(error); }\n }\n\n public every(predicate: Iteratee<T, boolean>): boolean\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n\n if (result.done) { return true; }\n if (!(predicate(result.value, index))) { return false; }\n\n index += 1;\n }\n }\n public some(predicate: Iteratee<T, boolean>): boolean\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n\n if (result.done) { return false; }\n if (predicate(result.value, index)) { return true; }\n\n index += 1;\n }\n }\n\n public filter(predicate: Iteratee<T, boolean>): SmartIterator<T, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<T, R>(function* ()\n {\n let index = 0;\n\n while (true)\n {\n const result = iterator.next();\n\n if (result.done) { return result.value; }\n if (predicate(result.value, index)) { yield result.value; }\n\n index += 1;\n }\n });\n }\n public map<V>(iteratee: Iteratee<T, V>): SmartIterator<V, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<V, R>(function* ()\n {\n let index = 0;\n\n while (true)\n {\n const result = iterator.next();\n if (result.done) { return result.value; }\n\n yield iteratee(result.value, index);\n\n index += 1;\n }\n });\n }\n public reduce(reducer: Reducer<T, T>): T;\n public reduce<A>(reducer: Reducer<T, A>, initialValue: A): A;\n public reduce<A>(reducer: Reducer<T, A>, initialValue?: A): A\n {\n let index = 0;\n let accumulator = initialValue;\n if (accumulator === undefined)\n {\n const result = this._iterator.next();\n if (result.done) { throw new TypeError(\"Reduce of empty iterator with no initial value\"); }\n\n accumulator = (result.value as unknown) as A;\n index += 1;\n }\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return accumulator; }\n\n accumulator = reducer(accumulator, result.value, index);\n\n index += 1;\n }\n }\n\n public enumerate(): SmartIterator<[number, T], R>\n {\n return this.map((value, index) => [index, value]);\n }\n public unique(): SmartIterator<T, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<T, R>(function* ()\n {\n const values = new Set<T>();\n\n while (true)\n {\n const result = iterator.next();\n\n if (result.done) { return result.value; }\n if (values.has(result.value)) { continue; }\n\n values.add(result.value);\n\n yield result.value;\n }\n });\n }\n\n public count(): number\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return index; }\n\n index += 1;\n }\n }\n public forEach(iteratee: Iteratee<T>): void\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return; }\n\n iteratee(result.value, index);\n\n index += 1;\n }\n }\n\n public next(...values: N extends undefined ? [] : [N]): IteratorResult<T, R>\n {\n return this._iterator.next(...values);\n }\n\n public toArray(): T[]\n {\n return Array.from(this as Iterable<T>);\n }\n\n public [Symbol.iterator](): SmartIterator<T, R, N> { return this; }\n}\n","import SmartIterator from \"../smart-iterator.js\";\n\nimport type { KeyIteratee } from \"./types.js\";\nimport type { GeneratorFunction } from \"../../types.js\";\n\nexport default class ReducedIterator<K extends PropertyKey, T>\n{\n protected _elements: SmartIterator<[K, T]>;\n\n public constructor(iterable: Iterable<[K, T]>);\n public constructor(iterator: Iterator<[K, T]>);\n public constructor(generatorFn: GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public filter(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, T>\n {\n const elements = this._elements;\n\n return new ReducedIterator(function* ()\n {\n for (const [index, [key, element]] of elements.enumerate())\n {\n if (predicate(key, element, index))\n {\n yield [key, element];\n }\n }\n });\n }\n public map<V>(iteratee: KeyIteratee<K, T, V>): ReducedIterator<K, V>\n {\n const elements = this._elements;\n\n return new ReducedIterator(function* ()\n {\n for (const [index, [key, element]] of elements.enumerate())\n {\n yield [key, iteratee(key, element, index)];\n }\n });\n }\n\n public toArray(): T[]\n {\n return Array.from(this.toMap().values());\n }\n public toMap(): Map<K, T>\n {\n return new Map(this._elements.toArray());\n }\n public toObject(): Record<K, T>\n {\n return Object.fromEntries(this._elements.toArray()) as Record<K, T>;\n }\n}\n","import ReducedIterator from \"./reduced-iterator.js\";\nimport SmartIterator from \"../smart-iterator.js\";\n\nimport type { KeyIteratee, KeyReducer } from \"./types.js\";\nimport type { GeneratorFunction } from \"../../types.js\";\n\nexport default class AggregatedIterator<K extends PropertyKey, T>\n{\n protected _elements: SmartIterator<[K, T]>;\n\n public constructor(iterable: Iterable<[K, T]>);\n public constructor(iterator: Iterator<[K, T]>);\n public constructor(generatorFn: GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public every(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, boolean>\n {\n const indexes = new Map<K, [number, boolean]>();\n\n for (const [key, element] of this._elements)\n {\n const [index, result] = indexes.get(key) ?? [0, true];\n\n if (!(result)) { continue; }\n\n indexes.set(key, [index + 1, predicate(key, element, index)]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, result]] of indexes)\n {\n yield [key, result];\n }\n });\n }\n public some(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, boolean>\n {\n const indexes = new Map<K, [number, boolean]>();\n\n for (const [key, element] of this._elements)\n {\n const [index, result] = indexes.get(key) ?? [0, false];\n\n if (result) { continue; }\n\n indexes.set(key, [index + 1, predicate(key, element, index)]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, result]] of indexes)\n {\n yield [key, result];\n }\n });\n }\n\n public filter(predicate: KeyIteratee<K, T, boolean>): AggregatedIterator<K, T>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const indexes = new Map<K, number>();\n\n for (const [key, element] of elements)\n {\n const index = indexes.get(key) ?? 0;\n\n indexes.set(key, index + 1);\n\n if (predicate(key, element, index)) { yield [key, element]; }\n }\n });\n }\n public map<V>(iteratee: KeyIteratee<K, T, V>): AggregatedIterator<K, V>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const indexes = new Map<K, number>();\n\n for (const [key, element] of elements)\n {\n const index = indexes.get(key) ?? 0;\n\n indexes.set(key, index + 1);\n\n yield [key, iteratee(key, element, index)];\n }\n });\n }\n public reduce(reducer: KeyReducer<K, T, T>): ReducedIterator<K, T>;\n public reduce<A>(reducer: KeyReducer<K, T, A>, initialValue: (key: K) => A): ReducedIterator<K, A>;\n public reduce<A>(reducer: KeyReducer<K, T, A>, initialValue?: (key: K) => A): ReducedIterator<K, A>\n {\n const accumulators = new Map<K, [number, A]>();\n\n for (const [key, element] of this._elements)\n {\n let index: number;\n let accumulator: A;\n\n if (accumulators.has(key))\n {\n [index, accumulator] = accumulators.get(key)!;\n\n index += 1;\n }\n else if (initialValue !== undefined)\n {\n index = 0;\n accumulator = initialValue(key);\n }\n else\n {\n accumulators.set(key, [0, (element as unknown) as A]);\n\n continue;\n }\n\n accumulator = reducer(key, accumulator, element, index);\n\n accumulators.set(key, [index, accumulator]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, accumulator]] of accumulators)\n {\n yield [key, accumulator];\n }\n });\n }\n\n public unique(): AggregatedIterator<K, T>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const keys = new Map<K, Set<T>>();\n\n for (const [key, element] of elements)\n {\n const values = keys.get(key) ?? new Set<T>();\n\n if (values.has(element)) { continue; }\n\n values.add(element);\n keys.set(key, values);\n\n yield [key, element];\n }\n });\n }\n\n public count(): ReducedIterator<K, number>\n {\n const counters = new Map<K, number>();\n\n for (const [key] of this._elements)\n {\n const count = counters.get(key) ?? 0;\n\n counters.set(key, count + 1);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, count] of counters)\n {\n yield [key, count];\n }\n });\n }\n public first(): ReducedIterator<K, T>\n {\n const firsts = new Map<K, T>();\n\n for (const [key, element] of this._elements)\n {\n if (firsts.has(key)) { continue; }\n\n firsts.set(key, element);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, element] of firsts)\n {\n yield [key, element];\n }\n });\n }\n public last(): ReducedIterator<K, T>\n {\n const lasts = new Map<K, T>();\n\n for (const [key, element] of this._elements)\n {\n lasts.set(key, element);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, element] of lasts)\n {\n yield [key, element];\n }\n });\n }\n\n public toArray(): T[][]\n {\n return Array.from(this.toMap().values());\n }\n public toMap(): Map<K, T[]>\n {\n const groups = new Map<K, T[]>();\n\n for (const [key, element] of this._elements)\n {\n const value = groups.get(key) ?? [];\n\n value.push(element);\n groups.set(key, value);\n }\n\n return groups;\n }\n public toObject(): Record<K, T[]>\n {\n const groups = { } as Record<K, T[]>;\n\n for (const [key, element] of this._elements)\n {\n const value = groups[key] ?? [];\n\n value.push(element);\n groups[key] = value;\n }\n\n return groups;\n }\n}\n","import AggregatedIterator from \"./aggregated-iterator.js\";\nimport ReducedIterator from \"./reduced-iterator.js\";\nimport SmartIterator from \"../smart-iterator.js\";\n\nimport type { GeneratorFunction, Iteratee } from \"../../types.js\";\n\nexport default class Aggregator<T>\n{\n protected _elements: SmartIterator<T>;\n\n public constructor(iterable: Iterable<T>);\n public constructor(iterator: Iterator<T>);\n public constructor(generatorFn: GeneratorFunction<T>);\n public constructor(argument: Iterable<T> | Iterator<T> | GeneratorFunction<T>);\n public constructor(argument: Iterable<T> | Iterator<T> | GeneratorFunction<T>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public filter(predicate: Iteratee<T, boolean>): Aggregator<T>\n {\n return new Aggregator(this._elements.filter(predicate));\n }\n public map<V>(iteratee: Iteratee<T, V>): Aggregator<V>\n {\n return new Aggregator(this._elements.map(iteratee));\n }\n\n public unique(): Aggregator<T>\n {\n return new Aggregator(this._elements.unique());\n }\n\n public byKey<K extends PropertyKey>(iteratee: Iteratee<T, K>): AggregatedIterator<K, T>\n {\n return new AggregatedIterator(this._elements.map((element, index) =>\n {\n const key = iteratee(element, index);\n\n return [key, element];\n }));\n }\n}\n\nexport { AggregatedIterator, ReducedIterator };\n","/* eslint-disable no-trailing-spaces */\n\n/**\n * A wrapper around the `Storage` API to store and retrieve JSON values.\n *\n * It allows to handle either the `sessionStorage` or the `localStorage`\n * storage at the same time, depending on the required use case.\n */\nexport default class JsonStorage\n{\n protected _preferPersistence: boolean;\n\n protected _volatile: Storage;\n protected _persistent: Storage;\n\n public constructor(preferPersistence = true)\n {\n this._preferPersistence = preferPersistence;\n\n this._volatile = window.sessionStorage;\n this._persistent = window.localStorage;\n }\n\n protected _get<T>(storage: Storage, propertyName: string): T | undefined;\n protected _get<T>(storage: Storage, propertyName: string, defaultValue: T): T;\n protected _get<T>(storage: Storage, propertyName: string, defaultValue?: T): T | undefined;\n protected _get<T>(storage: Storage, propertyName: string, defaultValue?: T): T | undefined\n {\n const propertyValue = storage.getItem(propertyName);\n if (propertyValue)\n {\n try\n {\n return JSON.parse(propertyValue);\n }\n catch (error)\n {\n // eslint-disable-next-line no-console\n console.warn(\n `The \"${propertyValue}\" value for \"${propertyName}\"` +\n \" property cannot be parsed. Clearing the storage...\");\n\n storage.removeItem(propertyName);\n }\n }\n\n return defaultValue;\n }\n protected _set<T>(storage: Storage, propertyName: string, newValue?: T): void\n {\n const encodedValue = JSON.stringify(newValue);\n if (encodedValue)\n {\n storage.setItem(propertyName, encodedValue);\n }\n else\n {\n storage.removeItem(propertyName);\n }\n }\n\n /**\n * Retrieves the value with the specified name from the corresponding storage.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n * @param persistent Whether to use the persistent `localStorage` or the volatile `sessionStorage`.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public get<T>(propertyName: string, defaultValue: undefined, persistent?: boolean): T | undefined;\n public get<T>(propertyName: string, defaultValue: T, persistent?: boolean): T ;\n public get<T>(propertyName: string, defaultValue?: T, persistent?: boolean): T | undefined;\n public get<T>(propertyName: string, defaultValue?: T, persistent = this._preferPersistence): T | undefined\n {\n const storage = persistent ? this._persistent : this._volatile;\n\n return this._get<T>(storage, propertyName, defaultValue);\n }\n /**\n * Retrieves the value with the specified name from the volatile `sessionStorage`.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public recall<T>(propertyName: string): T | undefined;\n public recall<T>(propertyName: string, defaultValue: T): T;\n public recall<T>(propertyName: string, defaultValue?: T): T | undefined;\n public recall<T>(propertyName: string, defaultValue?: T): T | undefined\n {\n return this._get<T>(this._volatile, propertyName, defaultValue);\n }\n /**\n * Retrieves the value with the specified name looking first in the\n * volatile `sessionStorage` and then in the persistent `localStorage`.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public retrieve<T>(propertyName: string): T | undefined;\n public retrieve<T>(propertyName: string, defaultValue: T): T;\n public retrieve<T>(propertyName: string, defaultValue?: T): T | undefined;\n public retrieve<T>(propertyName: string, defaultValue?: T): T | undefined\n {\n return this.recall<T>(propertyName) ?? this.read<T>(propertyName, defaultValue);\n }\n /**\n * Retrieves the value with the specified name from the persistent `localStorage`.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public read<T>(propertyName: string): T | undefined;\n public read<T>(propertyName: string, defaultValue: T): T;\n public read<T>(propertyName: string, defaultValue?: T): T | undefined;\n public read<T>(propertyName: string, defaultValue?: T): T | undefined\n {\n return this._get<T>(this._persistent, propertyName, defaultValue);\n }\n\n /**\n * Checks whether the property with the specified name exists in the corresponding storage.\n *\n * @param propertyName The name of the property to check.\n * @param persistent Whether to use the persistent `localStorage` or the volatile `sessionStorage`.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public has(propertyName: string, persistent?: boolean): boolean\n {\n const storage = persistent ? this._persistent : this._volatile;\n\n return storage.getItem(propertyName) !== null;\n }\n /**\n * Checks whether the property with the specified name exists in the volatile `sessionStorage`.\n *\n * @param propertyName The name of the property to check.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public knows(propertyName: string): boolean\n {\n return this._volatile.getItem(propertyName) !== null;\n }\n /**\n * Checks whether the property with the specified name exists looking first in the\n * volatile `sessionStorage` and then in the persistent `localStorage`.\n *\n * @param propertyName The name of the property to check.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public find(propertyName: string): boolean\n {\n return this.knows(propertyName) ?? this.exists(propertyName);\n }\n /**\n * Checks whether the property with the specified name exists in the persistent `localStorage`.\n *\n * @param propertyName The name of the property to check.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public exists(propertyName: string): boolean\n {\n return this._persistent.getItem(propertyName) !== null;\n }\n\n /**\n * Sets the value with the specified name in the corresponding storage.\n * If the value is `undefined`, the property is removed from the storage.\n *\n * @param propertyName The name of the property to set.\n * @param newValue The new value to set.\n * @param persistent Whether to use the persistent `localStorage` or the volatile `sessionStorage`.\n */\n public set<T>(propertyName: string, newValue?: T, persistent = this._preferPersistence): void\n {\n const storage = persistent ? this._persistent : this._volatile;\n\n this._set<T>(storage, propertyName, newValue);\n }\n /**\n * Sets the value with the specified name in the volatile `sessionStorage`.\n * If the value is `undefined`, the property is removed from the storage.\n *\n * @param propertyName The name of the property to set.\n * @param newValue The new value to set.\n */\n public remember<T>(propertyName: string, newValue?: T): void\n {\n this._set<T>(this._volatile, propertyName, newValue);\n }\n /**\n * Sets the value with the specified name in the persistent `localStorage`.\n * If the value is `undefined`, the property is removed from the storage.\n *\n * @param propertyName The name of the property to set.\n * @param newValue The new value to set.\n */\n public write<T>(propertyName: string, newValue?: T): void\n {\n this._set<T>(this._persistent, propertyName, newValue);\n }\n\n /**\n * Removes the value with the specified name from the volatile `sessionStorage`.\n *\n * @param propertyName The name of the property to remove.\n */\n public forget(propertyName: string): void\n {\n this._volatile.removeItem(propertyName);\n }\n /**\n * Removes the value with the specified name from the persistent `localStorage`.\n *\n * @param propertyName The name of the property to remove.\n */\n public erase(propertyName: string): void\n {\n this._persistent.removeItem(propertyName);\n }\n /**\n * Removes the value with the specified name from all the storages.\n *\n * @param propertyName The name of the property to remove.\n */\n public clear(propertyName: string): void\n {\n this._volatile.removeItem(propertyName);\n this._persistent.removeItem(propertyName);\n }\n}\n","import Exception from \"./exception.js\";\n\nexport default class Subscribers<P extends unknown[] = [], R = void, T extends (...args: P) => R = (...args: P) => R>\n{\n protected _subscribers: T[];\n\n public constructor()\n {\n this._subscribers = [];\n }\n\n public add(subscriber: T): void\n {\n this._subscribers.push(subscriber);\n }\n public remove(subscriber: T): void\n {\n const index = this._subscribers.indexOf(subscriber);\n if (index < 0)\n {\n throw new Exception(\"Unable to remove the requested subscriber. It was not found.\");\n }\n\n this._subscribers.splice(index, 1);\n }\n\n public call(...args: P): R[]\n {\n return this._subscribers\n .slice()\n .map((subscriber) => subscriber(...args));\n }\n}\n","import type {\n PromiseResolver,\n PromiseRejecter,\n FulfilledHandler,\n RejectedHandler,\n PromiseExecutor\n\n} from \"../../types.js\";\n\nexport default class DeferredPromise<T = void, E = unknown, F = T, R = never>\n{\n protected _isPending: boolean;\n protected _isFulfilled: boolean;\n protected _isRejected: boolean;\n\n protected _resolve!: PromiseResolver<T>;\n protected _reject!: PromiseRejecter<E>;\n\n protected _promise: Promise<F | R>;\n\n public constructor(onFulfilled?: FulfilledHandler<T, F> | null, onRejected?: RejectedHandler<E, R> | null)\n {\n this._isPending = true;\n this._isFulfilled = false;\n this._isRejected = false;\n\n let _resolve: PromiseResolver<T>;\n let _reject: PromiseRejecter<E>;\n\n const executor: PromiseExecutor<T, E> = (resolve, reject) =>\n {\n _resolve = resolve;\n _reject = reject;\n };\n\n let _onFulfilled: FulfilledHandler<T, F>;\n if (onFulfilled)\n {\n _onFulfilled = (value) =>\n {\n this._isPending = false;\n this._isFulfilled = true;\n\n return onFulfilled!(value);\n };\n }\n else\n {\n _onFulfilled = (value) =>\n {\n this._isPending = false;\n this._isFulfilled = true;\n\n return (value as unknown) as F;\n };\n }\n\n let _onRejected: RejectedHandler<E, R>;\n if (onRejected)\n {\n _onRejected = (reason) =>\n {\n this._isPending = false;\n this._isRejected = true;\n\n return onRejected!(reason);\n };\n }\n else\n {\n _onRejected = (reason) =>\n {\n this._isPending = false;\n this._isRejected = true;\n\n return (reason as unknown) as R;\n };\n }\n\n this._promise = new Promise<T>(executor)\n .then(_onFulfilled, _onRejected);\n\n this._resolve = _resolve!;\n this._reject = _reject!;\n }\n\n public get isPending(): boolean { return this._isPending; }\n public get isFulfilled(): boolean { return this._isFulfilled; }\n public get isRejected(): boolean { return this._isRejected; }\n\n public get resolve(): PromiseResolver<T> { return this._resolve; }\n public get reject(): PromiseRejecter<E> { return this._reject; }\n\n public then<N = F | R, H = R>(\n onFulfilled?: FulfilledHandler<F | R, N> | null,\n onRejected?: RejectedHandler<R, H> | null): Promise<N | H>\n {\n return this._promise.then(onFulfilled, onRejected);\n }\n public catch<H = R>(onRejected?: RejectedHandler<R, H> | null): Promise<F | R | H>\n {\n return this._promise.catch(onRejected);\n }\n public finally(onFinally?: (() => void) | null): Promise<F | R>\n {\n return this._promise.finally(onFinally);\n }\n\n public watch(promise: Promise<T>): this\n {\n promise.then(this.resolve, this.reject);\n\n return this;\n }\n\n public get [Symbol.toStringTag]() { return \"DeferredPromise\"; }\n}\n","import type { FulfilledHandler, PromiseExecutor, RejectedHandler } from \"../../types.js\";\n\nexport default class SmartPromise<T = void, E = unknown>\n{\n protected _isPending: boolean;\n protected _isFulfilled: boolean;\n protected _isRejected: boolean;\n\n protected _promise: Promise<T | E>;\n\n public constructor(executor: PromiseExecutor<T, E>)\n {\n this._isPending = true;\n this._isFulfilled = false;\n this._isRejected = false;\n\n const _resolve = (result: T): T =>\n {\n this._isPending = false;\n this._isFulfilled = true;\n\n return result;\n };\n const _reject = (reason: E): E =>\n {\n this._isPending = false;\n this._isRejected = true;\n\n return reason;\n };\n\n this._promise = new Promise<T>(executor)\n .then(_resolve, _reject);\n }\n\n public get isPending(): boolean { return this._isPending; }\n public get isFulfilled(): boolean { return this._isFulfilled; }\n public get isRejected(): boolean { return this._isRejected; }\n\n public then<F = T, R = E>(\n onFulfilled?: FulfilledHandler<T | E, F> | null,\n onRejected?: RejectedHandler<E, R> | null): Promise<F | R>\n {\n return this._promise.then(onFulfilled, onRejected);\n }\n public catch<R = E>(onRejected?: RejectedHandler<E, R> | null): Promise<T | E | R>\n {\n return this._promise.catch(onRejected);\n }\n public finally(onFinally?: (() => void) | null): Promise<T | E>\n {\n return this._promise.finally(onFinally);\n }\n\n public get [Symbol.toStringTag]() { return \"SmartPromise\"; }\n}\n","export default class Random\n{\n public static Boolean(ratio: number = 0.5): boolean\n {\n return (Math.random() < ratio);\n }\n\n public static Integer(max: number): number;\n public static Integer(min: number, max: number): number;\n public static Integer(min: number, max?: number): number\n {\n if (max === undefined)\n {\n return Math.floor(Math.random() * min);\n }\n\n return Math.floor(Math.random() * (max - min) + min);\n }\n\n public static Decimal(max: number): number;\n public static Decimal(min: number, max: number): number;\n public static Decimal(min: number, max?: number): number\n {\n if (max === undefined)\n {\n return (Math.random() * min);\n }\n\n return (Math.random() * (max - min) + min);\n }\n\n public static Choice<T>(elements: T[]): T\n {\n return elements[this.Integer(elements.length)];\n }\n\n // eslint-disable-next-line no-useless-constructor\n private constructor() { }\n}\n","export async function delay(milliseconds: number): Promise<void>\n{\n return new Promise<void>((resolve, reject) => setTimeout(resolve, milliseconds));\n}\n\nexport async function nextAnimationFrame(): Promise<void>\n{\n return new Promise<void>((resolve, reject) => requestAnimationFrame(() => resolve()));\n}\n","import { SmartIterator } from \"../models/index.js\";\n\nexport enum DateUnit\n{\n Second = 1000,\n Minute = 60 * Second,\n Hour = 60 * Minute,\n Day = 24 * Hour,\n Week = 7 * Day,\n Month = 30 * Day,\n Year = 365 * Day\n}\n\nexport function dateDifference(start: Date, end: Date, unit = DateUnit.Day): number\n{\n return Math.floor((end.getTime() - start.getTime()) / unit);\n}\n\nexport function dateRange(start: Date, end: Date, offset = DateUnit.Day): SmartIterator<Date>\n{\n return new SmartIterator<Date>(function* ()\n {\n const endTime = end.getTime();\n\n let unixTime: number = start.getTime();\n while (unixTime < endTime)\n {\n yield new Date(unixTime);\n\n unixTime += offset;\n }\n });\n}\n\nexport function dateRound(date: Date, unit = DateUnit.Day): Date\n{\n return new Date(Math.floor(date.getTime() / unit) * unit);\n}\n","export async function loadScript(scriptUrl: string, scriptType = \"text/javascript\"): Promise<void>\n{\n return new Promise<void>((resolve, reject) =>\n {\n const script = document.createElement(\"script\");\n\n script.async = true;\n script.defer = true;\n script.src = scriptUrl;\n script.type = scriptType;\n\n script.onload = () => resolve();\n script.onerror = () => reject();\n\n document.body.appendChild(script);\n });\n}\n","import { SmartIterator } from \"../models/index.js\";\n\nexport function count<T>(elements: Iterable<T>): number\n{\n if (Array.isArray(elements)) { return elements.length; }\n\n let _count = 0;\n for (const _ of elements) { _count += 1; }\n\n return _count;\n}\n\nexport function enumerate<T>(elements: Iterable<T>): SmartIterator<[number, T]>\n{\n return new SmartIterator<[number, T]>(function* ()\n {\n let index = 0;\n\n for (const element of elements)\n {\n yield [index, element];\n\n index += 1;\n }\n });\n}\n\nexport function range(end: number): SmartIterator<number>;\nexport function range(start: number, end: number): SmartIterator<number>;\nexport function range(start: number, end: number, step: number): SmartIterator<number>;\nexport function range(start: number, end?: number, step = 1): SmartIterator<number>\n{\n return new SmartIterator<number>(function* ()\n {\n if (end === undefined)\n {\n end = start;\n start = 0;\n }\n\n if (start > end) { step = step ?? -1; }\n\n for (let index = start; index < end; index += step) { yield index; }\n });\n}\n\nexport function shuffle<T>(iterable: Iterable<T>): T[]\n{\n const array = Array.from(iterable);\n\n for (let index = array.length - 1; index > 0; index -= 1)\n {\n const jndex = Math.floor(Math.random() * (index + 1));\n\n [array[index], array[jndex]] = [array[jndex], array[index]];\n }\n\n return array;\n}\n\nexport function unique<T>(elements: Iterable<T>): SmartIterator<T>\n{\n return new SmartIterator<T>(function* ()\n {\n const values = new Set<T>();\n\n for (const element of elements)\n {\n if (values.has(element)) { continue; }\n\n values.add(element);\n\n yield element;\n }\n });\n}\n\nexport function zip<T, U>(first: Iterable<T>, second: Iterable<U>): SmartIterator<[T, U]>\n{\n return new SmartIterator<[T, U]>(function* ()\n {\n const firstIterator = first[Symbol.iterator]();\n const secondIterator = second[Symbol.iterator]();\n\n while (true)\n {\n const firstResult = firstIterator.next();\n const secondResult = secondIterator.next();\n\n if ((firstResult.done) || (secondResult.done)) { break; }\n\n yield [firstResult.value, secondResult.value];\n }\n });\n}\n","import { zip } from \"./iterator.js\";\n\nexport function average<T extends number>(values: Iterable<T>): number;\nexport function average<T extends number>(values: Iterable<T>, weights: Iterable<number>): number;\nexport function average<T extends number>(values: Iterable<T>, weights?: Iterable<number>): number\n{\n if (weights === undefined)\n {\n let _sum = 0;\n let _count = 0;\n\n for (const value of values)\n {\n _sum += value;\n _count += 1;\n }\n\n return _sum / _count;\n }\n\n let _sum = 0;\n let _count = 0;\n\n for (const [value, weight] of zip(values, weights))\n {\n _sum += value * weight;\n _count += weight;\n }\n\n return _sum / _count;\n}\n\nexport function hash(value: string): number\n{\n let hashedValue = 0;\n for (let index = 0; index < value.length; index += 1)\n {\n const char = value.charCodeAt(index);\n\n hashedValue = ((hashedValue << 5) - hashedValue) + char;\n hashedValue |= 0;\n }\n\n return hashedValue;\n}\n\nexport function sum<T extends number>(values: Iterable<T>): number\n{\n let _sum = 0;\n for (const value of values) { _sum += value; }\n\n return _sum;\n}\n","export function capitalize(value: string): string\n{\n return `${value.charAt(0).toUpperCase()}${value.slice(1)}`;\n}\n","export const VERSION = \"1.3.4\";\n\nexport {\n AggregatedIterator,\n Aggregator,\n DeferredPromise,\n Exception,\n JsonStorage,\n ReducedIterator,\n SmartIterator,\n SmartPromise,\n Subscribers\n\n} from \"./models/index.js\";\n\nexport {\n average,\n capitalize,\n count,\n delay,\n dateDifference,\n dateRange,\n dateRound,\n DateUnit,\n hash,\n loadScript,\n nextAnimationFrame,\n Random,\n range,\n shuffle,\n sum,\n unique,\n zip\n\n} from \"./utils/index.js\";\n\nexport type {\n Constructor,\n FulfilledHandler,\n GeneratorFunction,\n Interval,\n Iteratee,\n MaybePromise,\n PromiseExecutor,\n PromiseRejecter,\n PromiseResolver,\n Reducer,\n RejectedHandler,\n Timeout\n\n} from \"./types.js\";\n"],"names":["Exception","error","exc","message","cause","name","SmartIterator","argument","__publicField","value","predicate","index","result","iterator","iteratee","reducer","initialValue","accumulator","values","ReducedIterator","elements","key","element","AggregatedIterator","indexes","_","accumulators","keys","counters","count","firsts","lasts","groups","Aggregator","JsonStorage","preferPersistence","storage","propertyName","defaultValue","propertyValue","newValue","encodedValue","persistent","Subscribers","subscriber","args","DeferredPromise","onFulfilled","onRejected","_resolve","_reject","executor","resolve","reject","_onFulfilled","_onRejected","reason","onFinally","promise","SmartPromise","Random","ratio","min","max","delay","milliseconds","nextAnimationFrame","DateUnit","dateDifference","start","end","unit","dateRange","offset","endTime","unixTime","dateRound","date","loadScript","scriptUrl","scriptType","script","_count","range","step","shuffle","iterable","array","jndex","unique","zip","first","second","firstIterator","secondIterator","firstResult","secondResult","average","weights","_sum","weight","hash","hashedValue","char","sum","capitalize","VERSION"],"mappings":";;;AAAA,MAAqBA,UAAkB,MACvC;AAAA,EACI,OAAc,YAAYC,GAC1B;AACI,QAAIA,aAAiBD;AAEV,aAAAC;AAEX,QAAIA,aAAiB,OACrB;AACI,YAAMC,IAAM,IAAIF,EAAUC,EAAM,OAAO;AAEvC,aAAAC,EAAI,QAAQD,EAAM,OAClBC,EAAI,OAAOD,EAAM,MAEVC;AAAA,IACX;AAEA,WAAO,IAAIF,EAAU,GAAGC,CAAK,EAAE;AAAA,EACnC;AAAA,EAEO,YAAYE,GAAiBC,GAAiBC,IAAO,aAC5D;AACI,UAAMF,CAAO,GAEb,KAAK,QAAQC,GACb,KAAK,OAAOC,GAERD,MAEIA,aAAiB,QAEjB,KAAK,SAAS;AAAA;AAAA,YAAiBA,EAAM,KAA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;AACX,aAAW1F,KAASS;AAAkB,IAAAiF,KAAA1F;AAE/B,SAAA0F;AACX;ACpDO,SAASM,EAAWhG,GAC3B;AACW,SAAA,GAAGA,EAAM,OAAO,CAAC,EAAE,aAAa,GAAGA,EAAM,MAAM,CAAC,CAAC;AAC5D;ACHO,MAAMiG,IAAU;"}
|
|
1
|
+
{"version":3,"file":"core.js","sources":["../src/models/exception.ts","../src/models/smart-iterator.ts","../src/models/aggregators/reduced-iterator.ts","../src/models/aggregators/aggregated-iterator.ts","../src/models/aggregators/index.ts","../src/models/json-storage.ts","../src/models/subscribers.ts","../src/models/promises/deferred-promise.ts","../src/models/promises/smart-promise.ts","../src/utils/random.ts","../src/utils/async.ts","../src/utils/date.ts","../src/utils/dom.ts","../src/utils/iterator.ts","../src/utils/math.ts","../src/utils/string.ts","../src/index.ts"],"sourcesContent":["export default class Exception extends Error\n{\n public static FromUnknown(error: unknown): Exception\n {\n if (error instanceof Exception)\n {\n return error;\n }\n if (error instanceof Error)\n {\n const exc = new Exception(error.message);\n\n exc.stack = error.stack;\n exc.name = error.name;\n\n return exc;\n }\n\n return new Exception(`${error}`);\n }\n\n public constructor(message: string, cause?: unknown, name = \"Exception\")\n {\n super(message);\n\n this.cause = cause;\n this.name = name;\n\n if (cause)\n {\n if (cause instanceof Error)\n {\n this.stack += `\\n\\nCaused by ${cause.stack}`;\n }\n else\n {\n this.stack += `\\n\\nCaused by ${cause}`;\n }\n }\n }\n\n public get [Symbol.toStringTag]() { return \"Exception\"; }\n}\n","import type { GeneratorFunction, Iteratee, TypeGuardIteratee, Reducer } from \"../types.js\";\n\nexport default class SmartIterator<T, R = void, N = undefined> implements Iterator<T, R, N>\n{\n protected _iterator: Iterator<T, R, N>;\n\n public return?: (value?: R) => IteratorResult<T, R>;\n public throw?: (error?: unknown) => IteratorResult<T, R>;\n\n public constructor(iterable: Iterable<T>);\n public constructor(iterator: Iterator<T, R, N>);\n public constructor(generatorFn: GeneratorFunction<T, R, N>);\n public constructor(argument: Iterable<T> | Iterator<T, R, N> | GeneratorFunction<T, R, N>);\n public constructor(argument: Iterable<T> | Iterator<T, R, N> | GeneratorFunction<T, R, N>)\n {\n if (argument instanceof Function)\n {\n this._iterator = argument();\n }\n else if (Symbol.iterator in argument)\n {\n this._iterator = argument[Symbol.iterator]() as Iterator<T, R, N>;\n }\n else\n {\n this._iterator = argument;\n }\n\n if (this._iterator.return) { this.return = (value?: R) => this._iterator.return!(value); }\n if (this._iterator.throw) { this.throw = (error?: unknown) => this._iterator.throw!(error); }\n }\n\n public every(predicate: Iteratee<T, boolean>): boolean\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n\n if (result.done) { return true; }\n if (!(predicate(result.value, index))) { return false; }\n\n index += 1;\n }\n }\n public some(predicate: Iteratee<T, boolean>): boolean\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n\n if (result.done) { return false; }\n if (predicate(result.value, index)) { return true; }\n\n index += 1;\n }\n }\n\n public filter(predicate: Iteratee<T, boolean>): SmartIterator<T, R>;\n public filter<S extends T>(predicate: TypeGuardIteratee<T, S>): SmartIterator<T, S>;\n public filter(predicate: Iteratee<T, boolean>): SmartIterator<T, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<T, R>(function* ()\n {\n let index = 0;\n\n while (true)\n {\n const result = iterator.next();\n\n if (result.done) { return result.value; }\n if (predicate(result.value, index)) { yield result.value; }\n\n index += 1;\n }\n });\n }\n public map<V>(iteratee: Iteratee<T, V>): SmartIterator<V, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<V, R>(function* ()\n {\n let index = 0;\n\n while (true)\n {\n const result = iterator.next();\n if (result.done) { return result.value; }\n\n yield iteratee(result.value, index);\n\n index += 1;\n }\n });\n }\n public reduce(reducer: Reducer<T, T>): T;\n public reduce<A>(reducer: Reducer<T, A>, initialValue: A): A;\n public reduce<A>(reducer: Reducer<T, A>, initialValue?: A): A\n {\n let index = 0;\n let accumulator = initialValue;\n if (accumulator === undefined)\n {\n const result = this._iterator.next();\n if (result.done) { throw new TypeError(\"Reduce of empty iterator with no initial value\"); }\n\n accumulator = (result.value as unknown) as A;\n index += 1;\n }\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return accumulator; }\n\n accumulator = reducer(accumulator, result.value, index);\n\n index += 1;\n }\n }\n\n public enumerate(): SmartIterator<[number, T], R>\n {\n return this.map((value, index) => [index, value]);\n }\n public unique(): SmartIterator<T, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<T, R>(function* ()\n {\n const values = new Set<T>();\n\n while (true)\n {\n const result = iterator.next();\n\n if (result.done) { return result.value; }\n if (values.has(result.value)) { continue; }\n\n values.add(result.value);\n\n yield result.value;\n }\n });\n }\n\n public count(): number\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return index; }\n\n index += 1;\n }\n }\n public forEach(iteratee: Iteratee<T>): void\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return; }\n\n iteratee(result.value, index);\n\n index += 1;\n }\n }\n\n public next(...values: N extends undefined ? [] : [N]): IteratorResult<T, R>\n {\n return this._iterator.next(...values);\n }\n\n public toArray(): T[]\n {\n return Array.from(this as Iterable<T>);\n }\n\n public get [Symbol.toStringTag]() { return \"SmartIterator\"; }\n\n public [Symbol.iterator](): SmartIterator<T, R, N> { return this; }\n}\n","import SmartIterator from \"../smart-iterator.js\";\n\nimport type { KeyIteratee, KeyTypeGuardIteratee } from \"./types.js\";\nimport type { GeneratorFunction } from \"../../types.js\";\n\nexport default class ReducedIterator<K extends PropertyKey, T>\n{\n protected _elements: SmartIterator<[K, T]>;\n\n public constructor(iterable: Iterable<[K, T]>);\n public constructor(iterator: Iterator<[K, T]>);\n public constructor(generatorFn: GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public filter(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, T>;\n public filter<S extends T>(predicate: KeyTypeGuardIteratee<K, T, S>): ReducedIterator<K, S>;\n public filter(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, T>\n {\n const elements = this._elements;\n\n return new ReducedIterator(function* ()\n {\n for (const [index, [key, element]] of elements.enumerate())\n {\n if (predicate(key, element, index))\n {\n yield [key, element];\n }\n }\n });\n }\n public map<V>(iteratee: KeyIteratee<K, T, V>): ReducedIterator<K, V>\n {\n const elements = this._elements;\n\n return new ReducedIterator(function* ()\n {\n for (const [index, [key, element]] of elements.enumerate())\n {\n yield [key, iteratee(key, element, index)];\n }\n });\n }\n\n public keys(): SmartIterator<K>\n {\n const elements = this._elements;\n\n return new SmartIterator<K>(function* ()\n {\n for (const [key] of elements)\n {\n yield key;\n }\n });\n }\n public items(): SmartIterator<[K, T]>\n {\n return this._elements;\n }\n public values(): SmartIterator<T>\n {\n const elements = this._elements;\n\n return new SmartIterator<T>(function* ()\n {\n for (const [_, element] of elements)\n {\n yield element;\n }\n });\n }\n\n public toArray(): T[]\n {\n return Array.from(this.values());\n }\n public toMap(): Map<K, T>\n {\n return new Map(this.items());\n }\n public toObject(): Record<K, T>\n {\n return Object.fromEntries(this.items()) as Record<K, T>;\n }\n\n public get [Symbol.toStringTag]() { return \"ReducedIterator\"; }\n}\n","import ReducedIterator from \"./reduced-iterator.js\";\nimport SmartIterator from \"../smart-iterator.js\";\n\nimport type { KeyIteratee, KeyTypeGuardIteratee, KeyReducer } from \"./types.js\";\nimport type { GeneratorFunction } from \"../../types.js\";\n\nexport default class AggregatedIterator<K extends PropertyKey, T>\n{\n protected _elements: SmartIterator<[K, T]>;\n\n public constructor(iterable: Iterable<[K, T]>);\n public constructor(iterator: Iterator<[K, T]>);\n public constructor(generatorFn: GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public every(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, boolean>\n {\n const indexes = new Map<K, [number, boolean]>();\n\n for (const [key, element] of this._elements)\n {\n const [index, result] = indexes.get(key) ?? [0, true];\n\n if (!(result)) { continue; }\n\n indexes.set(key, [index + 1, predicate(key, element, index)]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, result]] of indexes)\n {\n yield [key, result];\n }\n });\n }\n public some(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, boolean>\n {\n const indexes = new Map<K, [number, boolean]>();\n\n for (const [key, element] of this._elements)\n {\n const [index, result] = indexes.get(key) ?? [0, false];\n\n if (result) { continue; }\n\n indexes.set(key, [index + 1, predicate(key, element, index)]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, result]] of indexes)\n {\n yield [key, result];\n }\n });\n }\n\n public filter(predicate: KeyIteratee<K, T, boolean>): AggregatedIterator<K, T>;\n public filter<S extends T>(predicate: KeyTypeGuardIteratee<K, T, S>): AggregatedIterator<K, S>;\n public filter(predicate: KeyIteratee<K, T, boolean>): AggregatedIterator<K, T>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const indexes = new Map<K, number>();\n\n for (const [key, element] of elements)\n {\n const index = indexes.get(key) ?? 0;\n\n indexes.set(key, index + 1);\n\n if (predicate(key, element, index)) { yield [key, element]; }\n }\n });\n }\n public map<V>(iteratee: KeyIteratee<K, T, V>): AggregatedIterator<K, V>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const indexes = new Map<K, number>();\n\n for (const [key, element] of elements)\n {\n const index = indexes.get(key) ?? 0;\n\n indexes.set(key, index + 1);\n\n yield [key, iteratee(key, element, index)];\n }\n });\n }\n public reduce(reducer: KeyReducer<K, T, T>): ReducedIterator<K, T>;\n public reduce<A>(reducer: KeyReducer<K, T, A>, initialValue: (key: K) => A): ReducedIterator<K, A>;\n public reduce<A>(reducer: KeyReducer<K, T, A>, initialValue?: (key: K) => A): ReducedIterator<K, A>\n {\n const accumulators = new Map<K, [number, A]>();\n\n for (const [key, element] of this._elements)\n {\n let index: number;\n let accumulator: A;\n\n if (accumulators.has(key))\n {\n [index, accumulator] = accumulators.get(key)!;\n\n index += 1;\n }\n else if (initialValue !== undefined)\n {\n index = 0;\n accumulator = initialValue(key);\n }\n else\n {\n accumulators.set(key, [0, (element as unknown) as A]);\n\n continue;\n }\n\n accumulator = reducer(key, accumulator, element, index);\n\n accumulators.set(key, [index, accumulator]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, accumulator]] of accumulators)\n {\n yield [key, accumulator];\n }\n });\n }\n\n public unique(): AggregatedIterator<K, T>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const keys = new Map<K, Set<T>>();\n\n for (const [key, element] of elements)\n {\n const values = keys.get(key) ?? new Set<T>();\n\n if (values.has(element)) { continue; }\n\n values.add(element);\n keys.set(key, values);\n\n yield [key, element];\n }\n });\n }\n\n public count(): ReducedIterator<K, number>\n {\n const counters = new Map<K, number>();\n\n for (const [key] of this._elements)\n {\n const count = counters.get(key) ?? 0;\n\n counters.set(key, count + 1);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, count] of counters)\n {\n yield [key, count];\n }\n });\n }\n public first(): ReducedIterator<K, T>\n {\n const firsts = new Map<K, T>();\n\n for (const [key, element] of this._elements)\n {\n if (firsts.has(key)) { continue; }\n\n firsts.set(key, element);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, element] of firsts)\n {\n yield [key, element];\n }\n });\n }\n public last(): ReducedIterator<K, T>\n {\n const lasts = new Map<K, T>();\n\n for (const [key, element] of this._elements)\n {\n lasts.set(key, element);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, element] of lasts)\n {\n yield [key, element];\n }\n });\n }\n\n public keys(): SmartIterator<K>\n {\n const elements = this._elements;\n\n return new SmartIterator<K>(function* ()\n {\n for (const [key] of elements)\n {\n yield key;\n }\n });\n }\n public items(): SmartIterator<[K, T]>\n {\n return this._elements;\n }\n public values(): SmartIterator<T>\n {\n const elements = this._elements;\n\n return new SmartIterator<T>(function* ()\n {\n for (const [_, element] of elements)\n {\n yield element;\n }\n });\n }\n\n public toArray(): T[][]\n {\n return Array.from(this.toMap().values());\n }\n public toMap(): Map<K, T[]>\n {\n const groups = new Map<K, T[]>();\n\n for (const [key, element] of this._elements)\n {\n const value = groups.get(key) ?? [];\n\n value.push(element);\n groups.set(key, value);\n }\n\n return groups;\n }\n public toObject(): Record<K, T[]>\n {\n const groups = { } as Record<K, T[]>;\n\n for (const [key, element] of this._elements)\n {\n const value = groups[key] ?? [];\n\n value.push(element);\n groups[key] = value;\n }\n\n return groups;\n }\n\n public get [Symbol.toStringTag]() { return \"AggregatedIterator\"; }\n}\n","import AggregatedIterator from \"./aggregated-iterator.js\";\nimport ReducedIterator from \"./reduced-iterator.js\";\nimport SmartIterator from \"../smart-iterator.js\";\n\nimport type { GeneratorFunction, Iteratee, TypeGuardIteratee } from \"../../types.js\";\n\nexport default class Aggregator<T>\n{\n protected _elements: SmartIterator<T>;\n\n public constructor(iterable: Iterable<T>);\n public constructor(iterator: Iterator<T>);\n public constructor(generatorFn: GeneratorFunction<T>);\n public constructor(argument: Iterable<T> | Iterator<T> | GeneratorFunction<T>);\n public constructor(argument: Iterable<T> | Iterator<T> | GeneratorFunction<T>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public filter(predicate: Iteratee<T, boolean>): Aggregator<T>;\n public filter<S extends T>(predicate: TypeGuardIteratee<T, S>): Aggregator<S>;\n public filter(predicate: Iteratee<T, boolean>): Aggregator<T>\n {\n return new Aggregator(this._elements.filter(predicate));\n }\n public map<V>(iteratee: Iteratee<T, V>): Aggregator<V>\n {\n return new Aggregator(this._elements.map(iteratee));\n }\n\n public unique(): Aggregator<T>\n {\n return new Aggregator(this._elements.unique());\n }\n\n public groupBy<K extends PropertyKey>(iteratee: Iteratee<T, K>): AggregatedIterator<K, T>\n {\n return new AggregatedIterator(this._elements.map((element, index) =>\n {\n const key = iteratee(element, index);\n\n return [key, element];\n }));\n }\n\n public get [Symbol.toStringTag]() { return \"Aggregator\"; }\n}\n\nexport { AggregatedIterator, ReducedIterator };\nexport type { KeyIteratee, KeyReducer, KeyTypeGuardIteratee } from \"./types.js\";\n","/* eslint-disable no-trailing-spaces */\n\n/**\n * A wrapper around the `Storage` API to store and retrieve JSON values.\n *\n * It allows to handle either the `sessionStorage` or the `localStorage`\n * storage at the same time, depending on the required use case.\n */\nexport default class JsonStorage\n{\n protected _preferPersistence: boolean;\n\n protected _volatile: Storage;\n protected _persistent: Storage;\n\n public constructor(preferPersistence = true)\n {\n this._preferPersistence = preferPersistence;\n\n this._volatile = window.sessionStorage;\n this._persistent = window.localStorage;\n }\n\n protected _get<T>(storage: Storage, propertyName: string): T | undefined;\n protected _get<T>(storage: Storage, propertyName: string, defaultValue: T): T;\n protected _get<T>(storage: Storage, propertyName: string, defaultValue?: T): T | undefined;\n protected _get<T>(storage: Storage, propertyName: string, defaultValue?: T): T | undefined\n {\n const propertyValue = storage.getItem(propertyName);\n if (propertyValue)\n {\n try\n {\n return JSON.parse(propertyValue);\n }\n catch (error)\n {\n // eslint-disable-next-line no-console\n console.warn(\n `The \"${propertyValue}\" value for \"${propertyName}\"` +\n \" property cannot be parsed. Clearing the storage...\");\n\n storage.removeItem(propertyName);\n }\n }\n\n return defaultValue;\n }\n protected _set<T>(storage: Storage, propertyName: string, newValue?: T): void\n {\n const encodedValue = JSON.stringify(newValue);\n if (encodedValue)\n {\n storage.setItem(propertyName, encodedValue);\n }\n else\n {\n storage.removeItem(propertyName);\n }\n }\n\n /**\n * Retrieves the value with the specified name from the corresponding storage.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n * @param persistent Whether to use the persistent `localStorage` or the volatile `sessionStorage`.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public get<T>(propertyName: string, defaultValue: undefined, persistent?: boolean): T | undefined;\n public get<T>(propertyName: string, defaultValue: T, persistent?: boolean): T ;\n public get<T>(propertyName: string, defaultValue?: T, persistent?: boolean): T | undefined;\n public get<T>(propertyName: string, defaultValue?: T, persistent = this._preferPersistence): T | undefined\n {\n const storage = persistent ? this._persistent : this._volatile;\n\n return this._get<T>(storage, propertyName, defaultValue);\n }\n /**\n * Retrieves the value with the specified name from the volatile `sessionStorage`.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public recall<T>(propertyName: string): T | undefined;\n public recall<T>(propertyName: string, defaultValue: T): T;\n public recall<T>(propertyName: string, defaultValue?: T): T | undefined;\n public recall<T>(propertyName: string, defaultValue?: T): T | undefined\n {\n return this._get<T>(this._volatile, propertyName, defaultValue);\n }\n /**\n * Retrieves the value with the specified name looking first in the\n * volatile `sessionStorage` and then in the persistent `localStorage`.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public retrieve<T>(propertyName: string): T | undefined;\n public retrieve<T>(propertyName: string, defaultValue: T): T;\n public retrieve<T>(propertyName: string, defaultValue?: T): T | undefined;\n public retrieve<T>(propertyName: string, defaultValue?: T): T | undefined\n {\n return this.recall<T>(propertyName) ?? this.read<T>(propertyName, defaultValue);\n }\n /**\n * Retrieves the value with the specified name from the persistent `localStorage`.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public read<T>(propertyName: string): T | undefined;\n public read<T>(propertyName: string, defaultValue: T): T;\n public read<T>(propertyName: string, defaultValue?: T): T | undefined;\n public read<T>(propertyName: string, defaultValue?: T): T | undefined\n {\n return this._get<T>(this._persistent, propertyName, defaultValue);\n }\n\n /**\n * Checks whether the property with the specified name exists in the corresponding storage.\n *\n * @param propertyName The name of the property to check.\n * @param persistent Whether to use the persistent `localStorage` or the volatile `sessionStorage`.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public has(propertyName: string, persistent?: boolean): boolean\n {\n const storage = persistent ? this._persistent : this._volatile;\n\n return storage.getItem(propertyName) !== null;\n }\n /**\n * Checks whether the property with the specified name exists in the volatile `sessionStorage`.\n *\n * @param propertyName The name of the property to check.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public knows(propertyName: string): boolean\n {\n return this._volatile.getItem(propertyName) !== null;\n }\n /**\n * Checks whether the property with the specified name exists looking first in the\n * volatile `sessionStorage` and then in the persistent `localStorage`.\n *\n * @param propertyName The name of the property to check.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public find(propertyName: string): boolean\n {\n return this.knows(propertyName) ?? this.exists(propertyName);\n }\n /**\n * Checks whether the property with the specified name exists in the persistent `localStorage`.\n *\n * @param propertyName The name of the property to check.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public exists(propertyName: string): boolean\n {\n return this._persistent.getItem(propertyName) !== null;\n }\n\n /**\n * Sets the value with the specified name in the corresponding storage.\n * If the value is `undefined`, the property is removed from the storage.\n *\n * @param propertyName The name of the property to set.\n * @param newValue The new value to set.\n * @param persistent Whether to use the persistent `localStorage` or the volatile `sessionStorage`.\n */\n public set<T>(propertyName: string, newValue?: T, persistent = this._preferPersistence): void\n {\n const storage = persistent ? this._persistent : this._volatile;\n\n this._set<T>(storage, propertyName, newValue);\n }\n /**\n * Sets the value with the specified name in the volatile `sessionStorage`.\n * If the value is `undefined`, the property is removed from the storage.\n *\n * @param propertyName The name of the property to set.\n * @param newValue The new value to set.\n */\n public remember<T>(propertyName: string, newValue?: T): void\n {\n this._set<T>(this._volatile, propertyName, newValue);\n }\n /**\n * Sets the value with the specified name in the persistent `localStorage`.\n * If the value is `undefined`, the property is removed from the storage.\n *\n * @param propertyName The name of the property to set.\n * @param newValue The new value to set.\n */\n public write<T>(propertyName: string, newValue?: T): void\n {\n this._set<T>(this._persistent, propertyName, newValue);\n }\n\n /**\n * Removes the value with the specified name from the volatile `sessionStorage`.\n *\n * @param propertyName The name of the property to remove.\n */\n public forget(propertyName: string): void\n {\n this._volatile.removeItem(propertyName);\n }\n /**\n * Removes the value with the specified name from the persistent `localStorage`.\n *\n * @param propertyName The name of the property to remove.\n */\n public erase(propertyName: string): void\n {\n this._persistent.removeItem(propertyName);\n }\n /**\n * Removes the value with the specified name from all the storages.\n *\n * @param propertyName The name of the property to remove.\n */\n public clear(propertyName: string): void\n {\n this._volatile.removeItem(propertyName);\n this._persistent.removeItem(propertyName);\n }\n\n public get [Symbol.toStringTag]() { return \"JsonStorage\"; }\n}\n","import Exception from \"./exception.js\";\n\nexport default class Subscribers<P extends unknown[] = [], R = void, T extends (...args: P) => R = (...args: P) => R>\n{\n protected _subscribers: T[];\n\n public constructor()\n {\n this._subscribers = [];\n }\n\n public add(subscriber: T): void\n {\n this._subscribers.push(subscriber);\n }\n public remove(subscriber: T): void\n {\n const index = this._subscribers.indexOf(subscriber);\n if (index < 0)\n {\n throw new Exception(\"Unable to remove the requested subscriber. It was not found.\");\n }\n\n this._subscribers.splice(index, 1);\n }\n\n public call(...args: P): R[]\n {\n return this._subscribers\n .slice()\n .map((subscriber) => subscriber(...args));\n }\n\n public get [Symbol.toStringTag]() { return \"Subscribers\"; }\n}\n","import type {\n PromiseResolver,\n PromiseRejecter,\n FulfilledHandler,\n RejectedHandler,\n PromiseExecutor\n\n} from \"../../types.js\";\n\nexport default class DeferredPromise<T = void, E = unknown, F = T, R = never>\n{\n protected _isPending: boolean;\n protected _isFulfilled: boolean;\n protected _isRejected: boolean;\n\n protected _resolve!: PromiseResolver<T>;\n protected _reject!: PromiseRejecter<E>;\n\n protected _promise: Promise<F | R>;\n\n public constructor(onFulfilled?: FulfilledHandler<T, F> | null, onRejected?: RejectedHandler<E, R> | null)\n {\n this._isPending = true;\n this._isFulfilled = false;\n this._isRejected = false;\n\n let _resolve: PromiseResolver<T>;\n let _reject: PromiseRejecter<E>;\n\n const executor: PromiseExecutor<T, E> = (resolve, reject) =>\n {\n _resolve = resolve;\n _reject = reject;\n };\n\n let _onFulfilled: FulfilledHandler<T, F>;\n if (onFulfilled)\n {\n _onFulfilled = (value) =>\n {\n this._isPending = false;\n this._isFulfilled = true;\n\n return onFulfilled!(value);\n };\n }\n else\n {\n _onFulfilled = (value) =>\n {\n this._isPending = false;\n this._isFulfilled = true;\n\n return (value as unknown) as F;\n };\n }\n\n let _onRejected: RejectedHandler<E, R>;\n if (onRejected)\n {\n _onRejected = (reason) =>\n {\n this._isPending = false;\n this._isRejected = true;\n\n return onRejected!(reason);\n };\n }\n else\n {\n _onRejected = (reason) =>\n {\n this._isPending = false;\n this._isRejected = true;\n\n return (reason as unknown) as R;\n };\n }\n\n this._promise = new Promise<T>(executor)\n .then(_onFulfilled, _onRejected);\n\n this._resolve = _resolve!;\n this._reject = _reject!;\n }\n\n public get isPending(): boolean { return this._isPending; }\n public get isFulfilled(): boolean { return this._isFulfilled; }\n public get isRejected(): boolean { return this._isRejected; }\n\n public get resolve(): PromiseResolver<T> { return this._resolve; }\n public get reject(): PromiseRejecter<E> { return this._reject; }\n\n public then<N = F | R, H = R>(\n onFulfilled?: FulfilledHandler<F | R, N> | null,\n onRejected?: RejectedHandler<R, H> | null): Promise<N | H>\n {\n return this._promise.then(onFulfilled, onRejected);\n }\n public catch<H = R>(onRejected?: RejectedHandler<R, H> | null): Promise<F | R | H>\n {\n return this._promise.catch(onRejected);\n }\n public finally(onFinally?: (() => void) | null): Promise<F | R>\n {\n return this._promise.finally(onFinally);\n }\n\n public watch(promise: Promise<T>): this\n {\n promise.then(this.resolve, this.reject);\n\n return this;\n }\n\n public get [Symbol.toStringTag]() { return \"DeferredPromise\"; }\n}\n","import type { FulfilledHandler, PromiseExecutor, RejectedHandler } from \"../../types.js\";\n\nexport default class SmartPromise<T = void, E = unknown>\n{\n protected _isPending: boolean;\n protected _isFulfilled: boolean;\n protected _isRejected: boolean;\n\n protected _promise: Promise<T | E>;\n\n public constructor(executor: PromiseExecutor<T, E>)\n {\n this._isPending = true;\n this._isFulfilled = false;\n this._isRejected = false;\n\n const _resolve = (result: T): T =>\n {\n this._isPending = false;\n this._isFulfilled = true;\n\n return result;\n };\n const _reject = (reason: E): E =>\n {\n this._isPending = false;\n this._isRejected = true;\n\n return reason;\n };\n\n this._promise = new Promise<T>(executor)\n .then(_resolve, _reject);\n }\n\n public get isPending(): boolean { return this._isPending; }\n public get isFulfilled(): boolean { return this._isFulfilled; }\n public get isRejected(): boolean { return this._isRejected; }\n\n public then<F = T, R = E>(\n onFulfilled?: FulfilledHandler<T | E, F> | null,\n onRejected?: RejectedHandler<E, R> | null): Promise<F | R>\n {\n return this._promise.then(onFulfilled, onRejected);\n }\n public catch<R = E>(onRejected?: RejectedHandler<E, R> | null): Promise<T | E | R>\n {\n return this._promise.catch(onRejected);\n }\n public finally(onFinally?: (() => void) | null): Promise<T | E>\n {\n return this._promise.finally(onFinally);\n }\n\n public get [Symbol.toStringTag]() { return \"SmartPromise\"; }\n}\n","export default class Random\n{\n public static Boolean(ratio: number = 0.5): boolean\n {\n return (Math.random() < ratio);\n }\n\n public static Integer(max: number): number;\n public static Integer(min: number, max: number): number;\n public static Integer(min: number, max?: number): number\n {\n if (max === undefined)\n {\n return Math.floor(Math.random() * min);\n }\n\n return Math.floor(Math.random() * (max - min) + min);\n }\n\n public static Decimal(max: number): number;\n public static Decimal(min: number, max: number): number;\n public static Decimal(min: number, max?: number): number\n {\n if (max === undefined)\n {\n return (Math.random() * min);\n }\n\n return (Math.random() * (max - min) + min);\n }\n\n public static Choice<T>(elements: T[]): T\n {\n return elements[this.Integer(elements.length)];\n }\n\n // eslint-disable-next-line no-useless-constructor\n private constructor() { }\n}\n","export async function delay(milliseconds: number): Promise<void>\n{\n return new Promise<void>((resolve, reject) => setTimeout(resolve, milliseconds));\n}\n\nexport async function nextAnimationFrame(): Promise<void>\n{\n return new Promise<void>((resolve, reject) => requestAnimationFrame(() => resolve()));\n}\n","import { SmartIterator } from \"../models/index.js\";\n\nexport enum DateUnit\n{\n Second = 1000,\n Minute = 60 * Second,\n Hour = 60 * Minute,\n Day = 24 * Hour,\n Week = 7 * Day,\n Month = 30 * Day,\n Year = 365 * Day\n}\n\nexport function dateDifference(start: Date, end: Date, unit = DateUnit.Day): number\n{\n return Math.floor((end.getTime() - start.getTime()) / unit);\n}\n\nexport function dateRange(start: Date, end: Date, offset = DateUnit.Day): SmartIterator<Date>\n{\n return new SmartIterator<Date>(function* ()\n {\n const endTime = end.getTime();\n\n let unixTime: number = start.getTime();\n while (unixTime < endTime)\n {\n yield new Date(unixTime);\n\n unixTime += offset;\n }\n });\n}\n\nexport function dateRound(date: Date, unit = DateUnit.Day): Date\n{\n return new Date(Math.floor(date.getTime() / unit) * unit);\n}\n","export async function loadScript(scriptUrl: string, scriptType = \"text/javascript\"): Promise<void>\n{\n return new Promise<void>((resolve, reject) =>\n {\n const script = document.createElement(\"script\");\n\n script.async = true;\n script.defer = true;\n script.src = scriptUrl;\n script.type = scriptType;\n\n script.onload = () => resolve();\n script.onerror = () => reject();\n\n document.body.appendChild(script);\n });\n}\n","import { SmartIterator } from \"../models/index.js\";\n\nexport function count<T>(elements: Iterable<T>): number\n{\n if (Array.isArray(elements)) { return elements.length; }\n\n let _count = 0;\n for (const _ of elements) { _count += 1; }\n\n return _count;\n}\n\nexport function enumerate<T>(elements: Iterable<T>): SmartIterator<[number, T]>\n{\n return new SmartIterator<[number, T]>(function* ()\n {\n let index = 0;\n\n for (const element of elements)\n {\n yield [index, element];\n\n index += 1;\n }\n });\n}\n\nexport function range(end: number): SmartIterator<number>;\nexport function range(start: number, end: number): SmartIterator<number>;\nexport function range(start: number, end: number, step: number): SmartIterator<number>;\nexport function range(start: number, end?: number, step = 1): SmartIterator<number>\n{\n return new SmartIterator<number>(function* ()\n {\n if (end === undefined)\n {\n end = start;\n start = 0;\n }\n\n if (start > end) { step = step ?? -1; }\n\n for (let index = start; index < end; index += step) { yield index; }\n });\n}\n\nexport function shuffle<T>(iterable: Iterable<T>): T[]\n{\n const array = Array.from(iterable);\n\n for (let index = array.length - 1; index > 0; index -= 1)\n {\n const jndex = Math.floor(Math.random() * (index + 1));\n\n [array[index], array[jndex]] = [array[jndex], array[index]];\n }\n\n return array;\n}\n\nexport function unique<T>(elements: Iterable<T>): SmartIterator<T>\n{\n return new SmartIterator<T>(function* ()\n {\n const values = new Set<T>();\n\n for (const element of elements)\n {\n if (values.has(element)) { continue; }\n\n values.add(element);\n\n yield element;\n }\n });\n}\n\nexport function zip<T, U>(first: Iterable<T>, second: Iterable<U>): SmartIterator<[T, U]>\n{\n return new SmartIterator<[T, U]>(function* ()\n {\n const firstIterator = first[Symbol.iterator]();\n const secondIterator = second[Symbol.iterator]();\n\n while (true)\n {\n const firstResult = firstIterator.next();\n const secondResult = secondIterator.next();\n\n if ((firstResult.done) || (secondResult.done)) { break; }\n\n yield [firstResult.value, secondResult.value];\n }\n });\n}\n","import { zip } from \"./iterator.js\";\n\nexport function average<T extends number>(values: Iterable<T>): number;\nexport function average<T extends number>(values: Iterable<T>, weights: Iterable<number>): number;\nexport function average<T extends number>(values: Iterable<T>, weights?: Iterable<number>): number\n{\n if (weights === undefined)\n {\n let _sum = 0;\n let _count = 0;\n\n for (const value of values)\n {\n _sum += value;\n _count += 1;\n }\n\n return _sum / _count;\n }\n\n let _sum = 0;\n let _count = 0;\n\n for (const [value, weight] of zip(values, weights))\n {\n _sum += value * weight;\n _count += weight;\n }\n\n return _sum / _count;\n}\n\nexport function hash(value: string): number\n{\n let hashedValue = 0;\n for (let index = 0; index < value.length; index += 1)\n {\n const char = value.charCodeAt(index);\n\n hashedValue = ((hashedValue << 5) - hashedValue) + char;\n hashedValue |= 0;\n }\n\n return hashedValue;\n}\n\nexport function sum<T extends number>(values: Iterable<T>): number\n{\n let _sum = 0;\n for (const value of values) { _sum += value; }\n\n return _sum;\n}\n","export function capitalize(value: string): string\n{\n return `${value.charAt(0).toUpperCase()}${value.slice(1)}`;\n}\n","export const VERSION = \"1.4.1\";\n\nexport {\n AggregatedIterator,\n Aggregator,\n DeferredPromise,\n Exception,\n JsonStorage,\n ReducedIterator,\n SmartIterator,\n SmartPromise,\n Subscribers\n\n} from \"./models/index.js\";\nexport type { KeyIteratee, KeyReducer, KeyTypeGuardIteratee } from \"./models/index.js\";\n\nexport {\n average,\n capitalize,\n count,\n delay,\n dateDifference,\n dateRange,\n dateRound,\n DateUnit,\n hash,\n loadScript,\n nextAnimationFrame,\n Random,\n range,\n shuffle,\n sum,\n unique,\n zip\n\n} from \"./utils/index.js\";\n\nexport type {\n AsyncGeneratorFunction,\n Constructor,\n FulfilledHandler,\n GeneratorFunction,\n Interval,\n Iteratee,\n MaybePromise,\n PromiseExecutor,\n PromiseRejecter,\n PromiseResolver,\n Reducer,\n RejectedHandler,\n Timeout,\n TypeGuardIteratee\n\n} from \"./types.js\";\n"],"names":["Exception","error","exc","message","cause","name","SmartIterator","argument","__publicField","value","predicate","index","result","iterator","iteratee","reducer","initialValue","accumulator","values","ReducedIterator","elements","key","element","_","AggregatedIterator","indexes","accumulators","keys","counters","count","firsts","lasts","groups","Aggregator","JsonStorage","preferPersistence","storage","propertyName","defaultValue","propertyValue","newValue","encodedValue","persistent","Subscribers","subscriber","args","DeferredPromise","onFulfilled","onRejected","_resolve","_reject","executor","resolve","reject","_onFulfilled","_onRejected","reason","onFinally","promise","SmartPromise","Random","ratio","min","max","delay","milliseconds","nextAnimationFrame","DateUnit","dateDifference","start","end","unit","dateRange","offset","endTime","unixTime","dateRound","date","loadScript","scriptUrl","scriptType","script","_count","range","step","shuffle","iterable","array","jndex","unique","zip","first","second","firstIterator","secondIterator","firstResult","secondResult","average","weights","_sum","weight","hash","hashedValue","char","sum","capitalize","VERSION"],"mappings":";;;AAAA,MAAqBA,UAAkB,MACvC;AAAA,EACI,OAAc,YAAYC,GAC1B;AACI,QAAIA,aAAiBD;AAEV,aAAAC;AAEX,QAAIA,aAAiB,OACrB;AACI,YAAMC,IAAM,IAAIF,EAAUC,EAAM,OAAO;AAEvC,aAAAC,EAAI,QAAQD,EAAM,OAClBC,EAAI,OAAOD,EAAM,MAEVC;AAAA,IACX;AAEA,WAAO,IAAIF,EAAU,GAAGC,CAAK,EAAE;AAAA,EACnC;AAAA,EAEO,YAAYE,GAAiBC,GAAiBC,IAAO,aAC5D;AACI,UAAMF,CAAO,GAEb,KAAK,QAAQC,GACb,KAAK,OAAOC,GAERD,MAEIA,aAAiB,QAEjB,KAAK,SAAS;AAAA;AAAA,YAAiBA,EAAM,KAAK,KAI1C,KAAK,SAAS;AAAA;AAAA,YAAiBA,CAAK;AAAA,EAGhD;AAAA,EAEA,KAAY,OAAO,WAAW,IAAI;AAAS,WAAA;AAAA,EAAa;AAC5D;ACxCA,MAAqBE,EACrB;AAAA,EAUW,YAAYC,GACnB;AAVU,IAAAC,EAAA;AAEH,IAAAA,EAAA;AACA,IAAAA,EAAA;AAQH,IAAID,aAAoB,WAEpB,KAAK,YAAYA,MAEZ,OAAO,YAAYA,IAExB,KAAK,YAAYA,EAAS,OAAO,QAAQ,EAAE,IAI3C,KAAK,YAAYA,GAGjB,KAAK,UAAU,WAAU,KAAK,SAAS,CAACE,MAAc,KAAK,UAAU,OAAQA,CAAK,IAClF,KAAK,UAAU,UAAS,KAAK,QAAQ,CAACR,MAAoB,KAAK,UAAU,MAAOA,CAAK;AAAA,EAC7F;AAAA,EAEO,MAAMS,GACb;AACI,QAAIC,IAAQ;AAGZ,eACA;AACU,YAAAC,IAAS,KAAK,UAAU,KAAK;AAEnC,UAAIA,EAAO;AAAe,eAAA;AAC1B,UAAI,CAAEF,EAA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