@byloth/core 1.2.1-rc.1 → 1.3.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.js +70 -69
- 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 +1 -1
- package/src/index.ts +2 -2
- package/src/utils/index.ts +5 -1
- package/src/utils/math.ts +3 -51
- package/src/utils/random.ts +39 -0
package/dist/core.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
var d = Object.defineProperty;
|
|
2
2
|
var _ = (s, e, t) => e in s ? d(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
3
|
var u = (s, e, t) => (_(s, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
-
class
|
|
4
|
+
class h extends Error {
|
|
5
5
|
static FromUnknown(e) {
|
|
6
|
-
if (e instanceof
|
|
6
|
+
if (e instanceof h)
|
|
7
7
|
return e;
|
|
8
8
|
if (e instanceof Error) {
|
|
9
|
-
const t = new
|
|
9
|
+
const t = new h(e.message);
|
|
10
10
|
return t.stack = e.stack, t.name = e.name, t;
|
|
11
11
|
}
|
|
12
|
-
return new
|
|
12
|
+
return new h(`${e}`);
|
|
13
13
|
}
|
|
14
14
|
constructor(e, t, r = "Exception") {
|
|
15
15
|
super(e), this.cause = t, this.name = r, t && (t instanceof Error ? this.stack += `
|
|
@@ -19,7 +19,7 @@ Caused by ${t.stack}` : this.stack += `
|
|
|
19
19
|
Caused by ${t}`);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
class
|
|
22
|
+
class c {
|
|
23
23
|
constructor(e) {
|
|
24
24
|
u(this, "_iterator");
|
|
25
25
|
u(this, "return");
|
|
@@ -50,7 +50,7 @@ class l {
|
|
|
50
50
|
}
|
|
51
51
|
filter(e) {
|
|
52
52
|
const t = this._iterator;
|
|
53
|
-
return new
|
|
53
|
+
return new c(function* () {
|
|
54
54
|
let r = 0;
|
|
55
55
|
for (; ; ) {
|
|
56
56
|
const n = t.next();
|
|
@@ -62,7 +62,7 @@ class l {
|
|
|
62
62
|
}
|
|
63
63
|
map(e) {
|
|
64
64
|
const t = this._iterator;
|
|
65
|
-
return new
|
|
65
|
+
return new c(function* () {
|
|
66
66
|
let r = 0;
|
|
67
67
|
for (; ; ) {
|
|
68
68
|
const n = t.next();
|
|
@@ -92,7 +92,7 @@ class l {
|
|
|
92
92
|
}
|
|
93
93
|
unique() {
|
|
94
94
|
const e = this._iterator;
|
|
95
|
-
return new
|
|
95
|
+
return new c(function* () {
|
|
96
96
|
const t = /* @__PURE__ */ new Set();
|
|
97
97
|
for (; ; ) {
|
|
98
98
|
const r = e.next();
|
|
@@ -129,21 +129,21 @@ class l {
|
|
|
129
129
|
return this;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
class
|
|
132
|
+
class l {
|
|
133
133
|
constructor(e) {
|
|
134
134
|
u(this, "_elements");
|
|
135
|
-
this._elements = new
|
|
135
|
+
this._elements = new c(e);
|
|
136
136
|
}
|
|
137
137
|
filter(e) {
|
|
138
138
|
const t = this._elements;
|
|
139
|
-
return new
|
|
139
|
+
return new l(function* () {
|
|
140
140
|
for (const [r, [n, o]] of t.enumerate())
|
|
141
141
|
e(n, o, r) && (yield [n, o]);
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
map(e) {
|
|
145
145
|
const t = this._elements;
|
|
146
|
-
return new
|
|
146
|
+
return new l(function* () {
|
|
147
147
|
for (const [r, [n, o]] of t.enumerate())
|
|
148
148
|
yield [n, e(n, o, r)];
|
|
149
149
|
});
|
|
@@ -158,10 +158,10 @@ class c {
|
|
|
158
158
|
return Object.fromEntries(this._elements.toArray());
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
-
class
|
|
161
|
+
class f {
|
|
162
162
|
constructor(e) {
|
|
163
163
|
u(this, "_elements");
|
|
164
|
-
this._elements = new
|
|
164
|
+
this._elements = new c(e);
|
|
165
165
|
}
|
|
166
166
|
every(e) {
|
|
167
167
|
const t = /* @__PURE__ */ new Map();
|
|
@@ -169,7 +169,7 @@ class h {
|
|
|
169
169
|
const [o, i] = t.get(r) ?? [0, !0];
|
|
170
170
|
i && t.set(r, [o + 1, e(r, n, o)]);
|
|
171
171
|
}
|
|
172
|
-
return new
|
|
172
|
+
return new l(function* () {
|
|
173
173
|
for (const [r, [n, o]] of t)
|
|
174
174
|
yield [r, o];
|
|
175
175
|
});
|
|
@@ -180,14 +180,14 @@ class h {
|
|
|
180
180
|
const [o, i] = t.get(r) ?? [0, !1];
|
|
181
181
|
i || t.set(r, [o + 1, e(r, n, o)]);
|
|
182
182
|
}
|
|
183
|
-
return new
|
|
183
|
+
return new l(function* () {
|
|
184
184
|
for (const [r, [n, o]] of t)
|
|
185
185
|
yield [r, o];
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
188
|
filter(e) {
|
|
189
189
|
const t = this._elements;
|
|
190
|
-
return new
|
|
190
|
+
return new f(function* () {
|
|
191
191
|
const r = /* @__PURE__ */ new Map();
|
|
192
192
|
for (const [n, o] of t) {
|
|
193
193
|
const i = r.get(n) ?? 0;
|
|
@@ -197,7 +197,7 @@ class h {
|
|
|
197
197
|
}
|
|
198
198
|
map(e) {
|
|
199
199
|
const t = this._elements;
|
|
200
|
-
return new
|
|
200
|
+
return new f(function* () {
|
|
201
201
|
const r = /* @__PURE__ */ new Map();
|
|
202
202
|
for (const [n, o] of t) {
|
|
203
203
|
const i = r.get(n) ?? 0;
|
|
@@ -219,14 +219,14 @@ class h {
|
|
|
219
219
|
}
|
|
220
220
|
a = e(n, a, o, i), r.set(n, [i, a]);
|
|
221
221
|
}
|
|
222
|
-
return new
|
|
222
|
+
return new l(function* () {
|
|
223
223
|
for (const [n, [o, i]] of r)
|
|
224
224
|
yield [n, i];
|
|
225
225
|
});
|
|
226
226
|
}
|
|
227
227
|
unique() {
|
|
228
228
|
const e = this._elements;
|
|
229
|
-
return new
|
|
229
|
+
return new f(function* () {
|
|
230
230
|
const t = /* @__PURE__ */ new Map();
|
|
231
231
|
for (const [r, n] of e) {
|
|
232
232
|
const o = t.get(r) ?? /* @__PURE__ */ new Set();
|
|
@@ -240,7 +240,7 @@ class h {
|
|
|
240
240
|
const r = e.get(t) ?? 0;
|
|
241
241
|
e.set(t, r + 1);
|
|
242
242
|
}
|
|
243
|
-
return new
|
|
243
|
+
return new l(function* () {
|
|
244
244
|
for (const [t, r] of e)
|
|
245
245
|
yield [t, r];
|
|
246
246
|
});
|
|
@@ -268,7 +268,7 @@ class h {
|
|
|
268
268
|
class m {
|
|
269
269
|
constructor(e) {
|
|
270
270
|
u(this, "_elements");
|
|
271
|
-
this._elements = new
|
|
271
|
+
this._elements = new c(e);
|
|
272
272
|
}
|
|
273
273
|
filter(e) {
|
|
274
274
|
return new m(this._elements.filter(e));
|
|
@@ -280,7 +280,7 @@ class m {
|
|
|
280
280
|
return new m(this._elements.unique());
|
|
281
281
|
}
|
|
282
282
|
byKey(e) {
|
|
283
|
-
return new
|
|
283
|
+
return new f(this._elements.map((t, r) => [e(t, r), t]));
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
286
|
class p {
|
|
@@ -461,32 +461,49 @@ class b {
|
|
|
461
461
|
remove(e) {
|
|
462
462
|
const t = this._subscribers.indexOf(e);
|
|
463
463
|
if (t < 0)
|
|
464
|
-
throw new
|
|
464
|
+
throw new h("Unable to remove the requested subscriber. It was not found.");
|
|
465
465
|
this._subscribers.splice(t, 1);
|
|
466
466
|
}
|
|
467
467
|
call(...e) {
|
|
468
468
|
return this._subscribers.slice().map((t) => t(...e));
|
|
469
469
|
}
|
|
470
470
|
}
|
|
471
|
-
|
|
471
|
+
class g {
|
|
472
|
+
static Boolean(e = 0.5) {
|
|
473
|
+
return Math.random() < e;
|
|
474
|
+
}
|
|
475
|
+
static Integer(e, t) {
|
|
476
|
+
return Math.floor(t === void 0 ? Math.random() * e : Math.random() * (t - e) + e);
|
|
477
|
+
}
|
|
478
|
+
static Decimal(e, t) {
|
|
479
|
+
return t === void 0 ? Math.random() * e : Math.random() * (t - e) + e;
|
|
480
|
+
}
|
|
481
|
+
static Choice(e) {
|
|
482
|
+
return e[this.Integer(e.length)];
|
|
483
|
+
}
|
|
484
|
+
// eslint-disable-next-line no-useless-constructor
|
|
485
|
+
constructor() {
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
async function k(s) {
|
|
472
489
|
return new Promise((e, t) => setTimeout(e, s));
|
|
473
490
|
}
|
|
474
|
-
async function
|
|
491
|
+
async function M() {
|
|
475
492
|
return new Promise((s, e) => requestAnimationFrame(() => s()));
|
|
476
493
|
}
|
|
477
494
|
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 || {});
|
|
478
|
-
function
|
|
495
|
+
function S(s, e, t = 864e5) {
|
|
479
496
|
return Math.floor((e.getTime() - s.getTime()) / t);
|
|
480
497
|
}
|
|
481
|
-
function
|
|
482
|
-
return new
|
|
498
|
+
function j(s, e, t = 864e5) {
|
|
499
|
+
return new c(function* () {
|
|
483
500
|
const r = e.getTime();
|
|
484
501
|
let n = s.getTime();
|
|
485
502
|
for (; n < r; )
|
|
486
503
|
yield new Date(n), n += t;
|
|
487
504
|
});
|
|
488
505
|
}
|
|
489
|
-
function
|
|
506
|
+
function I(s, e = 864e5) {
|
|
490
507
|
return new Date(Math.floor(s.getTime() / e) * e);
|
|
491
508
|
}
|
|
492
509
|
async function A(s, e = "text/javascript") {
|
|
@@ -503,14 +520,14 @@ function T(s) {
|
|
|
503
520
|
e += 1;
|
|
504
521
|
return e;
|
|
505
522
|
}
|
|
506
|
-
function
|
|
507
|
-
return new
|
|
523
|
+
function P(s, e, t = 1) {
|
|
524
|
+
return new c(function* () {
|
|
508
525
|
e === void 0 && (e = s, s = 0), s > e && (t = t ?? -1);
|
|
509
526
|
for (let r = s; r < e; r += t)
|
|
510
527
|
yield r;
|
|
511
528
|
});
|
|
512
529
|
}
|
|
513
|
-
function
|
|
530
|
+
function q(s) {
|
|
514
531
|
const e = Array.from(s);
|
|
515
532
|
for (let t = e.length - 1; t > 0; t -= 1) {
|
|
516
533
|
const r = Math.floor(Math.random() * (t + 1));
|
|
@@ -518,15 +535,15 @@ function P(s) {
|
|
|
518
535
|
}
|
|
519
536
|
return e;
|
|
520
537
|
}
|
|
521
|
-
function
|
|
522
|
-
return new
|
|
538
|
+
function C(s) {
|
|
539
|
+
return new c(function* () {
|
|
523
540
|
const e = /* @__PURE__ */ new Set();
|
|
524
541
|
for (const t of s)
|
|
525
542
|
e.has(t) || (e.add(t), yield t);
|
|
526
543
|
});
|
|
527
544
|
}
|
|
528
545
|
function y(s, e) {
|
|
529
|
-
return new
|
|
546
|
+
return new c(function* () {
|
|
530
547
|
const t = s[Symbol.iterator](), r = e[Symbol.iterator]();
|
|
531
548
|
for (; ; ) {
|
|
532
549
|
const n = t.next(), o = r.next();
|
|
@@ -550,29 +567,13 @@ function E(s, e) {
|
|
|
550
567
|
}
|
|
551
568
|
function O(s) {
|
|
552
569
|
let e = 0;
|
|
553
|
-
for (let t = 0; t < s.length; t
|
|
570
|
+
for (let t = 0; t < s.length; t += 1) {
|
|
554
571
|
const r = s.charCodeAt(t);
|
|
555
572
|
e = (e << 5) - e + r, e |= 0;
|
|
556
573
|
}
|
|
557
574
|
return e;
|
|
558
575
|
}
|
|
559
|
-
function $(s
|
|
560
|
-
if (e === void 0 && (e = s, s = 0), s === e)
|
|
561
|
-
return s;
|
|
562
|
-
let r;
|
|
563
|
-
if (t === !0)
|
|
564
|
-
r = (n) => n;
|
|
565
|
-
else if (t === void 0)
|
|
566
|
-
Math.abs(e - s) <= 1 ? r = (n) => n : r = Math.floor;
|
|
567
|
-
else if (t === !1)
|
|
568
|
-
r = Math.floor;
|
|
569
|
-
else {
|
|
570
|
-
const n = 10 ** t;
|
|
571
|
-
r = (o) => Math.floor(o * n) / n;
|
|
572
|
-
}
|
|
573
|
-
return r(Math.random() * (e - s) + s);
|
|
574
|
-
}
|
|
575
|
-
function C(s) {
|
|
576
|
+
function $(s) {
|
|
576
577
|
let e = 0;
|
|
577
578
|
for (const t of s)
|
|
578
579
|
e += t;
|
|
@@ -581,33 +582,33 @@ function C(s) {
|
|
|
581
582
|
function R(s) {
|
|
582
583
|
return `${s.charAt(0).toUpperCase()}${s.slice(1)}`;
|
|
583
584
|
}
|
|
584
|
-
const F = "1.
|
|
585
|
+
const F = "1.3.0-rc.1";
|
|
585
586
|
export {
|
|
586
|
-
|
|
587
|
+
f as AggregatedIterator,
|
|
587
588
|
m as Aggregator,
|
|
588
589
|
w as DateUnit,
|
|
589
590
|
p as DeferredPromise,
|
|
590
|
-
|
|
591
|
+
h as Exception,
|
|
591
592
|
x as JsonStorage,
|
|
592
|
-
|
|
593
|
-
l as
|
|
593
|
+
g as Random,
|
|
594
|
+
l as ReducedIterator,
|
|
595
|
+
c as SmartIterator,
|
|
594
596
|
b as Subscribers,
|
|
595
597
|
F as VERSION,
|
|
596
598
|
E as average,
|
|
597
599
|
R as capitalize,
|
|
598
600
|
T as count,
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
601
|
+
S as dateDifference,
|
|
602
|
+
j as dateRange,
|
|
603
|
+
I as dateRound,
|
|
604
|
+
k as delay,
|
|
603
605
|
O as hash,
|
|
604
606
|
A as loadScript,
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
C as
|
|
610
|
-
q as unique,
|
|
607
|
+
M as nextAnimationFrame,
|
|
608
|
+
P as range,
|
|
609
|
+
q as shuffle,
|
|
610
|
+
$ as sum,
|
|
611
|
+
C as unique,
|
|
611
612
|
y as zip
|
|
612
613
|
};
|
|
613
614
|
//# 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/deferred-promise.ts","../src/models/json-storage.ts","../src/models/subscribers.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<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<T, K extends PropertyKey>\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<T, K, boolean>): ReducedIterator<T, K>\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<T, K, V>): ReducedIterator<V, K>\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<T, K extends PropertyKey>\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<T, K, boolean>): ReducedIterator<boolean, K>\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<T, K, boolean>): ReducedIterator<boolean, K>\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<T, K, boolean>): AggregatedIterator<T, K>\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<T, K, V>): AggregatedIterator<V, K>\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<A>(reducer: KeyReducer<T, K, A>, initialValue?: A): ReducedIterator<A, K>\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;\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<T, K>\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<number, K>\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\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<T, K>\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","import type { PromiseResolver, PromiseRejecter, FulfilledHandler, RejectedHandler } from \"../types.js\";\n\nexport default class DeferredPromise<T = void, E = unknown, F = T, R = never>\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 let _resolve: PromiseResolver<T>;\n let _reject: PromiseRejecter<E>;\n\n this._promise = new Promise<T>((resolve, reject) =>\n {\n _resolve = resolve as PromiseResolver<T>;\n _reject = reject as PromiseRejecter<E>;\n\n }).then(onFulfilled, onRejected);\n\n this._resolve = _resolve!;\n this._reject = _reject!;\n }\n\n public get resolve(): PromiseResolver<T>\n {\n return this._resolve;\n }\n public get reject(): PromiseRejecter<E>\n {\n return this._reject;\n }\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]()\n {\n return \"DeferredPromise\";\n }\n}\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","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 i = 0; i < value.length; i++)\n {\n const char = value.charCodeAt(i);\n hashedValue = ((hashedValue << 5) - hashedValue) + char;\n hashedValue |= 0;\n }\n\n return hashedValue;\n}\n\nexport function random(): number;\nexport function random(max: number): number;\nexport function random(min: number, max: number): number;\nexport function random(min: number, max: number, isDecimal: boolean): number;\nexport function random(min: number, max: number, digits: number): number;\nexport function random(min: number = 1, max?: number, decimals?: boolean | number): number\n{\n if (max === undefined)\n {\n max = min;\n min = 0;\n }\n\n if (min === max)\n {\n return min;\n }\n\n let rounder: (value: number) => number;\n\n if (decimals === true)\n {\n rounder = (value) => value;\n }\n else if (decimals === undefined)\n {\n if (Math.abs(max - min) <= 1)\n {\n rounder = (value) => value;\n }\n else\n {\n rounder = Math.floor;\n }\n }\n else if (decimals === false)\n {\n rounder = Math.floor;\n }\n else\n {\n const digits = 10 ** decimals;\n\n rounder = (value) => Math.floor(value * digits) / digits;\n }\n\n return rounder(Math.random() * (max - min) + min);\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.2.1-rc.1\";\n\nexport {\n AggregatedIterator,\n Aggregator,\n DeferredPromise,\n Exception,\n JsonStorage,\n ReducedIterator,\n SmartIterator,\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 Iteratee,\n MaybePromise,\n PromiseExecutor,\n PromiseRejecter,\n PromiseResolver,\n Reducer,\n RejectedHandler\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","groups","Aggregator","DeferredPromise","onFulfilled","onRejected","_resolve","_reject","resolve","reject","onFinally","promise","JsonStorage","preferPersistence","storage","propertyName","defaultValue","propertyValue","newValue","encodedValue","persistent","Subscribers","subscriber","args","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","i","char","random","min","max","decimals","rounder","digits","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;AACJ;ACtCA,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,C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/B,SAAA+E;AACX;ACpGO,SAASa,EAAW5F,GAC3B;AACW,SAAA,GAAGA,EAAM,OAAO,CAAC,EAAE,aAAa,GAAGA,EAAM,MAAM,CAAC,CAAC;AAC5D;ACHO,MAAM6F,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/deferred-promise.ts","../src/models/json-storage.ts","../src/models/subscribers.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<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<T, K extends PropertyKey>\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<T, K, boolean>): ReducedIterator<T, K>\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<T, K, V>): ReducedIterator<V, K>\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<T, K extends PropertyKey>\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<T, K, boolean>): ReducedIterator<boolean, K>\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<T, K, boolean>): ReducedIterator<boolean, K>\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<T, K, boolean>): AggregatedIterator<T, K>\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<T, K, V>): AggregatedIterator<V, K>\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<A>(reducer: KeyReducer<T, K, A>, initialValue?: A): ReducedIterator<A, K>\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;\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<T, K>\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<number, K>\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\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<T, K>\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","import type { PromiseResolver, PromiseRejecter, FulfilledHandler, RejectedHandler } from \"../types.js\";\n\nexport default class DeferredPromise<T = void, E = unknown, F = T, R = never>\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 let _resolve: PromiseResolver<T>;\n let _reject: PromiseRejecter<E>;\n\n this._promise = new Promise<T>((resolve, reject) =>\n {\n _resolve = resolve as PromiseResolver<T>;\n _reject = reject as PromiseRejecter<E>;\n\n }).then(onFulfilled, onRejected);\n\n this._resolve = _resolve!;\n this._reject = _reject!;\n }\n\n public get resolve(): PromiseResolver<T>\n {\n return this._resolve;\n }\n public get reject(): PromiseRejecter<E>\n {\n return this._reject;\n }\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]()\n {\n return \"DeferredPromise\";\n }\n}\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","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.0-rc.1\";\n\nexport {\n AggregatedIterator,\n Aggregator,\n DeferredPromise,\n Exception,\n JsonStorage,\n ReducedIterator,\n SmartIterator,\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 Iteratee,\n MaybePromise,\n PromiseExecutor,\n PromiseRejecter,\n PromiseResolver,\n Reducer,\n RejectedHandler\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","groups","Aggregator","DeferredPromise","onFulfilled","onRejected","_resolve","_reject","resolve","reject","onFinally","promise","JsonStorage","preferPersistence","storage","propertyName","defaultValue","propertyValue","newValue","encodedValue","persistent","Subscribers","subscriber","args","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;AACJ;ACtCA,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,K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tC;AACI,MAAI0E,IAAO;AACX,aAAWnF,KAASS;AAAkB,IAAA0E,KAAAnF;AAE/B,SAAAmF;AACX;ACpDO,SAASM,EAAWzF,GAC3B;AACW,SAAA,GAAGA,EAAM,OAAO,CAAC,EAAE,aAAa,GAAGA,EAAM,MAAM,CAAC,CAAC;AAC5D;ACHO,MAAM0F,IAAU;"}
|
package/dist/core.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(o,
|
|
1
|
+
(function(o,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(o=typeof globalThis<"u"?globalThis:o||self,c(o.Core={}))})(this,function(o){"use strict";var $=Object.defineProperty;var F=(o,c,l)=>c in o?$(o,c,{enumerable:!0,configurable:!0,writable:!0,value:l}):o[c]=l;var a=(o,c,l)=>(F(o,typeof c!="symbol"?c+"":c,l),l);class c extends Error{static FromUnknown(e){if(e instanceof c)return e;if(e instanceof Error){const t=new c(e.message);return t.stack=e.stack,t.name=e.name,t}return new c(`${e}`)}constructor(e,t,n="Exception"){super(e),this.cause=t,this.name=n,t&&(t instanceof Error?this.stack+=`
|
|
2
2
|
|
|
3
3
|
Caused by ${t.stack}`:this.stack+=`
|
|
4
4
|
|
|
5
|
-
Caused by ${t}`)}}class
|
|
5
|
+
Caused by ${t}`)}}class l{constructor(e){a(this,"_iterator");a(this,"return");a(this,"throw");e instanceof Function?this._iterator=e():Symbol.iterator in e?this._iterator=e[Symbol.iterator]():this._iterator=e,this._iterator.return&&(this.return=t=>this._iterator.return(t)),this._iterator.throw&&(this.throw=t=>this._iterator.throw(t))}every(e){let t=0;for(;;){const n=this._iterator.next();if(n.done)return!0;if(!e(n.value,t))return!1;t+=1}}some(e){let t=0;for(;;){const n=this._iterator.next();if(n.done)return!1;if(e(n.value,t))return!0;t+=1}}filter(e){const t=this._iterator;return new l(function*(){let n=0;for(;;){const r=t.next();if(r.done)return r.value;e(r.value,n)&&(yield r.value),n+=1}})}map(e){const t=this._iterator;return new l(function*(){let n=0;for(;;){const r=t.next();if(r.done)return r.value;yield e(r.value,n),n+=1}})}reduce(e,t){let n=0,r=t;if(r===void 0){const i=this._iterator.next();if(i.done)throw new TypeError("Reduce of empty iterator with no initial value");r=i.value,n+=1}for(;;){const i=this._iterator.next();if(i.done)return r;r=e(r,i.value,n),n+=1}}enumerate(){return this.map((e,t)=>[t,e])}unique(){const e=this._iterator;return new l(function*(){const t=new Set;for(;;){const n=e.next();if(n.done)return n.value;t.has(n.value)||(t.add(n.value),yield n.value)}})}count(){let e=0;for(;;){if(this._iterator.next().done)return e;e+=1}}forEach(e){let t=0;for(;;){const n=this._iterator.next();if(n.done)return;e(n.value,t),t+=1}}next(...e){return this._iterator.next(...e)}toArray(){return Array.from(this)}[Symbol.iterator](){return this}}class f{constructor(e){a(this,"_elements");this._elements=new l(e)}filter(e){const t=this._elements;return new f(function*(){for(const[n,[r,i]]of t.enumerate())e(r,i,n)&&(yield[r,i])})}map(e){const t=this._elements;return new f(function*(){for(const[n,[r,i]]of t.enumerate())yield[r,e(r,i,n)]})}toArray(){return Array.from(this.toMap().values())}toMap(){return new Map(this._elements.toArray())}toObject(){return Object.fromEntries(this._elements.toArray())}}class h{constructor(e){a(this,"_elements");this._elements=new l(e)}every(e){const t=new Map;for(const[n,r]of this._elements){const[i,u]=t.get(n)??[0,!0];u&&t.set(n,[i+1,e(n,r,i)])}return new f(function*(){for(const[n,[r,i]]of t)yield[n,i]})}some(e){const t=new Map;for(const[n,r]of this._elements){const[i,u]=t.get(n)??[0,!1];u||t.set(n,[i+1,e(n,r,i)])}return new f(function*(){for(const[n,[r,i]]of t)yield[n,i]})}filter(e){const t=this._elements;return new h(function*(){const n=new Map;for(const[r,i]of t){const u=n.get(r)??0;n.set(r,u+1),e(r,i,u)&&(yield[r,i])}})}map(e){const t=this._elements;return new h(function*(){const n=new Map;for(const[r,i]of t){const u=n.get(r)??0;n.set(r,u+1),yield[r,e(r,i,u)]}})}reduce(e,t){const n=new Map;for(const[r,i]of this._elements){let u,m;if(n.has(r))[u,m]=n.get(r),u+=1;else if(t!==void 0)u=0,m=t;else{n.set(r,[0,i]);continue}m=e(r,m,i,u),n.set(r,[u,m])}return new f(function*(){for(const[r,[i,u]]of n)yield[r,u]})}unique(){const e=this._elements;return new h(function*(){const t=new Map;for(const[n,r]of e){const i=t.get(n)??new Set;i.has(r)||(i.add(r),t.set(n,i),yield[n,r])}})}count(){const e=new Map;for(const[t]of this._elements){const n=e.get(t)??0;e.set(t,n+1)}return new f(function*(){for(const[t,n]of e)yield[t,n]})}toArray(){return Array.from(this.toMap().values())}toMap(){const e=new Map;for(const[t,n]of this._elements){const r=e.get(t)??[];r.push(n),e.set(t,r)}return e}toObject(){const e={};for(const[t,n]of this._elements){const r=e[t]??[];r.push(n),e[t]=r}return e}}class d{constructor(e){a(this,"_elements");this._elements=new l(e)}filter(e){return new d(this._elements.filter(e))}map(e){return new d(this._elements.map(e))}unique(){return new d(this._elements.unique())}byKey(e){return new h(this._elements.map((t,n)=>[e(t,n),t]))}}class w{constructor(e,t){a(this,"_resolve");a(this,"_reject");a(this,"_promise");let n,r;this._promise=new Promise((i,u)=>{n=i,r=u}).then(e,t),this._resolve=n,this._reject=r}get resolve(){return this._resolve}get reject(){return this._reject}then(e,t){return this._promise.then(e,t)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}watch(e){return e.then(this.resolve,this.reject),this}get[Symbol.toStringTag](){return"DeferredPromise"}}class v{constructor(e=!0){a(this,"_preferPersistence");a(this,"_volatile");a(this,"_persistent");this._preferPersistence=e,this._volatile=window.sessionStorage,this._persistent=window.localStorage}_get(e,t,n){const r=e.getItem(t);if(r)try{return JSON.parse(r)}catch{console.warn(`The "${r}" value for "${t}" property cannot be parsed. Clearing the storage...`),e.removeItem(t)}return n}_set(e,t,n){const r=JSON.stringify(n);r?e.setItem(t,r):e.removeItem(t)}get(e,t,n=this._preferPersistence){const r=n?this._persistent:this._volatile;return this._get(r,e,t)}recall(e,t){return this._get(this._volatile,e,t)}retrieve(e,t){return this.recall(e)??this.read(e,t)}read(e,t){return this._get(this._persistent,e,t)}has(e,t){return(t?this._persistent:this._volatile).getItem(e)!==null}knows(e){return this._volatile.getItem(e)!==null}find(e){return this.knows(e)??this.exists(e)}exists(e){return this._persistent.getItem(e)!==null}set(e,t,n=this._preferPersistence){const r=n?this._persistent:this._volatile;this._set(r,e,t)}remember(e,t){this._set(this._volatile,e,t)}write(e,t){this._set(this._persistent,e,t)}forget(e){this._volatile.removeItem(e)}erase(e){this._persistent.removeItem(e)}clear(e){this._volatile.removeItem(e),this._persistent.removeItem(e)}}class g{constructor(){a(this,"_subscribers");this._subscribers=[]}add(e){this._subscribers.push(e)}remove(e){const t=this._subscribers.indexOf(e);if(t<0)throw new c("Unable to remove the requested subscriber. It was not found.");this._subscribers.splice(t,1)}call(...e){return this._subscribers.slice().map(t=>t(...e))}}class b{static Boolean(e=.5){return Math.random()<e}static Integer(e,t){return Math.floor(t===void 0?Math.random()*e:Math.random()*(t-e)+e)}static Decimal(e,t){return t===void 0?Math.random()*e:Math.random()*(t-e)+e}static Choice(e){return e[this.Integer(e.length)]}constructor(){}}async function p(s){return new Promise((e,t)=>setTimeout(e,s))}async function k(){return new Promise((s,e)=>requestAnimationFrame(()=>s()))}var _=(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))(_||{});function M(s,e,t=864e5){return Math.floor((e.getTime()-s.getTime())/t)}function S(s,e,t=864e5){return new l(function*(){const n=e.getTime();let r=s.getTime();for(;r<n;)yield new Date(r),r+=t})}function x(s,e=864e5){return new Date(Math.floor(s.getTime()/e)*e)}async function I(s,e="text/javascript"){return new Promise((t,n)=>{const r=document.createElement("script");r.async=!0,r.defer=!0,r.src=s,r.type=e,r.onload=()=>t(),r.onerror=()=>n(),document.body.appendChild(r)})}function j(s){if(Array.isArray(s))return s.length;let e=0;for(const t of s)e+=1;return e}function A(s,e,t=1){return new l(function*(){e===void 0&&(e=s,s=0),s>e&&(t=t??-1);for(let n=s;n<e;n+=t)yield n})}function T(s){const e=Array.from(s);for(let t=e.length-1;t>0;t-=1){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e}function P(s){return new l(function*(){const e=new Set;for(const t of s)e.has(t)||(e.add(t),yield t)})}function y(s,e){return new l(function*(){const t=s[Symbol.iterator](),n=e[Symbol.iterator]();for(;;){const r=t.next(),i=n.next();if(r.done||i.done)break;yield[r.value,i.value]}})}function R(s,e){if(e===void 0){let r=0,i=0;for(const u of s)r+=u,i+=1;return r/i}let t=0,n=0;for(const[r,i]of y(s,e))t+=r*i,n+=i;return t/n}function E(s){let e=0;for(let t=0;t<s.length;t+=1){const n=s.charCodeAt(t);e=(e<<5)-e+n,e|=0}return e}function O(s){let e=0;for(const t of s)e+=t;return e}function q(s){return`${s.charAt(0).toUpperCase()}${s.slice(1)}`}const C="1.3.0-rc.1";o.AggregatedIterator=h,o.Aggregator=d,o.DateUnit=_,o.DeferredPromise=w,o.Exception=c,o.JsonStorage=v,o.Random=b,o.ReducedIterator=f,o.SmartIterator=l,o.Subscribers=g,o.VERSION=C,o.average=R,o.capitalize=q,o.count=j,o.dateDifference=M,o.dateRange=S,o.dateRound=x,o.delay=p,o.hash=E,o.loadScript=I,o.nextAnimationFrame=k,o.range=A,o.shuffle=T,o.sum=O,o.unique=P,o.zip=y,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|
|
6
6
|
//# sourceMappingURL=core.umd.cjs.map
|
package/dist/core.umd.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.umd.cjs","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/deferred-promise.ts","../src/models/json-storage.ts","../src/models/subscribers.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<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<T, K extends PropertyKey>\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<T, K, boolean>): ReducedIterator<T, K>\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<T, K, V>): ReducedIterator<V, K>\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<T, K extends PropertyKey>\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<T, K, boolean>): ReducedIterator<boolean, K>\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<T, K, boolean>): ReducedIterator<boolean, K>\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<T, K, boolean>): AggregatedIterator<T, K>\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<T, K, V>): AggregatedIterator<V, K>\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<A>(reducer: KeyReducer<T, K, A>, initialValue?: A): ReducedIterator<A, K>\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;\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<T, K>\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<number, K>\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\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<T, K>\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","import type { PromiseResolver, PromiseRejecter, FulfilledHandler, RejectedHandler } from \"../types.js\";\n\nexport default class DeferredPromise<T = void, E = unknown, F = T, R = never>\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 let _resolve: PromiseResolver<T>;\n let _reject: PromiseRejecter<E>;\n\n this._promise = new Promise<T>((resolve, reject) =>\n {\n _resolve = resolve as PromiseResolver<T>;\n _reject = reject as PromiseRejecter<E>;\n\n }).then(onFulfilled, onRejected);\n\n this._resolve = _resolve!;\n this._reject = _reject!;\n }\n\n public get resolve(): PromiseResolver<T>\n {\n return this._resolve;\n }\n public get reject(): PromiseRejecter<E>\n {\n return this._reject;\n }\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]()\n {\n return \"DeferredPromise\";\n }\n}\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","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 i = 0; i < value.length; i++)\n {\n const char = value.charCodeAt(i);\n hashedValue = ((hashedValue << 5) - hashedValue) + char;\n hashedValue |= 0;\n }\n\n return hashedValue;\n}\n\nexport function random(): number;\nexport function random(max: number): number;\nexport function random(min: number, max: number): number;\nexport function random(min: number, max: number, isDecimal: boolean): number;\nexport function random(min: number, max: number, digits: number): number;\nexport function random(min: number = 1, max?: number, decimals?: boolean | number): number\n{\n if (max === undefined)\n {\n max = min;\n min = 0;\n }\n\n if (min === max)\n {\n return min;\n }\n\n let rounder: (value: number) => number;\n\n if (decimals === true)\n {\n rounder = (value) => value;\n }\n else if (decimals === undefined)\n {\n if (Math.abs(max - min) <= 1)\n {\n rounder = (value) => value;\n }\n else\n {\n rounder = Math.floor;\n }\n }\n else if (decimals === false)\n {\n rounder = Math.floor;\n }\n else\n {\n const digits = 10 ** decimals;\n\n rounder = (value) => Math.floor(value * digits) / digits;\n }\n\n return rounder(Math.random() * (max - min) + min);\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.2.1-rc.1\";\n\nexport {\n AggregatedIterator,\n Aggregator,\n DeferredPromise,\n Exception,\n JsonStorage,\n ReducedIterator,\n SmartIterator,\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 Iteratee,\n MaybePromise,\n PromiseExecutor,\n PromiseRejecter,\n PromiseResolver,\n Reducer,\n RejectedHandler\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","groups","Aggregator","DeferredPromise","onFulfilled","onRejected","_resolve","_reject","resolve","reject","onFinally","promise","JsonStorage","preferPersistence","storage","propertyName","defaultValue","propertyValue","newValue","encodedValue","persistent","Subscribers","subscriber","args","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","i","char","random","min","max","decimals","rounder","digits","sum","capitalize","VERSION"],"mappings":"oYAAA,MAAqBA,UAAkB,KACvC,CACI,OAAc,YAAYC,EAC1B,CACI,GAAIA,aAAiBD,EAEV,OAAAC,EAEX,GAAIA,aAAiB,MACrB,CACI,MAAMC,EAAM,IAAIF,EAAUC,EAAM,OAAO,EAEvC,OAAAC,EAAI,MAAQD,EAAM,MAClBC,EAAI,KAAOD,EAAM,KAEVC,CACX,CAEA,OAAO,IAAIF,EAAU,GAAGC,CAAK,EAAE,CACnC,CAEO,YAAYE,EAAiBC,EAAiBC,EAAO,YAC5D,CACI,MAAMF,CAAO,EAEb,KAAK,MAAQC,EACb,KAAK,KAAOC,EAERD,IAEIA,aAAiB,MAEjB,KAAK,OAAS;AAAA;AAAA,YAAiBA,EAAM,KAAK,GAI1C,KAAK,OAAS;AAAA;AAAA,YAAiBA,CAAK,GAGhD,CACJ,CCtCA,MAAqBE,CACrB,CAUW,YAAYC,EACnB,CAVUC,EAAA,kBAEHA,EAAA,eACAA,EAAA,cAQCD,aAAoB,SAEpB,KAAK,UAAYA,IAEZ,OAAO,YAAYA,EAExB,KAAK,UAAYA,EAAS,OAAO,QAAQ,EAAE,EAI3C,KAAK,UAAYA,EAGjB,KAAK,UAAU,SAAU,KAAK,OAAUE,GAAc,KAAK,UAAU,OAAQA,CAAK,GAClF,KAAK,UAAU,QAAS,KAAK,MAASR,GAAoB,KAAK,UAAU,MAAOA,CAAK,EAC7F,CAEO,MAAMS,EACb,CACI,IAAIC,EAAQ,EAGZ,OACA,CACU,MAAAC,EAAS,KAAK,UAAU,KAAK,EAEnC,GAAIA,EAAO,KAAe,MAAA,GAC1B,GAAI,CAAEF,EAAUE,EAAO,MAAOD,CAAK,EAAa,MAAA,GAEvCA,GAAA,CACb,CACJ,CACO,KAAKD,EACZ,CACI,IAAIC,EAAQ,EAGZ,OAC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,IAAAG,EAEJ,GAAID,IAAa,GAEbC,EAAWzF,GAAUA,UAEhBwF,IAAa,OAEd,KAAK,IAAID,EAAMD,CAAG,GAAK,EAEvBG,EAAWzF,GAAUA,EAIrByF,EAAU,KAAK,cAGdD,IAAa,GAElBC,EAAU,KAAK,UAGnB,CACI,MAAMC,EAAS,IAAMF,EAErBC,EAAWzF,GAAU,KAAK,MAAMA,EAAQ0F,CAAM,EAAIA,CACtD,CAEA,OAAOD,EAAQ,KAAK,OAAA,GAAYF,EAAMD,GAAOA,CAAG,CACpD,CAEO,SAASK,EAAsBlF,EACtC,CACI,IAAIsE,EAAO,EACX,UAAW/E,KAASS,EAAkBsE,GAAA/E,EAE/B,OAAA+E,CACX,CCpGO,SAASa,EAAW5F,EAC3B,CACW,MAAA,GAAGA,EAAM,OAAO,CAAC,EAAE,aAAa,GAAGA,EAAM,MAAM,CAAC,CAAC,EAC5D,CCHO,MAAM6F,EAAU"}
|
|
1
|
+
{"version":3,"file":"core.umd.cjs","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/deferred-promise.ts","../src/models/json-storage.ts","../src/models/subscribers.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<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<T, K extends PropertyKey>\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<T, K, boolean>): ReducedIterator<T, K>\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<T, K, V>): ReducedIterator<V, K>\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<T, K extends PropertyKey>\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<T, K, boolean>): ReducedIterator<boolean, K>\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<T, K, boolean>): ReducedIterator<boolean, K>\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<T, K, boolean>): AggregatedIterator<T, K>\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<T, K, V>): AggregatedIterator<V, K>\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<A>(reducer: KeyReducer<T, K, A>, initialValue?: A): ReducedIterator<A, K>\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;\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<T, K>\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<number, K>\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\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<T, K>\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","import type { PromiseResolver, PromiseRejecter, FulfilledHandler, RejectedHandler } from \"../types.js\";\n\nexport default class DeferredPromise<T = void, E = unknown, F = T, R = never>\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 let _resolve: PromiseResolver<T>;\n let _reject: PromiseRejecter<E>;\n\n this._promise = new Promise<T>((resolve, reject) =>\n {\n _resolve = resolve as PromiseResolver<T>;\n _reject = reject as PromiseRejecter<E>;\n\n }).then(onFulfilled, onRejected);\n\n this._resolve = _resolve!;\n this._reject = _reject!;\n }\n\n public get resolve(): PromiseResolver<T>\n {\n return this._resolve;\n }\n public get reject(): PromiseRejecter<E>\n {\n return this._reject;\n }\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]()\n {\n return \"DeferredPromise\";\n }\n}\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","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.0-rc.1\";\n\nexport {\n AggregatedIterator,\n Aggregator,\n DeferredPromise,\n Exception,\n JsonStorage,\n ReducedIterator,\n SmartIterator,\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 Iteratee,\n MaybePromise,\n PromiseExecutor,\n PromiseRejecter,\n PromiseResolver,\n Reducer,\n RejectedHandler\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","groups","Aggregator","DeferredPromise","onFulfilled","onRejected","_resolve","_reject","resolve","reject","onFinally","promise","JsonStorage","preferPersistence","storage","propertyName","defaultValue","propertyValue","newValue","encodedValue","persistent","Subscribers","subscriber","args","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":"oYAAA,MAAqBA,UAAkB,KACvC,CACI,OAAc,YAAYC,EAC1B,CACI,GAAIA,aAAiBD,EAEV,OAAAC,EAEX,GAAIA,aAAiB,MACrB,CACI,MAAMC,EAAM,IAAIF,EAAUC,EAAM,OAAO,EAEvC,OAAAC,EAAI,MAAQD,EAAM,MAClBC,EAAI,KAAOD,EAAM,KAEVC,CACX,CAEA,OAAO,IAAIF,EAAU,GAAGC,CAAK,EAAE,CACnC,CAEO,YAAYE,EAAiBC,EAAiBC,EAAO,YAC5D,CACI,MAAMF,CAAO,EAEb,KAAK,MAAQC,EACb,KAAK,KAAOC,EAERD,IAEIA,aAAiB,MAEjB,KAAK,OAA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AM,CAAC,CAAC,EAC5D,CCHO,MAAM0F,EAAU"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
package/src/utils/index.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import Random from "./random.js";
|
|
2
|
+
|
|
1
3
|
export { delay, nextAnimationFrame } from "./async.js";
|
|
2
4
|
export { dateDifference, dateRange, dateRound, DateUnit } from "./date.js";
|
|
3
5
|
export { loadScript } from "./dom.js";
|
|
4
6
|
export { count, range, shuffle, unique, zip } from "./iterator.js";
|
|
5
|
-
export { average, hash,
|
|
7
|
+
export { average, hash, sum } from "./math.js";
|
|
6
8
|
export { capitalize } from "./string.js";
|
|
9
|
+
|
|
10
|
+
export { Random };
|
package/src/utils/math.ts
CHANGED
|
@@ -33,9 +33,10 @@ export function average<T extends number>(values: Iterable<T>, weights?: Iterabl
|
|
|
33
33
|
export function hash(value: string): number
|
|
34
34
|
{
|
|
35
35
|
let hashedValue = 0;
|
|
36
|
-
for (let
|
|
36
|
+
for (let index = 0; index < value.length; index += 1)
|
|
37
37
|
{
|
|
38
|
-
const char = value.charCodeAt(
|
|
38
|
+
const char = value.charCodeAt(index);
|
|
39
|
+
|
|
39
40
|
hashedValue = ((hashedValue << 5) - hashedValue) + char;
|
|
40
41
|
hashedValue |= 0;
|
|
41
42
|
}
|
|
@@ -43,55 +44,6 @@ export function hash(value: string): number
|
|
|
43
44
|
return hashedValue;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
export function random(): number;
|
|
47
|
-
export function random(max: number): number;
|
|
48
|
-
export function random(min: number, max: number): number;
|
|
49
|
-
export function random(min: number, max: number, isDecimal: boolean): number;
|
|
50
|
-
export function random(min: number, max: number, digits: number): number;
|
|
51
|
-
export function random(min: number = 1, max?: number, decimals?: boolean | number): number
|
|
52
|
-
{
|
|
53
|
-
if (max === undefined)
|
|
54
|
-
{
|
|
55
|
-
max = min;
|
|
56
|
-
min = 0;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (min === max)
|
|
60
|
-
{
|
|
61
|
-
return min;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
let rounder: (value: number) => number;
|
|
65
|
-
|
|
66
|
-
if (decimals === true)
|
|
67
|
-
{
|
|
68
|
-
rounder = (value) => value;
|
|
69
|
-
}
|
|
70
|
-
else if (decimals === undefined)
|
|
71
|
-
{
|
|
72
|
-
if (Math.abs(max - min) <= 1)
|
|
73
|
-
{
|
|
74
|
-
rounder = (value) => value;
|
|
75
|
-
}
|
|
76
|
-
else
|
|
77
|
-
{
|
|
78
|
-
rounder = Math.floor;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
else if (decimals === false)
|
|
82
|
-
{
|
|
83
|
-
rounder = Math.floor;
|
|
84
|
-
}
|
|
85
|
-
else
|
|
86
|
-
{
|
|
87
|
-
const digits = 10 ** decimals;
|
|
88
|
-
|
|
89
|
-
rounder = (value) => Math.floor(value * digits) / digits;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return rounder(Math.random() * (max - min) + min);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
47
|
export function sum<T extends number>(values: Iterable<T>): number
|
|
96
48
|
{
|
|
97
49
|
let _sum = 0;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export default class Random
|
|
2
|
+
{
|
|
3
|
+
public static Boolean(ratio: number = 0.5): boolean
|
|
4
|
+
{
|
|
5
|
+
return (Math.random() < ratio);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
public static Integer(max: number): number;
|
|
9
|
+
public static Integer(min: number, max: number): number;
|
|
10
|
+
public static Integer(min: number, max?: number): number
|
|
11
|
+
{
|
|
12
|
+
if (max === undefined)
|
|
13
|
+
{
|
|
14
|
+
return Math.floor(Math.random() * min);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return Math.floor(Math.random() * (max - min) + min);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public static Decimal(max: number): number;
|
|
21
|
+
public static Decimal(min: number, max: number): number;
|
|
22
|
+
public static Decimal(min: number, max?: number): number
|
|
23
|
+
{
|
|
24
|
+
if (max === undefined)
|
|
25
|
+
{
|
|
26
|
+
return (Math.random() * min);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (Math.random() * (max - min) + min);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public static Choice<T>(elements: T[]): T
|
|
33
|
+
{
|
|
34
|
+
return elements[this.Integer(elements.length)];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// eslint-disable-next-line no-useless-constructor
|
|
38
|
+
private constructor() { }
|
|
39
|
+
}
|