@byloth/core 1.3.3 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -1,6 +1,6 @@
1
- var w = Object.defineProperty;
2
- var y = (s, e, t) => e in s ? w(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var l = (s, e, t) => (y(s, typeof e != "symbol" ? e + "" : e, t), t);
1
+ var y = Object.defineProperty;
2
+ var g = (s, e, t) => e in s ? y(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var l = (s, e, t) => (g(s, typeof e != "symbol" ? e + "" : e, t), t);
4
4
  class h extends Error {
5
5
  static FromUnknown(e) {
6
6
  if (e instanceof h)
@@ -18,6 +18,9 @@ Caused by ${t.stack}` : this.stack += `
18
18
 
19
19
  Caused by ${t}`);
20
20
  }
21
+ get [Symbol.toStringTag]() {
22
+ return "Exception";
23
+ }
21
24
  }
22
25
  class u {
23
26
  constructor(e) {
@@ -125,6 +128,9 @@ class u {
125
128
  toArray() {
126
129
  return Array.from(this);
127
130
  }
131
+ get [Symbol.toStringTag]() {
132
+ return "SmartIterator";
133
+ }
128
134
  [Symbol.iterator]() {
129
135
  return this;
130
136
  }
@@ -148,17 +154,37 @@ class f {
148
154
  yield [r, e(r, i, n)];
149
155
  });
150
156
  }
157
+ keys() {
158
+ const e = this._elements;
159
+ return new u(function* () {
160
+ for (const [t] of e)
161
+ yield t;
162
+ });
163
+ }
164
+ items() {
165
+ return this._elements;
166
+ }
167
+ values() {
168
+ const e = this._elements;
169
+ return new u(function* () {
170
+ for (const [t, n] of e)
171
+ yield n;
172
+ });
173
+ }
151
174
  toArray() {
152
- return Array.from(this.toMap().values());
175
+ return Array.from(this.values());
153
176
  }
154
177
  toMap() {
155
- return new Map(this._elements.toArray());
178
+ return new Map(this.items());
156
179
  }
157
180
  toObject() {
158
- return Object.fromEntries(this._elements.toArray());
181
+ return Object.fromEntries(this.items());
182
+ }
183
+ get [Symbol.toStringTag]() {
184
+ return "ReducedIterator";
159
185
  }
160
186
  }
161
- class d {
187
+ class m {
162
188
  constructor(e) {
163
189
  l(this, "_elements");
164
190
  this._elements = new u(e);
@@ -187,7 +213,7 @@ class d {
187
213
  }
188
214
  filter(e) {
189
215
  const t = this._elements;
190
- return new d(function* () {
216
+ return new m(function* () {
191
217
  const n = /* @__PURE__ */ new Map();
192
218
  for (const [r, i] of t) {
193
219
  const o = n.get(r) ?? 0;
@@ -197,7 +223,7 @@ class d {
197
223
  }
198
224
  map(e) {
199
225
  const t = this._elements;
200
- return new d(function* () {
226
+ return new m(function* () {
201
227
  const n = /* @__PURE__ */ new Map();
202
228
  for (const [r, i] of t) {
203
229
  const o = n.get(r) ?? 0;
@@ -212,7 +238,7 @@ class d {
212
238
  if (n.has(r))
213
239
  [o, c] = n.get(r), o += 1;
214
240
  else if (t !== void 0)
215
- o = 0, c = t;
241
+ o = 0, c = t(r);
216
242
  else {
217
243
  n.set(r, [0, i]);
218
244
  continue;
@@ -226,7 +252,7 @@ class d {
226
252
  }
227
253
  unique() {
228
254
  const e = this._elements;
229
- return new d(function* () {
255
+ return new m(function* () {
230
256
  const t = /* @__PURE__ */ new Map();
231
257
  for (const [n, r] of e) {
232
258
  const i = t.get(n) ?? /* @__PURE__ */ new Set();
@@ -263,6 +289,23 @@ class d {
263
289
  yield [t, n];
264
290
  });
265
291
  }
292
+ keys() {
293
+ const e = this._elements;
294
+ return new u(function* () {
295
+ for (const [t] of e)
296
+ yield t;
297
+ });
298
+ }
299
+ items() {
300
+ return this._elements;
301
+ }
302
+ values() {
303
+ const e = this._elements;
304
+ return new u(function* () {
305
+ for (const [t, n] of e)
306
+ yield n;
307
+ });
308
+ }
266
309
  toArray() {
267
310
  return Array.from(this.toMap().values());
268
311
  }
@@ -282,23 +325,29 @@ class d {
282
325
  }
283
326
  return e;
284
327
  }
328
+ get [Symbol.toStringTag]() {
329
+ return "AggregatedIterator";
330
+ }
285
331
  }
286
- class _ {
332
+ class d {
287
333
  constructor(e) {
288
334
  l(this, "_elements");
289
335
  this._elements = new u(e);
290
336
  }
291
337
  filter(e) {
292
- return new _(this._elements.filter(e));
338
+ return new d(this._elements.filter(e));
293
339
  }
294
340
  map(e) {
295
- return new _(this._elements.map(e));
341
+ return new d(this._elements.map(e));
296
342
  }
297
343
  unique() {
298
- return new _(this._elements.unique());
344
+ return new d(this._elements.unique());
299
345
  }
300
- byKey(e) {
301
- return new d(this._elements.map((t, n) => [e(t, n), t]));
346
+ groupBy(e) {
347
+ return new m(this._elements.map((t, n) => [e(t, n), t]));
348
+ }
349
+ get [Symbol.toStringTag]() {
350
+ return "Aggregator";
302
351
  }
303
352
  }
304
353
  class x {
@@ -435,6 +484,9 @@ class x {
435
484
  clear(e) {
436
485
  this._volatile.removeItem(e), this._persistent.removeItem(e);
437
486
  }
487
+ get [Symbol.toStringTag]() {
488
+ return "JsonStorage";
489
+ }
438
490
  }
439
491
  class b {
440
492
  constructor() {
@@ -453,8 +505,11 @@ class b {
453
505
  call(...e) {
454
506
  return this._subscribers.slice().map((t) => t(...e));
455
507
  }
508
+ get [Symbol.toStringTag]() {
509
+ return "Subscribers";
510
+ }
456
511
  }
457
- class k {
512
+ class S {
458
513
  constructor(e, t) {
459
514
  l(this, "_isPending");
460
515
  l(this, "_isFulfilled");
@@ -464,8 +519,8 @@ class k {
464
519
  l(this, "_promise");
465
520
  this._isPending = !0, this._isFulfilled = !1, this._isRejected = !1;
466
521
  let n, r;
467
- const i = (a, m) => {
468
- n = a, r = m;
522
+ const i = (a, _) => {
523
+ n = a, r = _;
469
524
  };
470
525
  let o;
471
526
  e ? o = (a) => (this._isPending = !1, this._isFulfilled = !0, e(a)) : o = (a) => (this._isPending = !1, this._isFulfilled = !0, a);
@@ -503,7 +558,7 @@ class k {
503
558
  return "DeferredPromise";
504
559
  }
505
560
  }
506
- class M {
561
+ class k {
507
562
  constructor(e) {
508
563
  l(this, "_isPending");
509
564
  l(this, "_isFulfilled");
@@ -535,7 +590,7 @@ class M {
535
590
  return "SmartPromise";
536
591
  }
537
592
  }
538
- class P {
593
+ class M {
539
594
  static Boolean(e = 0.5) {
540
595
  return Math.random() < e;
541
596
  }
@@ -552,17 +607,17 @@ class P {
552
607
  constructor() {
553
608
  }
554
609
  }
555
- async function j(s) {
610
+ async function P(s) {
556
611
  return new Promise((e, t) => setTimeout(e, s));
557
612
  }
558
- async function S() {
613
+ async function j() {
559
614
  return new Promise((s, e) => requestAnimationFrame(() => s()));
560
615
  }
561
- var v = /* @__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))(v || {});
562
- function R(s, e, t = 864e5) {
616
+ var w = /* @__PURE__ */ ((s) => (s[s.Second = 1e3] = "Second", s[s.Minute = 6e4] = "Minute", s[s.Hour = 36e5] = "Hour", s[s.Day = 864e5] = "Day", s[s.Week = 6048e5] = "Week", s[s.Month = 2592e6] = "Month", s[s.Year = 31536e6] = "Year", s))(w || {});
617
+ function T(s, e, t = 864e5) {
563
618
  return Math.floor((e.getTime() - s.getTime()) / t);
564
619
  }
565
- function F(s, e, t = 864e5) {
620
+ function R(s, e, t = 864e5) {
566
621
  return new u(function* () {
567
622
  const n = e.getTime();
568
623
  let r = s.getTime();
@@ -570,10 +625,10 @@ function F(s, e, t = 864e5) {
570
625
  yield new Date(r), r += t;
571
626
  });
572
627
  }
573
- function I(s, e = 864e5) {
628
+ function F(s, e = 864e5) {
574
629
  return new Date(Math.floor(s.getTime() / e) * e);
575
630
  }
576
- async function T(s, e = "text/javascript") {
631
+ async function I(s, e = "text/javascript") {
577
632
  return new Promise((t, n) => {
578
633
  const r = document.createElement("script");
579
634
  r.async = !0, r.defer = !0, r.src = s, r.type = e, r.onload = () => t(), r.onerror = () => n(), document.body.appendChild(r);
@@ -587,14 +642,14 @@ function A(s) {
587
642
  e += 1;
588
643
  return e;
589
644
  }
590
- function q(s, e, t = 1) {
645
+ function E(s, e, t = 1) {
591
646
  return new u(function* () {
592
647
  e === void 0 && (e = s, s = 0), s > e && (t = t ?? -1);
593
648
  for (let n = s; n < e; n += t)
594
649
  yield n;
595
650
  });
596
651
  }
597
- function C(s) {
652
+ function q(s) {
598
653
  const e = Array.from(s);
599
654
  for (let t = e.length - 1; t > 0; t -= 1) {
600
655
  const n = Math.floor(Math.random() * (t + 1));
@@ -602,14 +657,14 @@ function C(s) {
602
657
  }
603
658
  return e;
604
659
  }
605
- function E(s) {
660
+ function C(s) {
606
661
  return new u(function* () {
607
662
  const e = /* @__PURE__ */ new Set();
608
663
  for (const t of s)
609
664
  e.has(t) || (e.add(t), yield t);
610
665
  });
611
666
  }
612
- function p(s, e) {
667
+ function v(s, e) {
613
668
  return new u(function* () {
614
669
  const t = s[Symbol.iterator](), n = e[Symbol.iterator]();
615
670
  for (; ; ) {
@@ -628,7 +683,7 @@ function O(s, e) {
628
683
  return r / i;
629
684
  }
630
685
  let t = 0, n = 0;
631
- for (const [r, i] of p(s, e))
686
+ for (const [r, i] of v(s, e))
632
687
  t += r * i, n += i;
633
688
  return t / n;
634
689
  }
@@ -649,34 +704,34 @@ function J(s) {
649
704
  function V(s) {
650
705
  return `${s.charAt(0).toUpperCase()}${s.slice(1)}`;
651
706
  }
652
- const z = "1.3.3";
707
+ const z = "1.4.0";
653
708
  export {
654
- d as AggregatedIterator,
655
- _ as Aggregator,
656
- v as DateUnit,
657
- k as DeferredPromise,
709
+ m as AggregatedIterator,
710
+ d as Aggregator,
711
+ w as DateUnit,
712
+ S as DeferredPromise,
658
713
  h as Exception,
659
714
  x as JsonStorage,
660
- P as Random,
715
+ M as Random,
661
716
  f as ReducedIterator,
662
717
  u as SmartIterator,
663
- M as SmartPromise,
718
+ k as SmartPromise,
664
719
  b as Subscribers,
665
720
  z as VERSION,
666
721
  O as average,
667
722
  V as capitalize,
668
723
  A as count,
669
- R as dateDifference,
670
- F as dateRange,
671
- I as dateRound,
672
- j as delay,
724
+ T as dateDifference,
725
+ R as dateRange,
726
+ F as dateRound,
727
+ P as delay,
673
728
  $ as hash,
674
- T as loadScript,
675
- S as nextAnimationFrame,
676
- q as range,
677
- C as shuffle,
729
+ I as loadScript,
730
+ j as nextAnimationFrame,
731
+ E as range,
732
+ q as shuffle,
678
733
  J as sum,
679
- E as unique,
680
- p as zip
734
+ C as unique,
735
+ v as zip
681
736
  };
682
737
  //# sourceMappingURL=core.js.map
package/dist/core.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"core.js","sources":["../src/models/exception.ts","../src/models/smart-iterator.ts","../src/models/aggregators/reduced-iterator.ts","../src/models/aggregators/aggregated-iterator.ts","../src/models/aggregators/index.ts","../src/models/json-storage.ts","../src/models/subscribers.ts","../src/models/promises/deferred-promise.ts","../src/models/promises/smart-promise.ts","../src/utils/random.ts","../src/utils/async.ts","../src/utils/date.ts","../src/utils/dom.ts","../src/utils/iterator.ts","../src/utils/math.ts","../src/utils/string.ts","../src/index.ts"],"sourcesContent":["export default class Exception extends Error\n{\n public static FromUnknown(error: unknown): Exception\n {\n if (error instanceof Exception)\n {\n return error;\n }\n if (error instanceof Error)\n {\n const exc = new Exception(error.message);\n\n exc.stack = error.stack;\n exc.name = error.name;\n\n return exc;\n }\n\n return new Exception(`${error}`);\n }\n\n public constructor(message: string, cause?: unknown, name = \"Exception\")\n {\n super(message);\n\n this.cause = cause;\n this.name = name;\n\n if (cause)\n {\n if (cause instanceof Error)\n {\n this.stack += `\\n\\nCaused by ${cause.stack}`;\n }\n else\n {\n this.stack += `\\n\\nCaused by ${cause}`;\n }\n }\n }\n}\n","import type { GeneratorFunction, Iteratee, Reducer } from \"../types.js\";\n\nexport default class SmartIterator<T, R = void, N = undefined> implements Iterator<T, R, N>\n{\n protected _iterator: Iterator<T, R, N>;\n\n public return?: (value?: R) => IteratorResult<T, R>;\n public throw?: (error?: unknown) => IteratorResult<T, R>;\n\n public constructor(iterable: Iterable<T>);\n public constructor(iterator: Iterator<T, R, N>);\n public constructor(generatorFn: GeneratorFunction<T, R, N>);\n public constructor(argument: Iterable<T> | Iterator<T, R, N> | GeneratorFunction<T, R, N>);\n public constructor(argument: Iterable<T> | Iterator<T, R, N> | GeneratorFunction<T, R, N>)\n {\n if (argument instanceof Function)\n {\n this._iterator = argument();\n }\n else if (Symbol.iterator in argument)\n {\n this._iterator = argument[Symbol.iterator]() as Iterator<T, R, N>;\n }\n else\n {\n this._iterator = argument;\n }\n\n if (this._iterator.return) { this.return = (value?: R) => this._iterator.return!(value); }\n if (this._iterator.throw) { this.throw = (error?: unknown) => this._iterator.throw!(error); }\n }\n\n public every(predicate: Iteratee<T, boolean>): boolean\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n\n if (result.done) { return true; }\n if (!(predicate(result.value, index))) { return false; }\n\n index += 1;\n }\n }\n public some(predicate: Iteratee<T, boolean>): boolean\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n\n if (result.done) { return false; }\n if (predicate(result.value, index)) { return true; }\n\n index += 1;\n }\n }\n\n public filter(predicate: Iteratee<T, boolean>): SmartIterator<T, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<T, R>(function* ()\n {\n let index = 0;\n\n while (true)\n {\n const result = iterator.next();\n\n if (result.done) { return result.value; }\n if (predicate(result.value, index)) { yield result.value; }\n\n index += 1;\n }\n });\n }\n public map<V>(iteratee: Iteratee<T, V>): SmartIterator<V, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<V, R>(function* ()\n {\n let index = 0;\n\n while (true)\n {\n const result = iterator.next();\n if (result.done) { return result.value; }\n\n yield iteratee(result.value, index);\n\n index += 1;\n }\n });\n }\n public reduce<A>(reducer: Reducer<T, A>, initialValue?: A): A\n {\n let index = 0;\n let accumulator = initialValue;\n if (accumulator === undefined)\n {\n const result = this._iterator.next();\n if (result.done) { throw new TypeError(\"Reduce of empty iterator with no initial value\"); }\n\n accumulator = (result.value as unknown) as A;\n index += 1;\n }\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return accumulator; }\n\n accumulator = reducer(accumulator, result.value, index);\n\n index += 1;\n }\n }\n\n public enumerate(): SmartIterator<[number, T], R>\n {\n return this.map((value, index) => [index, value]);\n }\n public unique(): SmartIterator<T, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<T, R>(function* ()\n {\n const values = new Set<T>();\n\n while (true)\n {\n const result = iterator.next();\n\n if (result.done) { return result.value; }\n if (values.has(result.value)) { continue; }\n\n values.add(result.value);\n\n yield result.value;\n }\n });\n }\n\n public count(): number\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return index; }\n\n index += 1;\n }\n }\n public forEach(iteratee: Iteratee<T>): void\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return; }\n\n iteratee(result.value, index);\n\n index += 1;\n }\n }\n\n public next(...values: N extends undefined ? [] : [N]): IteratorResult<T, R>\n {\n return this._iterator.next(...values);\n }\n\n public toArray(): T[]\n {\n return Array.from(this as Iterable<T>);\n }\n\n public [Symbol.iterator](): SmartIterator<T, R, N> { return this; }\n}\n","import SmartIterator from \"../smart-iterator.js\";\n\nimport type { KeyIteratee } from \"./types.js\";\nimport type { GeneratorFunction } from \"../../types.js\";\n\nexport default class ReducedIterator<K extends PropertyKey, T>\n{\n protected _elements: SmartIterator<[K, T]>;\n\n public constructor(iterable: Iterable<[K, T]>);\n public constructor(iterator: Iterator<[K, T]>);\n public constructor(generatorFn: GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public filter(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, T>\n {\n const elements = this._elements;\n\n return new ReducedIterator(function* ()\n {\n for (const [index, [key, element]] of elements.enumerate())\n {\n if (predicate(key, element, index))\n {\n yield [key, element];\n }\n }\n });\n }\n public map<V>(iteratee: KeyIteratee<K, T, V>): ReducedIterator<K, V>\n {\n const elements = this._elements;\n\n return new ReducedIterator(function* ()\n {\n for (const [index, [key, element]] of elements.enumerate())\n {\n yield [key, iteratee(key, element, index)];\n }\n });\n }\n\n public toArray(): T[]\n {\n return Array.from(this.toMap().values());\n }\n public toMap(): Map<K, T>\n {\n return new Map(this._elements.toArray());\n }\n public toObject(): Record<K, T>\n {\n return Object.fromEntries(this._elements.toArray()) as Record<K, T>;\n }\n}\n","import ReducedIterator from \"./reduced-iterator.js\";\nimport SmartIterator from \"../smart-iterator.js\";\n\nimport type { KeyIteratee, KeyReducer } from \"./types.js\";\nimport type { GeneratorFunction } from \"../../types.js\";\n\nexport default class AggregatedIterator<K extends PropertyKey, T>\n{\n protected _elements: SmartIterator<[K, T]>;\n\n public constructor(iterable: Iterable<[K, T]>);\n public constructor(iterator: Iterator<[K, T]>);\n public constructor(generatorFn: GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public every(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, boolean>\n {\n const indexes = new Map<K, [number, boolean]>();\n\n for (const [key, element] of this._elements)\n {\n const [index, result] = indexes.get(key) ?? [0, true];\n\n if (!(result)) { continue; }\n\n indexes.set(key, [index + 1, predicate(key, element, index)]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, result]] of indexes)\n {\n yield [key, result];\n }\n });\n }\n public some(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, boolean>\n {\n const indexes = new Map<K, [number, boolean]>();\n\n for (const [key, element] of this._elements)\n {\n const [index, result] = indexes.get(key) ?? [0, false];\n\n if (result) { continue; }\n\n indexes.set(key, [index + 1, predicate(key, element, index)]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, result]] of indexes)\n {\n yield [key, result];\n }\n });\n }\n\n public filter(predicate: KeyIteratee<K, T, boolean>): AggregatedIterator<K, T>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const indexes = new Map<K, number>();\n\n for (const [key, element] of elements)\n {\n const index = indexes.get(key) ?? 0;\n\n indexes.set(key, index + 1);\n\n if (predicate(key, element, index)) { yield [key, element]; }\n }\n });\n }\n public map<V>(iteratee: KeyIteratee<K, T, V>): AggregatedIterator<K, V>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const indexes = new Map<K, number>();\n\n for (const [key, element] of elements)\n {\n const index = indexes.get(key) ?? 0;\n\n indexes.set(key, index + 1);\n\n yield [key, iteratee(key, element, index)];\n }\n });\n }\n public reduce<A>(reducer: KeyReducer<K, T, A>, initialValue?: A): ReducedIterator<K, A>\n {\n const accumulators = new Map<K, [number, A]>();\n\n for (const [key, element] of this._elements)\n {\n let index: number;\n let accumulator: A;\n\n if (accumulators.has(key))\n {\n [index, accumulator] = accumulators.get(key)!;\n\n index += 1;\n }\n else if (initialValue !== undefined)\n {\n index = 0;\n accumulator = initialValue;\n }\n else\n {\n accumulators.set(key, [0, (element as unknown) as A]);\n\n continue;\n }\n\n accumulator = reducer(key, accumulator, element, index);\n\n accumulators.set(key, [index, accumulator]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, accumulator]] of accumulators)\n {\n yield [key, accumulator];\n }\n });\n }\n\n public unique(): AggregatedIterator<K, T>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const keys = new Map<K, Set<T>>();\n\n for (const [key, element] of elements)\n {\n const values = keys.get(key) ?? new Set<T>();\n\n if (values.has(element)) { continue; }\n\n values.add(element);\n keys.set(key, values);\n\n yield [key, element];\n }\n });\n }\n\n public count(): ReducedIterator<K, number>\n {\n const counters = new Map<K, number>();\n\n for (const [key] of this._elements)\n {\n const count = counters.get(key) ?? 0;\n\n counters.set(key, count + 1);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, count] of counters)\n {\n yield [key, count];\n }\n });\n }\n public first(): ReducedIterator<K, T>\n {\n const firsts = new Map<K, T>();\n\n for (const [key, element] of this._elements)\n {\n if (firsts.has(key)) { continue; }\n\n firsts.set(key, element);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, element] of firsts)\n {\n yield [key, element];\n }\n });\n }\n public last(): ReducedIterator<K, T>\n {\n const lasts = new Map<K, T>();\n\n for (const [key, element] of this._elements)\n {\n lasts.set(key, element);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, element] of lasts)\n {\n yield [key, element];\n }\n });\n }\n\n public toArray(): T[][]\n {\n return Array.from(this.toMap().values());\n }\n public toMap(): Map<K, T[]>\n {\n const groups = new Map<K, T[]>();\n\n for (const [key, element] of this._elements)\n {\n const value = groups.get(key) ?? [];\n\n value.push(element);\n groups.set(key, value);\n }\n\n return groups;\n }\n public toObject(): Record<K, T[]>\n {\n const groups = { } as Record<K, T[]>;\n\n for (const [key, element] of this._elements)\n {\n const value = groups[key] ?? [];\n\n value.push(element);\n groups[key] = value;\n }\n\n return groups;\n }\n}\n","import AggregatedIterator from \"./aggregated-iterator.js\";\nimport ReducedIterator from \"./reduced-iterator.js\";\nimport SmartIterator from \"../smart-iterator.js\";\n\nimport type { GeneratorFunction, Iteratee } from \"../../types.js\";\n\nexport default class Aggregator<T>\n{\n protected _elements: SmartIterator<T>;\n\n public constructor(iterable: Iterable<T>);\n public constructor(iterator: Iterator<T>);\n public constructor(generatorFn: GeneratorFunction<T>);\n public constructor(argument: Iterable<T> | Iterator<T> | GeneratorFunction<T>);\n public constructor(argument: Iterable<T> | Iterator<T> | GeneratorFunction<T>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public filter(predicate: Iteratee<T, boolean>): Aggregator<T>\n {\n return new Aggregator(this._elements.filter(predicate));\n }\n public map<V>(iteratee: Iteratee<T, V>): Aggregator<V>\n {\n return new Aggregator(this._elements.map(iteratee));\n }\n\n public unique(): Aggregator<T>\n {\n return new Aggregator(this._elements.unique());\n }\n\n public byKey<K extends PropertyKey>(iteratee: Iteratee<T, K>): AggregatedIterator<K, T>\n {\n return new AggregatedIterator(this._elements.map((element, index) =>\n {\n const key = iteratee(element, index);\n\n return [key, element];\n }));\n }\n}\n\nexport { AggregatedIterator, ReducedIterator };\n","/* eslint-disable no-trailing-spaces */\n\n/**\n * A wrapper around the `Storage` API to store and retrieve JSON values.\n *\n * It allows to handle either the `sessionStorage` or the `localStorage`\n * storage at the same time, depending on the required use case.\n */\nexport default class JsonStorage\n{\n protected _preferPersistence: boolean;\n\n protected _volatile: Storage;\n protected _persistent: Storage;\n\n public constructor(preferPersistence = true)\n {\n this._preferPersistence = preferPersistence;\n\n this._volatile = window.sessionStorage;\n this._persistent = window.localStorage;\n }\n\n protected _get<T>(storage: Storage, propertyName: string): T | undefined;\n protected _get<T>(storage: Storage, propertyName: string, defaultValue: T): T;\n protected _get<T>(storage: Storage, propertyName: string, defaultValue?: T): T | undefined;\n protected _get<T>(storage: Storage, propertyName: string, defaultValue?: T): T | undefined\n {\n const propertyValue = storage.getItem(propertyName);\n if (propertyValue)\n {\n try\n {\n return JSON.parse(propertyValue);\n }\n catch (error)\n {\n // eslint-disable-next-line no-console\n console.warn(\n `The \"${propertyValue}\" value for \"${propertyName}\"` +\n \" property cannot be parsed. Clearing the storage...\");\n\n storage.removeItem(propertyName);\n }\n }\n\n return defaultValue;\n }\n protected _set<T>(storage: Storage, propertyName: string, newValue?: T): void\n {\n const encodedValue = JSON.stringify(newValue);\n if (encodedValue)\n {\n storage.setItem(propertyName, encodedValue);\n }\n else\n {\n storage.removeItem(propertyName);\n }\n }\n\n /**\n * Retrieves the value with the specified name from the corresponding storage.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n * @param persistent Whether to use the persistent `localStorage` or the volatile `sessionStorage`.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public get<T>(propertyName: string, defaultValue: undefined, persistent?: boolean): T | undefined;\n public get<T>(propertyName: string, defaultValue: T, persistent?: boolean): T ;\n public get<T>(propertyName: string, defaultValue?: T, persistent?: boolean): T | undefined;\n public get<T>(propertyName: string, defaultValue?: T, persistent = this._preferPersistence): T | undefined\n {\n const storage = persistent ? this._persistent : this._volatile;\n\n return this._get<T>(storage, propertyName, defaultValue);\n }\n /**\n * Retrieves the value with the specified name from the volatile `sessionStorage`.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public recall<T>(propertyName: string): T | undefined;\n public recall<T>(propertyName: string, defaultValue: T): T;\n public recall<T>(propertyName: string, defaultValue?: T): T | undefined;\n public recall<T>(propertyName: string, defaultValue?: T): T | undefined\n {\n return this._get<T>(this._volatile, propertyName, defaultValue);\n }\n /**\n * Retrieves the value with the specified name looking first in the\n * volatile `sessionStorage` and then in the persistent `localStorage`.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public retrieve<T>(propertyName: string): T | undefined;\n public retrieve<T>(propertyName: string, defaultValue: T): T;\n public retrieve<T>(propertyName: string, defaultValue?: T): T | undefined;\n public retrieve<T>(propertyName: string, defaultValue?: T): T | undefined\n {\n return this.recall<T>(propertyName) ?? this.read<T>(propertyName, defaultValue);\n }\n /**\n * Retrieves the value with the specified name from the persistent `localStorage`.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public read<T>(propertyName: string): T | undefined;\n public read<T>(propertyName: string, defaultValue: T): T;\n public read<T>(propertyName: string, defaultValue?: T): T | undefined;\n public read<T>(propertyName: string, defaultValue?: T): T | undefined\n {\n return this._get<T>(this._persistent, propertyName, defaultValue);\n }\n\n /**\n * Checks whether the property with the specified name exists in the corresponding storage.\n *\n * @param propertyName The name of the property to check.\n * @param persistent Whether to use the persistent `localStorage` or the volatile `sessionStorage`.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public has(propertyName: string, persistent?: boolean): boolean\n {\n const storage = persistent ? this._persistent : this._volatile;\n\n return storage.getItem(propertyName) !== null;\n }\n /**\n * Checks whether the property with the specified name exists in the volatile `sessionStorage`.\n *\n * @param propertyName The name of the property to check.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public knows(propertyName: string): boolean\n {\n return this._volatile.getItem(propertyName) !== null;\n }\n /**\n * Checks whether the property with the specified name exists looking first in the\n * volatile `sessionStorage` and then in the persistent `localStorage`.\n *\n * @param propertyName The name of the property to check.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public find(propertyName: string): boolean\n {\n return this.knows(propertyName) ?? this.exists(propertyName);\n }\n /**\n * Checks whether the property with the specified name exists in the persistent `localStorage`.\n *\n * @param propertyName The name of the property to check.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public exists(propertyName: string): boolean\n {\n return this._persistent.getItem(propertyName) !== null;\n }\n\n /**\n * Sets the value with the specified name in the corresponding storage.\n * If the value is `undefined`, the property is removed from the storage.\n *\n * @param propertyName The name of the property to set.\n * @param newValue The new value to set.\n * @param persistent Whether to use the persistent `localStorage` or the volatile `sessionStorage`.\n */\n public set<T>(propertyName: string, newValue?: T, persistent = this._preferPersistence): void\n {\n const storage = persistent ? this._persistent : this._volatile;\n\n this._set<T>(storage, propertyName, newValue);\n }\n /**\n * Sets the value with the specified name in the volatile `sessionStorage`.\n * If the value is `undefined`, the property is removed from the storage.\n *\n * @param propertyName The name of the property to set.\n * @param newValue The new value to set.\n */\n public remember<T>(propertyName: string, newValue?: T): void\n {\n this._set<T>(this._volatile, propertyName, newValue);\n }\n /**\n * Sets the value with the specified name in the persistent `localStorage`.\n * If the value is `undefined`, the property is removed from the storage.\n *\n * @param propertyName The name of the property to set.\n * @param newValue The new value to set.\n */\n public write<T>(propertyName: string, newValue?: T): void\n {\n this._set<T>(this._persistent, propertyName, newValue);\n }\n\n /**\n * Removes the value with the specified name from the volatile `sessionStorage`.\n *\n * @param propertyName The name of the property to remove.\n */\n public forget(propertyName: string): void\n {\n this._volatile.removeItem(propertyName);\n }\n /**\n * Removes the value with the specified name from the persistent `localStorage`.\n *\n * @param propertyName The name of the property to remove.\n */\n public erase(propertyName: string): void\n {\n this._persistent.removeItem(propertyName);\n }\n /**\n * Removes the value with the specified name from all the storages.\n *\n * @param propertyName The name of the property to remove.\n */\n public clear(propertyName: string): void\n {\n this._volatile.removeItem(propertyName);\n this._persistent.removeItem(propertyName);\n }\n}\n","import Exception from \"./exception.js\";\n\nexport default class Subscribers<P extends unknown[] = [], R = void, T extends (...args: P) => R = (...args: P) => R>\n{\n protected _subscribers: T[];\n\n public constructor()\n {\n this._subscribers = [];\n }\n\n public add(subscriber: T): void\n {\n this._subscribers.push(subscriber);\n }\n public remove(subscriber: T): void\n {\n const index = this._subscribers.indexOf(subscriber);\n if (index < 0)\n {\n throw new Exception(\"Unable to remove the requested subscriber. It was not found.\");\n }\n\n this._subscribers.splice(index, 1);\n }\n\n public call(...args: P): R[]\n {\n return this._subscribers\n .slice()\n .map((subscriber) => subscriber(...args));\n }\n}\n","import type {\n PromiseResolver,\n PromiseRejecter,\n FulfilledHandler,\n RejectedHandler,\n PromiseExecutor\n\n} from \"../../types.js\";\n\nexport default class DeferredPromise<T = void, E = unknown, F = T, R = never>\n{\n protected _isPending: boolean;\n protected _isFulfilled: boolean;\n protected _isRejected: boolean;\n\n protected _resolve!: PromiseResolver<T>;\n protected _reject!: PromiseRejecter<E>;\n\n protected _promise: Promise<F | R>;\n\n public constructor(onFulfilled?: FulfilledHandler<T, F> | null, onRejected?: RejectedHandler<E, R> | null)\n {\n this._isPending = true;\n this._isFulfilled = false;\n this._isRejected = false;\n\n let _resolve: PromiseResolver<T>;\n let _reject: PromiseRejecter<E>;\n\n const executor: PromiseExecutor<T, E> = (resolve, reject) =>\n {\n _resolve = resolve;\n _reject = reject;\n };\n\n let _onFulfilled: FulfilledHandler<T, F>;\n if (onFulfilled)\n {\n _onFulfilled = (value) =>\n {\n this._isPending = false;\n this._isFulfilled = true;\n\n return onFulfilled!(value);\n };\n }\n else\n {\n _onFulfilled = (value) =>\n {\n this._isPending = false;\n this._isFulfilled = true;\n\n return (value as unknown) as F;\n };\n }\n\n let _onRejected: RejectedHandler<E, R>;\n if (onRejected)\n {\n _onRejected = (reason) =>\n {\n this._isPending = false;\n this._isRejected = true;\n\n return onRejected!(reason);\n };\n }\n else\n {\n _onRejected = (reason) =>\n {\n this._isPending = false;\n this._isRejected = true;\n\n return (reason as unknown) as R;\n };\n }\n\n this._promise = new Promise<T>(executor)\n .then(_onFulfilled, _onRejected);\n\n this._resolve = _resolve!;\n this._reject = _reject!;\n }\n\n public get isPending(): boolean { return this._isPending; }\n public get isFulfilled(): boolean { return this._isFulfilled; }\n public get isRejected(): boolean { return this._isRejected; }\n\n public get resolve(): PromiseResolver<T> { return this._resolve; }\n public get reject(): PromiseRejecter<E> { return this._reject; }\n\n public then<N = F | R, H = R>(\n onFulfilled?: FulfilledHandler<F | R, N> | null,\n onRejected?: RejectedHandler<R, H> | null): Promise<N | H>\n {\n return this._promise.then(onFulfilled, onRejected);\n }\n public catch<H = R>(onRejected?: RejectedHandler<R, H> | null): Promise<F | R | H>\n {\n return this._promise.catch(onRejected);\n }\n public finally(onFinally?: (() => void) | null): Promise<F | R>\n {\n return this._promise.finally(onFinally);\n }\n\n public watch(promise: Promise<T>): this\n {\n promise.then(this.resolve, this.reject);\n\n return this;\n }\n\n public get [Symbol.toStringTag]() { return \"DeferredPromise\"; }\n}\n","import type { FulfilledHandler, PromiseExecutor, RejectedHandler } from \"../../types.js\";\n\nexport default class SmartPromise<T = void, E = unknown>\n{\n protected _isPending: boolean;\n protected _isFulfilled: boolean;\n protected _isRejected: boolean;\n\n protected _promise: Promise<T | E>;\n\n public constructor(executor: PromiseExecutor<T, E>)\n {\n this._isPending = true;\n this._isFulfilled = false;\n this._isRejected = false;\n\n const _resolve = (result: T): T =>\n {\n this._isPending = false;\n this._isFulfilled = true;\n\n return result;\n };\n const _reject = (reason: E): E =>\n {\n this._isPending = false;\n this._isRejected = true;\n\n return reason;\n };\n\n this._promise = new Promise<T>(executor)\n .then(_resolve, _reject);\n }\n\n public get isPending(): boolean { return this._isPending; }\n public get isFulfilled(): boolean { return this._isFulfilled; }\n public get isRejected(): boolean { return this._isRejected; }\n\n public then<F = T, R = E>(\n onFulfilled?: FulfilledHandler<T | E, F> | null,\n onRejected?: RejectedHandler<E, R> | null): Promise<F | R>\n {\n return this._promise.then(onFulfilled, onRejected);\n }\n public catch<R = E>(onRejected?: RejectedHandler<E, R> | null): Promise<T | E | R>\n {\n return this._promise.catch(onRejected);\n }\n public finally(onFinally?: (() => void) | null): Promise<T | E>\n {\n return this._promise.finally(onFinally);\n }\n\n public get [Symbol.toStringTag]() { return \"SmartPromise\"; }\n}\n","export default class Random\n{\n public static Boolean(ratio: number = 0.5): boolean\n {\n return (Math.random() < ratio);\n }\n\n public static Integer(max: number): number;\n public static Integer(min: number, max: number): number;\n public static Integer(min: number, max?: number): number\n {\n if (max === undefined)\n {\n return Math.floor(Math.random() * min);\n }\n\n return Math.floor(Math.random() * (max - min) + min);\n }\n\n public static Decimal(max: number): number;\n public static Decimal(min: number, max: number): number;\n public static Decimal(min: number, max?: number): number\n {\n if (max === undefined)\n {\n return (Math.random() * min);\n }\n\n return (Math.random() * (max - min) + min);\n }\n\n public static Choice<T>(elements: T[]): T\n {\n return elements[this.Integer(elements.length)];\n }\n\n // eslint-disable-next-line no-useless-constructor\n private constructor() { }\n}\n","export async function delay(milliseconds: number): Promise<void>\n{\n return new Promise<void>((resolve, reject) => setTimeout(resolve, milliseconds));\n}\n\nexport async function nextAnimationFrame(): Promise<void>\n{\n return new Promise<void>((resolve, reject) => requestAnimationFrame(() => resolve()));\n}\n","import { SmartIterator } from \"../models/index.js\";\n\nexport enum DateUnit\n{\n Second = 1000,\n Minute = 60 * Second,\n Hour = 60 * Minute,\n Day = 24 * Hour,\n Week = 7 * Day,\n Month = 30 * Day,\n Year = 365 * Day\n}\n\nexport function dateDifference(start: Date, end: Date, unit = DateUnit.Day): number\n{\n return Math.floor((end.getTime() - start.getTime()) / unit);\n}\n\nexport function dateRange(start: Date, end: Date, offset = DateUnit.Day): SmartIterator<Date>\n{\n return new SmartIterator<Date>(function* ()\n {\n const endTime = end.getTime();\n\n let unixTime: number = start.getTime();\n while (unixTime < endTime)\n {\n yield new Date(unixTime);\n\n unixTime += offset;\n }\n });\n}\n\nexport function dateRound(date: Date, unit = DateUnit.Day): Date\n{\n return new Date(Math.floor(date.getTime() / unit) * unit);\n}\n","export async function loadScript(scriptUrl: string, scriptType = \"text/javascript\"): Promise<void>\n{\n return new Promise<void>((resolve, reject) =>\n {\n const script = document.createElement(\"script\");\n\n script.async = true;\n script.defer = true;\n script.src = scriptUrl;\n script.type = scriptType;\n\n script.onload = () => resolve();\n script.onerror = () => reject();\n\n document.body.appendChild(script);\n });\n}\n","import { SmartIterator } from \"../models/index.js\";\n\nexport function count<T>(elements: Iterable<T>): number\n{\n if (Array.isArray(elements)) { return elements.length; }\n\n let _count = 0;\n for (const _ of elements) { _count += 1; }\n\n return _count;\n}\n\nexport function enumerate<T>(elements: Iterable<T>): SmartIterator<[number, T]>\n{\n return new SmartIterator<[number, T]>(function* ()\n {\n let index = 0;\n\n for (const element of elements)\n {\n yield [index, element];\n\n index += 1;\n }\n });\n}\n\nexport function range(end: number): SmartIterator<number>;\nexport function range(start: number, end: number): SmartIterator<number>;\nexport function range(start: number, end: number, step: number): SmartIterator<number>;\nexport function range(start: number, end?: number, step = 1): SmartIterator<number>\n{\n return new SmartIterator<number>(function* ()\n {\n if (end === undefined)\n {\n end = start;\n start = 0;\n }\n\n if (start > end) { step = step ?? -1; }\n\n for (let index = start; index < end; index += step) { yield index; }\n });\n}\n\nexport function shuffle<T>(iterable: Iterable<T>): T[]\n{\n const array = Array.from(iterable);\n\n for (let index = array.length - 1; index > 0; index -= 1)\n {\n const jndex = Math.floor(Math.random() * (index + 1));\n\n [array[index], array[jndex]] = [array[jndex], array[index]];\n }\n\n return array;\n}\n\nexport function unique<T>(elements: Iterable<T>): SmartIterator<T>\n{\n return new SmartIterator<T>(function* ()\n {\n const values = new Set<T>();\n\n for (const element of elements)\n {\n if (values.has(element)) { continue; }\n\n values.add(element);\n\n yield element;\n }\n });\n}\n\nexport function zip<T, U>(first: Iterable<T>, second: Iterable<U>): SmartIterator<[T, U]>\n{\n return new SmartIterator<[T, U]>(function* ()\n {\n const firstIterator = first[Symbol.iterator]();\n const secondIterator = second[Symbol.iterator]();\n\n while (true)\n {\n const firstResult = firstIterator.next();\n const secondResult = secondIterator.next();\n\n if ((firstResult.done) || (secondResult.done)) { break; }\n\n yield [firstResult.value, secondResult.value];\n }\n });\n}\n","import { zip } from \"./iterator.js\";\n\nexport function average<T extends number>(values: Iterable<T>): number;\nexport function average<T extends number>(values: Iterable<T>, weights: Iterable<number>): number;\nexport function average<T extends number>(values: Iterable<T>, weights?: Iterable<number>): number\n{\n if (weights === undefined)\n {\n let _sum = 0;\n let _count = 0;\n\n for (const value of values)\n {\n _sum += value;\n _count += 1;\n }\n\n return _sum / _count;\n }\n\n let _sum = 0;\n let _count = 0;\n\n for (const [value, weight] of zip(values, weights))\n {\n _sum += value * weight;\n _count += weight;\n }\n\n return _sum / _count;\n}\n\nexport function hash(value: string): number\n{\n let hashedValue = 0;\n for (let index = 0; index < value.length; index += 1)\n {\n const char = value.charCodeAt(index);\n\n hashedValue = ((hashedValue << 5) - hashedValue) + char;\n hashedValue |= 0;\n }\n\n return hashedValue;\n}\n\nexport function sum<T extends number>(values: Iterable<T>): number\n{\n let _sum = 0;\n for (const value of values) { _sum += value; }\n\n return _sum;\n}\n","export function capitalize(value: string): string\n{\n return `${value.charAt(0).toUpperCase()}${value.slice(1)}`;\n}\n","export const VERSION = \"1.3.3\";\n\nexport {\n AggregatedIterator,\n Aggregator,\n DeferredPromise,\n Exception,\n JsonStorage,\n ReducedIterator,\n SmartIterator,\n SmartPromise,\n Subscribers\n\n} from \"./models/index.js\";\n\nexport {\n average,\n capitalize,\n count,\n delay,\n dateDifference,\n dateRange,\n dateRound,\n DateUnit,\n hash,\n loadScript,\n nextAnimationFrame,\n Random,\n range,\n shuffle,\n sum,\n unique,\n zip\n\n} from \"./utils/index.js\";\n\nexport type {\n Constructor,\n FulfilledHandler,\n GeneratorFunction,\n Interval,\n Iteratee,\n MaybePromise,\n PromiseExecutor,\n PromiseRejecter,\n PromiseResolver,\n Reducer,\n RejectedHandler,\n Timeout\n\n} from \"./types.js\";\n"],"names":["Exception","error","exc","message","cause","name","SmartIterator","argument","__publicField","value","predicate","index","result","iterator","iteratee","reducer","initialValue","accumulator","values","ReducedIterator","elements","key","element","AggregatedIterator","indexes","_","accumulators","keys","counters","count","firsts","lasts","groups","Aggregator","JsonStorage","preferPersistence","storage","propertyName","defaultValue","propertyValue","newValue","encodedValue","persistent","Subscribers","subscriber","args","DeferredPromise","onFulfilled","onRejected","_resolve","_reject","executor","resolve","reject","_onFulfilled","_onRejected","reason","onFinally","promise","SmartPromise","Random","ratio","min","max","delay","milliseconds","nextAnimationFrame","DateUnit","dateDifference","start","end","unit","dateRange","offset","endTime","unixTime","dateRound","date","loadScript","scriptUrl","scriptType","script","_count","range","step","shuffle","iterable","array","jndex","unique","zip","first","second","firstIterator","secondIterator","firstResult","secondResult","average","weights","_sum","weight","hash","hashedValue","char","sum","capitalize","VERSION"],"mappings":";;;AAAA,MAAqBA,UAAkB,MACvC;A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IAAS;AAEb,aAAW,CAACzE,GAAO2F,CAAM,KAAKV,EAAIxE,GAAQgF,CAAO;AAE7C,IAAAC,KAAQ1F,IAAQ2F,GACNlB,KAAAkB;AAGd,SAAOD,IAAOjB;AAClB;AAEO,SAASmB,EAAK5F,GACrB;AACI,MAAI6F,IAAc;AAClB,WAAS3F,IAAQ,GAAGA,IAAQF,EAAM,QAAQE,KAAS,GACnD;AACU,UAAA4F,IAAO9F,EAAM,WAAWE,CAAK;AAEnB,IAAA2F,KAAAA,KAAe,KAAKA,IAAeC,GACpCD,KAAA;AAAA,EACnB;AAEO,SAAAA;AACX;AAEO,SAASE,EAAsBtF,GACtC;AACI,MAAIiF,IAAO;AACX,aAAW1F,KAASS;AAAkB,IAAAiF,KAAA1F;AAE/B,SAAA0F;AACX;ACpDO,SAASM,EAAWhG,GAC3B;AACW,SAAA,GAAGA,EAAM,OAAO,CAAC,EAAE,aAAa,GAAGA,EAAM,MAAM,CAAC,CAAC;AAC5D;ACHO,MAAMiG,IAAU;"}
1
+ {"version":3,"file":"core.js","sources":["../src/models/exception.ts","../src/models/smart-iterator.ts","../src/models/aggregators/reduced-iterator.ts","../src/models/aggregators/aggregated-iterator.ts","../src/models/aggregators/index.ts","../src/models/json-storage.ts","../src/models/subscribers.ts","../src/models/promises/deferred-promise.ts","../src/models/promises/smart-promise.ts","../src/utils/random.ts","../src/utils/async.ts","../src/utils/date.ts","../src/utils/dom.ts","../src/utils/iterator.ts","../src/utils/math.ts","../src/utils/string.ts","../src/index.ts"],"sourcesContent":["export default class Exception extends Error\n{\n public static FromUnknown(error: unknown): Exception\n {\n if (error instanceof Exception)\n {\n return error;\n }\n if (error instanceof Error)\n {\n const exc = new Exception(error.message);\n\n exc.stack = error.stack;\n exc.name = error.name;\n\n return exc;\n }\n\n return new Exception(`${error}`);\n }\n\n public constructor(message: string, cause?: unknown, name = \"Exception\")\n {\n super(message);\n\n this.cause = cause;\n this.name = name;\n\n if (cause)\n {\n if (cause instanceof Error)\n {\n this.stack += `\\n\\nCaused by ${cause.stack}`;\n }\n else\n {\n this.stack += `\\n\\nCaused by ${cause}`;\n }\n }\n }\n\n public get [Symbol.toStringTag]() { return \"Exception\"; }\n}\n","import type { GeneratorFunction, Iteratee, Reducer } from \"../types.js\";\n\nexport default class SmartIterator<T, R = void, N = undefined> implements Iterator<T, R, N>\n{\n protected _iterator: Iterator<T, R, N>;\n\n public return?: (value?: R) => IteratorResult<T, R>;\n public throw?: (error?: unknown) => IteratorResult<T, R>;\n\n public constructor(iterable: Iterable<T>);\n public constructor(iterator: Iterator<T, R, N>);\n public constructor(generatorFn: GeneratorFunction<T, R, N>);\n public constructor(argument: Iterable<T> | Iterator<T, R, N> | GeneratorFunction<T, R, N>);\n public constructor(argument: Iterable<T> | Iterator<T, R, N> | GeneratorFunction<T, R, N>)\n {\n if (argument instanceof Function)\n {\n this._iterator = argument();\n }\n else if (Symbol.iterator in argument)\n {\n this._iterator = argument[Symbol.iterator]() as Iterator<T, R, N>;\n }\n else\n {\n this._iterator = argument;\n }\n\n if (this._iterator.return) { this.return = (value?: R) => this._iterator.return!(value); }\n if (this._iterator.throw) { this.throw = (error?: unknown) => this._iterator.throw!(error); }\n }\n\n public every(predicate: Iteratee<T, boolean>): boolean\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n\n if (result.done) { return true; }\n if (!(predicate(result.value, index))) { return false; }\n\n index += 1;\n }\n }\n public some(predicate: Iteratee<T, boolean>): boolean\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n\n if (result.done) { return false; }\n if (predicate(result.value, index)) { return true; }\n\n index += 1;\n }\n }\n\n public filter(predicate: Iteratee<T, boolean>): SmartIterator<T, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<T, R>(function* ()\n {\n let index = 0;\n\n while (true)\n {\n const result = iterator.next();\n\n if (result.done) { return result.value; }\n if (predicate(result.value, index)) { yield result.value; }\n\n index += 1;\n }\n });\n }\n public map<V>(iteratee: Iteratee<T, V>): SmartIterator<V, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<V, R>(function* ()\n {\n let index = 0;\n\n while (true)\n {\n const result = iterator.next();\n if (result.done) { return result.value; }\n\n yield iteratee(result.value, index);\n\n index += 1;\n }\n });\n }\n public reduce(reducer: Reducer<T, T>): T;\n public reduce<A>(reducer: Reducer<T, A>, initialValue: A): A;\n public reduce<A>(reducer: Reducer<T, A>, initialValue?: A): A\n {\n let index = 0;\n let accumulator = initialValue;\n if (accumulator === undefined)\n {\n const result = this._iterator.next();\n if (result.done) { throw new TypeError(\"Reduce of empty iterator with no initial value\"); }\n\n accumulator = (result.value as unknown) as A;\n index += 1;\n }\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return accumulator; }\n\n accumulator = reducer(accumulator, result.value, index);\n\n index += 1;\n }\n }\n\n public enumerate(): SmartIterator<[number, T], R>\n {\n return this.map((value, index) => [index, value]);\n }\n public unique(): SmartIterator<T, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<T, R>(function* ()\n {\n const values = new Set<T>();\n\n while (true)\n {\n const result = iterator.next();\n\n if (result.done) { return result.value; }\n if (values.has(result.value)) { continue; }\n\n values.add(result.value);\n\n yield result.value;\n }\n });\n }\n\n public count(): number\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return index; }\n\n index += 1;\n }\n }\n public forEach(iteratee: Iteratee<T>): void\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return; }\n\n iteratee(result.value, index);\n\n index += 1;\n }\n }\n\n public next(...values: N extends undefined ? [] : [N]): IteratorResult<T, R>\n {\n return this._iterator.next(...values);\n }\n\n public toArray(): T[]\n {\n return Array.from(this as Iterable<T>);\n }\n\n public get [Symbol.toStringTag]() { return \"SmartIterator\"; }\n\n public [Symbol.iterator](): SmartIterator<T, R, N> { return this; }\n}\n","import SmartIterator from \"../smart-iterator.js\";\n\nimport type { KeyIteratee } from \"./types.js\";\nimport type { GeneratorFunction } from \"../../types.js\";\n\nexport default class ReducedIterator<K extends PropertyKey, T>\n{\n protected _elements: SmartIterator<[K, T]>;\n\n public constructor(iterable: Iterable<[K, T]>);\n public constructor(iterator: Iterator<[K, T]>);\n public constructor(generatorFn: GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public filter(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, T>\n {\n const elements = this._elements;\n\n return new ReducedIterator(function* ()\n {\n for (const [index, [key, element]] of elements.enumerate())\n {\n if (predicate(key, element, index))\n {\n yield [key, element];\n }\n }\n });\n }\n public map<V>(iteratee: KeyIteratee<K, T, V>): ReducedIterator<K, V>\n {\n const elements = this._elements;\n\n return new ReducedIterator(function* ()\n {\n for (const [index, [key, element]] of elements.enumerate())\n {\n yield [key, iteratee(key, element, index)];\n }\n });\n }\n\n public keys(): SmartIterator<K>\n {\n const elements = this._elements;\n\n return new SmartIterator<K>(function* ()\n {\n for (const [key] of elements)\n {\n yield key;\n }\n });\n }\n public items(): SmartIterator<[K, T]>\n {\n return this._elements;\n }\n public values(): SmartIterator<T>\n {\n const elements = this._elements;\n\n return new SmartIterator<T>(function* ()\n {\n for (const [_, element] of elements)\n {\n yield element;\n }\n });\n }\n\n public toArray(): T[]\n {\n return Array.from(this.values());\n }\n public toMap(): Map<K, T>\n {\n return new Map(this.items());\n }\n public toObject(): Record<K, T>\n {\n return Object.fromEntries(this.items()) as Record<K, T>;\n }\n\n public get [Symbol.toStringTag]() { return \"ReducedIterator\"; }\n}\n","import ReducedIterator from \"./reduced-iterator.js\";\nimport SmartIterator from \"../smart-iterator.js\";\n\nimport type { KeyIteratee, KeyReducer } from \"./types.js\";\nimport type { GeneratorFunction } from \"../../types.js\";\n\nexport default class AggregatedIterator<K extends PropertyKey, T>\n{\n protected _elements: SmartIterator<[K, T]>;\n\n public constructor(iterable: Iterable<[K, T]>);\n public constructor(iterator: Iterator<[K, T]>);\n public constructor(generatorFn: GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public every(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, boolean>\n {\n const indexes = new Map<K, [number, boolean]>();\n\n for (const [key, element] of this._elements)\n {\n const [index, result] = indexes.get(key) ?? [0, true];\n\n if (!(result)) { continue; }\n\n indexes.set(key, [index + 1, predicate(key, element, index)]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, result]] of indexes)\n {\n yield [key, result];\n }\n });\n }\n public some(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, boolean>\n {\n const indexes = new Map<K, [number, boolean]>();\n\n for (const [key, element] of this._elements)\n {\n const [index, result] = indexes.get(key) ?? [0, false];\n\n if (result) { continue; }\n\n indexes.set(key, [index + 1, predicate(key, element, index)]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, result]] of indexes)\n {\n yield [key, result];\n }\n });\n }\n\n public filter(predicate: KeyIteratee<K, T, boolean>): AggregatedIterator<K, T>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const indexes = new Map<K, number>();\n\n for (const [key, element] of elements)\n {\n const index = indexes.get(key) ?? 0;\n\n indexes.set(key, index + 1);\n\n if (predicate(key, element, index)) { yield [key, element]; }\n }\n });\n }\n public map<V>(iteratee: KeyIteratee<K, T, V>): AggregatedIterator<K, V>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const indexes = new Map<K, number>();\n\n for (const [key, element] of elements)\n {\n const index = indexes.get(key) ?? 0;\n\n indexes.set(key, index + 1);\n\n yield [key, iteratee(key, element, index)];\n }\n });\n }\n public reduce(reducer: KeyReducer<K, T, T>): ReducedIterator<K, T>;\n public reduce<A>(reducer: KeyReducer<K, T, A>, initialValue: (key: K) => A): ReducedIterator<K, A>;\n public reduce<A>(reducer: KeyReducer<K, T, A>, initialValue?: (key: K) => A): ReducedIterator<K, A>\n {\n const accumulators = new Map<K, [number, A]>();\n\n for (const [key, element] of this._elements)\n {\n let index: number;\n let accumulator: A;\n\n if (accumulators.has(key))\n {\n [index, accumulator] = accumulators.get(key)!;\n\n index += 1;\n }\n else if (initialValue !== undefined)\n {\n index = 0;\n accumulator = initialValue(key);\n }\n else\n {\n accumulators.set(key, [0, (element as unknown) as A]);\n\n continue;\n }\n\n accumulator = reducer(key, accumulator, element, index);\n\n accumulators.set(key, [index, accumulator]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, accumulator]] of accumulators)\n {\n yield [key, accumulator];\n }\n });\n }\n\n public unique(): AggregatedIterator<K, T>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const keys = new Map<K, Set<T>>();\n\n for (const [key, element] of elements)\n {\n const values = keys.get(key) ?? new Set<T>();\n\n if (values.has(element)) { continue; }\n\n values.add(element);\n keys.set(key, values);\n\n yield [key, element];\n }\n });\n }\n\n public count(): ReducedIterator<K, number>\n {\n const counters = new Map<K, number>();\n\n for (const [key] of this._elements)\n {\n const count = counters.get(key) ?? 0;\n\n counters.set(key, count + 1);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, count] of counters)\n {\n yield [key, count];\n }\n });\n }\n public first(): ReducedIterator<K, T>\n {\n const firsts = new Map<K, T>();\n\n for (const [key, element] of this._elements)\n {\n if (firsts.has(key)) { continue; }\n\n firsts.set(key, element);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, element] of firsts)\n {\n yield [key, element];\n }\n });\n }\n public last(): ReducedIterator<K, T>\n {\n const lasts = new Map<K, T>();\n\n for (const [key, element] of this._elements)\n {\n lasts.set(key, element);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, element] of lasts)\n {\n yield [key, element];\n }\n });\n }\n\n public keys(): SmartIterator<K>\n {\n const elements = this._elements;\n\n return new SmartIterator<K>(function* ()\n {\n for (const [key] of elements)\n {\n yield key;\n }\n });\n }\n public items(): SmartIterator<[K, T]>\n {\n return this._elements;\n }\n public values(): SmartIterator<T>\n {\n const elements = this._elements;\n\n return new SmartIterator<T>(function* ()\n {\n for (const [_, element] of elements)\n {\n yield element;\n }\n });\n }\n\n public toArray(): T[][]\n {\n return Array.from(this.toMap().values());\n }\n public toMap(): Map<K, T[]>\n {\n const groups = new Map<K, T[]>();\n\n for (const [key, element] of this._elements)\n {\n const value = groups.get(key) ?? [];\n\n value.push(element);\n groups.set(key, value);\n }\n\n return groups;\n }\n public toObject(): Record<K, T[]>\n {\n const groups = { } as Record<K, T[]>;\n\n for (const [key, element] of this._elements)\n {\n const value = groups[key] ?? [];\n\n value.push(element);\n groups[key] = value;\n }\n\n return groups;\n }\n\n public get [Symbol.toStringTag]() { return \"AggregatedIterator\"; }\n}\n","import AggregatedIterator from \"./aggregated-iterator.js\";\nimport ReducedIterator from \"./reduced-iterator.js\";\nimport SmartIterator from \"../smart-iterator.js\";\n\nimport type { GeneratorFunction, Iteratee } 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 groupBy<K extends PropertyKey>(iteratee: Iteratee<T, K>): AggregatedIterator<K, T>\n {\n return new AggregatedIterator(this._elements.map((element, index) =>\n {\n const key = iteratee(element, index);\n\n return [key, element];\n }));\n }\n\n public get [Symbol.toStringTag]() { return \"Aggregator\"; }\n}\n\nexport { AggregatedIterator, ReducedIterator };\n","/* eslint-disable no-trailing-spaces */\n\n/**\n * A wrapper around the `Storage` API to store and retrieve JSON values.\n *\n * It allows to handle either the `sessionStorage` or the `localStorage`\n * storage at the same time, depending on the required use case.\n */\nexport default class JsonStorage\n{\n protected _preferPersistence: boolean;\n\n protected _volatile: Storage;\n protected _persistent: Storage;\n\n public constructor(preferPersistence = true)\n {\n this._preferPersistence = preferPersistence;\n\n this._volatile = window.sessionStorage;\n this._persistent = window.localStorage;\n }\n\n protected _get<T>(storage: Storage, propertyName: string): T | undefined;\n protected _get<T>(storage: Storage, propertyName: string, defaultValue: T): T;\n protected _get<T>(storage: Storage, propertyName: string, defaultValue?: T): T | undefined;\n protected _get<T>(storage: Storage, propertyName: string, defaultValue?: T): T | undefined\n {\n const propertyValue = storage.getItem(propertyName);\n if (propertyValue)\n {\n try\n {\n return JSON.parse(propertyValue);\n }\n catch (error)\n {\n // eslint-disable-next-line no-console\n console.warn(\n `The \"${propertyValue}\" value for \"${propertyName}\"` +\n \" property cannot be parsed. Clearing the storage...\");\n\n storage.removeItem(propertyName);\n }\n }\n\n return defaultValue;\n }\n protected _set<T>(storage: Storage, propertyName: string, newValue?: T): void\n {\n const encodedValue = JSON.stringify(newValue);\n if (encodedValue)\n {\n storage.setItem(propertyName, encodedValue);\n }\n else\n {\n storage.removeItem(propertyName);\n }\n }\n\n /**\n * Retrieves the value with the specified name from the corresponding storage.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n * @param persistent Whether to use the persistent `localStorage` or the volatile `sessionStorage`.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public get<T>(propertyName: string, defaultValue: undefined, persistent?: boolean): T | undefined;\n public get<T>(propertyName: string, defaultValue: T, persistent?: boolean): T ;\n public get<T>(propertyName: string, defaultValue?: T, persistent?: boolean): T | undefined;\n public get<T>(propertyName: string, defaultValue?: T, persistent = this._preferPersistence): T | undefined\n {\n const storage = persistent ? this._persistent : this._volatile;\n\n return this._get<T>(storage, propertyName, defaultValue);\n }\n /**\n * Retrieves the value with the specified name from the volatile `sessionStorage`.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public recall<T>(propertyName: string): T | undefined;\n public recall<T>(propertyName: string, defaultValue: T): T;\n public recall<T>(propertyName: string, defaultValue?: T): T | undefined;\n public recall<T>(propertyName: string, defaultValue?: T): T | undefined\n {\n return this._get<T>(this._volatile, propertyName, defaultValue);\n }\n /**\n * Retrieves the value with the specified name looking first in the\n * volatile `sessionStorage` and then in the persistent `localStorage`.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public retrieve<T>(propertyName: string): T | undefined;\n public retrieve<T>(propertyName: string, defaultValue: T): T;\n public retrieve<T>(propertyName: string, defaultValue?: T): T | undefined;\n public retrieve<T>(propertyName: string, defaultValue?: T): T | undefined\n {\n return this.recall<T>(propertyName) ?? this.read<T>(propertyName, defaultValue);\n }\n /**\n * Retrieves the value with the specified name from the persistent `localStorage`.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public read<T>(propertyName: string): T | undefined;\n public read<T>(propertyName: string, defaultValue: T): T;\n public read<T>(propertyName: string, defaultValue?: T): T | undefined;\n public read<T>(propertyName: string, defaultValue?: T): T | undefined\n {\n return this._get<T>(this._persistent, propertyName, defaultValue);\n }\n\n /**\n * Checks whether the property with the specified name exists in the corresponding storage.\n *\n * @param propertyName The name of the property to check.\n * @param persistent Whether to use the persistent `localStorage` or the volatile `sessionStorage`.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public has(propertyName: string, persistent?: boolean): boolean\n {\n const storage = persistent ? this._persistent : this._volatile;\n\n return storage.getItem(propertyName) !== null;\n }\n /**\n * Checks whether the property with the specified name exists in the volatile `sessionStorage`.\n *\n * @param propertyName The name of the property to check.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public knows(propertyName: string): boolean\n {\n return this._volatile.getItem(propertyName) !== null;\n }\n /**\n * Checks whether the property with the specified name exists looking first in the\n * volatile `sessionStorage` and then in the persistent `localStorage`.\n *\n * @param propertyName The name of the property to check.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public find(propertyName: string): boolean\n {\n return this.knows(propertyName) ?? this.exists(propertyName);\n }\n /**\n * Checks whether the property with the specified name exists in the persistent `localStorage`.\n *\n * @param propertyName The name of the property to check.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public exists(propertyName: string): boolean\n {\n return this._persistent.getItem(propertyName) !== null;\n }\n\n /**\n * Sets the value with the specified name in the corresponding storage.\n * If the value is `undefined`, the property is removed from the storage.\n *\n * @param propertyName The name of the property to set.\n * @param newValue The new value to set.\n * @param persistent Whether to use the persistent `localStorage` or the volatile `sessionStorage`.\n */\n public set<T>(propertyName: string, newValue?: T, persistent = this._preferPersistence): void\n {\n const storage = persistent ? this._persistent : this._volatile;\n\n this._set<T>(storage, propertyName, newValue);\n }\n /**\n * Sets the value with the specified name in the volatile `sessionStorage`.\n * If the value is `undefined`, the property is removed from the storage.\n *\n * @param propertyName The name of the property to set.\n * @param newValue The new value to set.\n */\n public remember<T>(propertyName: string, newValue?: T): void\n {\n this._set<T>(this._volatile, propertyName, newValue);\n }\n /**\n * Sets the value with the specified name in the persistent `localStorage`.\n * If the value is `undefined`, the property is removed from the storage.\n *\n * @param propertyName The name of the property to set.\n * @param newValue The new value to set.\n */\n public write<T>(propertyName: string, newValue?: T): void\n {\n this._set<T>(this._persistent, propertyName, newValue);\n }\n\n /**\n * Removes the value with the specified name from the volatile `sessionStorage`.\n *\n * @param propertyName The name of the property to remove.\n */\n public forget(propertyName: string): void\n {\n this._volatile.removeItem(propertyName);\n }\n /**\n * Removes the value with the specified name from the persistent `localStorage`.\n *\n * @param propertyName The name of the property to remove.\n */\n public erase(propertyName: string): void\n {\n this._persistent.removeItem(propertyName);\n }\n /**\n * Removes the value with the specified name from all the storages.\n *\n * @param propertyName The name of the property to remove.\n */\n public clear(propertyName: string): void\n {\n this._volatile.removeItem(propertyName);\n this._persistent.removeItem(propertyName);\n }\n\n public get [Symbol.toStringTag]() { return \"JsonStorage\"; }\n}\n","import Exception from \"./exception.js\";\n\nexport default class Subscribers<P extends unknown[] = [], R = void, T extends (...args: P) => R = (...args: P) => R>\n{\n protected _subscribers: T[];\n\n public constructor()\n {\n this._subscribers = [];\n }\n\n public add(subscriber: T): void\n {\n this._subscribers.push(subscriber);\n }\n public remove(subscriber: T): void\n {\n const index = this._subscribers.indexOf(subscriber);\n if (index < 0)\n {\n throw new Exception(\"Unable to remove the requested subscriber. It was not found.\");\n }\n\n this._subscribers.splice(index, 1);\n }\n\n public call(...args: P): R[]\n {\n return this._subscribers\n .slice()\n .map((subscriber) => subscriber(...args));\n }\n\n public get [Symbol.toStringTag]() { return \"Subscribers\"; }\n}\n","import type {\n PromiseResolver,\n PromiseRejecter,\n FulfilledHandler,\n RejectedHandler,\n PromiseExecutor\n\n} from \"../../types.js\";\n\nexport default class DeferredPromise<T = void, E = unknown, F = T, R = never>\n{\n protected _isPending: boolean;\n protected _isFulfilled: boolean;\n protected _isRejected: boolean;\n\n protected _resolve!: PromiseResolver<T>;\n protected _reject!: PromiseRejecter<E>;\n\n protected _promise: Promise<F | R>;\n\n public constructor(onFulfilled?: FulfilledHandler<T, F> | null, onRejected?: RejectedHandler<E, R> | null)\n {\n this._isPending = true;\n this._isFulfilled = false;\n this._isRejected = false;\n\n let _resolve: PromiseResolver<T>;\n let _reject: PromiseRejecter<E>;\n\n const executor: PromiseExecutor<T, E> = (resolve, reject) =>\n {\n _resolve = resolve;\n _reject = reject;\n };\n\n let _onFulfilled: FulfilledHandler<T, F>;\n if (onFulfilled)\n {\n _onFulfilled = (value) =>\n {\n this._isPending = false;\n this._isFulfilled = true;\n\n return onFulfilled!(value);\n };\n }\n else\n {\n _onFulfilled = (value) =>\n {\n this._isPending = false;\n this._isFulfilled = true;\n\n return (value as unknown) as F;\n };\n }\n\n let _onRejected: RejectedHandler<E, R>;\n if (onRejected)\n {\n _onRejected = (reason) =>\n {\n this._isPending = false;\n this._isRejected = true;\n\n return onRejected!(reason);\n };\n }\n else\n {\n _onRejected = (reason) =>\n {\n this._isPending = false;\n this._isRejected = true;\n\n return (reason as unknown) as R;\n };\n }\n\n this._promise = new Promise<T>(executor)\n .then(_onFulfilled, _onRejected);\n\n this._resolve = _resolve!;\n this._reject = _reject!;\n }\n\n public get isPending(): boolean { return this._isPending; }\n public get isFulfilled(): boolean { return this._isFulfilled; }\n public get isRejected(): boolean { return this._isRejected; }\n\n public get resolve(): PromiseResolver<T> { return this._resolve; }\n public get reject(): PromiseRejecter<E> { return this._reject; }\n\n public then<N = F | R, H = R>(\n onFulfilled?: FulfilledHandler<F | R, N> | null,\n onRejected?: RejectedHandler<R, H> | null): Promise<N | H>\n {\n return this._promise.then(onFulfilled, onRejected);\n }\n public catch<H = R>(onRejected?: RejectedHandler<R, H> | null): Promise<F | R | H>\n {\n return this._promise.catch(onRejected);\n }\n public finally(onFinally?: (() => void) | null): Promise<F | R>\n {\n return this._promise.finally(onFinally);\n }\n\n public watch(promise: Promise<T>): this\n {\n promise.then(this.resolve, this.reject);\n\n return this;\n }\n\n public get [Symbol.toStringTag]() { return \"DeferredPromise\"; }\n}\n","import type { FulfilledHandler, PromiseExecutor, RejectedHandler } from \"../../types.js\";\n\nexport default class SmartPromise<T = void, E = unknown>\n{\n protected _isPending: boolean;\n protected _isFulfilled: boolean;\n protected _isRejected: boolean;\n\n protected _promise: Promise<T | E>;\n\n public constructor(executor: PromiseExecutor<T, E>)\n {\n this._isPending = true;\n this._isFulfilled = false;\n this._isRejected = false;\n\n const _resolve = (result: T): T =>\n {\n this._isPending = false;\n this._isFulfilled = true;\n\n return result;\n };\n const _reject = (reason: E): E =>\n {\n this._isPending = false;\n this._isRejected = true;\n\n return reason;\n };\n\n this._promise = new Promise<T>(executor)\n .then(_resolve, _reject);\n }\n\n public get isPending(): boolean { return this._isPending; }\n public get isFulfilled(): boolean { return this._isFulfilled; }\n public get isRejected(): boolean { return this._isRejected; }\n\n public then<F = T, R = E>(\n onFulfilled?: FulfilledHandler<T | E, F> | null,\n onRejected?: RejectedHandler<E, R> | null): Promise<F | R>\n {\n return this._promise.then(onFulfilled, onRejected);\n }\n public catch<R = E>(onRejected?: RejectedHandler<E, R> | null): Promise<T | E | R>\n {\n return this._promise.catch(onRejected);\n }\n public finally(onFinally?: (() => void) | null): Promise<T | E>\n {\n return this._promise.finally(onFinally);\n }\n\n public get [Symbol.toStringTag]() { return \"SmartPromise\"; }\n}\n","export default class Random\n{\n public static Boolean(ratio: number = 0.5): boolean\n {\n return (Math.random() < ratio);\n }\n\n public static Integer(max: number): number;\n public static Integer(min: number, max: number): number;\n public static Integer(min: number, max?: number): number\n {\n if (max === undefined)\n {\n return Math.floor(Math.random() * min);\n }\n\n return Math.floor(Math.random() * (max - min) + min);\n }\n\n public static Decimal(max: number): number;\n public static Decimal(min: number, max: number): number;\n public static Decimal(min: number, max?: number): number\n {\n if (max === undefined)\n {\n return (Math.random() * min);\n }\n\n return (Math.random() * (max - min) + min);\n }\n\n public static Choice<T>(elements: T[]): T\n {\n return elements[this.Integer(elements.length)];\n }\n\n // eslint-disable-next-line no-useless-constructor\n private constructor() { }\n}\n","export async function delay(milliseconds: number): Promise<void>\n{\n return new Promise<void>((resolve, reject) => setTimeout(resolve, milliseconds));\n}\n\nexport async function nextAnimationFrame(): Promise<void>\n{\n return new Promise<void>((resolve, reject) => requestAnimationFrame(() => resolve()));\n}\n","import { SmartIterator } from \"../models/index.js\";\n\nexport enum DateUnit\n{\n Second = 1000,\n Minute = 60 * Second,\n Hour = 60 * Minute,\n Day = 24 * Hour,\n Week = 7 * Day,\n Month = 30 * Day,\n Year = 365 * Day\n}\n\nexport function dateDifference(start: Date, end: Date, unit = DateUnit.Day): number\n{\n return Math.floor((end.getTime() - start.getTime()) / unit);\n}\n\nexport function dateRange(start: Date, end: Date, offset = DateUnit.Day): SmartIterator<Date>\n{\n return new SmartIterator<Date>(function* ()\n {\n const endTime = end.getTime();\n\n let unixTime: number = start.getTime();\n while (unixTime < endTime)\n {\n yield new Date(unixTime);\n\n unixTime += offset;\n }\n });\n}\n\nexport function dateRound(date: Date, unit = DateUnit.Day): Date\n{\n return new Date(Math.floor(date.getTime() / unit) * unit);\n}\n","export async function loadScript(scriptUrl: string, scriptType = \"text/javascript\"): Promise<void>\n{\n return new Promise<void>((resolve, reject) =>\n {\n const script = document.createElement(\"script\");\n\n script.async = true;\n script.defer = true;\n script.src = scriptUrl;\n script.type = scriptType;\n\n script.onload = () => resolve();\n script.onerror = () => reject();\n\n document.body.appendChild(script);\n });\n}\n","import { SmartIterator } from \"../models/index.js\";\n\nexport function count<T>(elements: Iterable<T>): number\n{\n if (Array.isArray(elements)) { return elements.length; }\n\n let _count = 0;\n for (const _ of elements) { _count += 1; }\n\n return _count;\n}\n\nexport function enumerate<T>(elements: Iterable<T>): SmartIterator<[number, T]>\n{\n return new SmartIterator<[number, T]>(function* ()\n {\n let index = 0;\n\n for (const element of elements)\n {\n yield [index, element];\n\n index += 1;\n }\n });\n}\n\nexport function range(end: number): SmartIterator<number>;\nexport function range(start: number, end: number): SmartIterator<number>;\nexport function range(start: number, end: number, step: number): SmartIterator<number>;\nexport function range(start: number, end?: number, step = 1): SmartIterator<number>\n{\n return new SmartIterator<number>(function* ()\n {\n if (end === undefined)\n {\n end = start;\n start = 0;\n }\n\n if (start > end) { step = step ?? -1; }\n\n for (let index = start; index < end; index += step) { yield index; }\n });\n}\n\nexport function shuffle<T>(iterable: Iterable<T>): T[]\n{\n const array = Array.from(iterable);\n\n for (let index = array.length - 1; index > 0; index -= 1)\n {\n const jndex = Math.floor(Math.random() * (index + 1));\n\n [array[index], array[jndex]] = [array[jndex], array[index]];\n }\n\n return array;\n}\n\nexport function unique<T>(elements: Iterable<T>): SmartIterator<T>\n{\n return new SmartIterator<T>(function* ()\n {\n const values = new Set<T>();\n\n for (const element of elements)\n {\n if (values.has(element)) { continue; }\n\n values.add(element);\n\n yield element;\n }\n });\n}\n\nexport function zip<T, U>(first: Iterable<T>, second: Iterable<U>): SmartIterator<[T, U]>\n{\n return new SmartIterator<[T, U]>(function* ()\n {\n const firstIterator = first[Symbol.iterator]();\n const secondIterator = second[Symbol.iterator]();\n\n while (true)\n {\n const firstResult = firstIterator.next();\n const secondResult = secondIterator.next();\n\n if ((firstResult.done) || (secondResult.done)) { break; }\n\n yield [firstResult.value, secondResult.value];\n }\n });\n}\n","import { zip } from \"./iterator.js\";\n\nexport function average<T extends number>(values: Iterable<T>): number;\nexport function average<T extends number>(values: Iterable<T>, weights: Iterable<number>): number;\nexport function average<T extends number>(values: Iterable<T>, weights?: Iterable<number>): number\n{\n if (weights === undefined)\n {\n let _sum = 0;\n let _count = 0;\n\n for (const value of values)\n {\n _sum += value;\n _count += 1;\n }\n\n return _sum / _count;\n }\n\n let _sum = 0;\n let _count = 0;\n\n for (const [value, weight] of zip(values, weights))\n {\n _sum += value * weight;\n _count += weight;\n }\n\n return _sum / _count;\n}\n\nexport function hash(value: string): number\n{\n let hashedValue = 0;\n for (let index = 0; index < value.length; index += 1)\n {\n const char = value.charCodeAt(index);\n\n hashedValue = ((hashedValue << 5) - hashedValue) + char;\n hashedValue |= 0;\n }\n\n return hashedValue;\n}\n\nexport function sum<T extends number>(values: Iterable<T>): number\n{\n let _sum = 0;\n for (const value of values) { _sum += value; }\n\n return _sum;\n}\n","export function capitalize(value: string): string\n{\n return `${value.charAt(0).toUpperCase()}${value.slice(1)}`;\n}\n","export const VERSION = \"1.4.0\";\n\nexport {\n AggregatedIterator,\n Aggregator,\n DeferredPromise,\n Exception,\n JsonStorage,\n ReducedIterator,\n SmartIterator,\n SmartPromise,\n Subscribers\n\n} from \"./models/index.js\";\n\nexport {\n average,\n capitalize,\n count,\n delay,\n dateDifference,\n dateRange,\n dateRound,\n DateUnit,\n hash,\n loadScript,\n nextAnimationFrame,\n Random,\n range,\n shuffle,\n sum,\n unique,\n zip\n\n} from \"./utils/index.js\";\n\nexport type {\n Constructor,\n FulfilledHandler,\n GeneratorFunction,\n Interval,\n Iteratee,\n MaybePromise,\n PromiseExecutor,\n PromiseRejecter,\n PromiseResolver,\n Reducer,\n RejectedHandler,\n Timeout\n\n} from \"./types.js\";\n"],"names":["Exception","error","exc","message","cause","name","SmartIterator","argument","__publicField","value","predicate","index","result","iterator","iteratee","reducer","initialValue","accumulator","values","ReducedIterator","elements","key","element","_","AggregatedIterator","indexes","accumulators","keys","counters","count","firsts","lasts","groups","Aggregator","JsonStorage","preferPersistence","storage","propertyName","defaultValue","propertyValue","newValue","encodedValue","persistent","Subscribers","subscriber","args","DeferredPromise","onFulfilled","onRejected","_resolve","_reject","executor","resolve","reject","_onFulfilled","_onRejected","reason","onFinally","promise","SmartPromise","Random","ratio","min","max","delay","milliseconds","nextAnimationFrame","DateUnit","dateDifference","start","end","unit","dateRange","offset","endTime","unixTime","dateRound","date","loadScript","scriptUrl","scriptType","script","_count","range","step","shuffle","iterable","array","jndex","unique","zip","first","second","firstIterator","secondIterator","firstResult","secondResult","average","weights","_sum","weight","hash","hashedValue","char","sum","capitalize","VERSION"],"mappings":";;;AAAA,MAAqBA,UAAkB,MACvC;AAAA,EACI,OAAc,YAAYC,GAC1B;AACI,QAAIA,aAAiBD;AAEV,aAAAC;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rB;AACI,MAAI6F,IAAc;AAClB,WAAS3F,IAAQ,GAAGA,IAAQF,EAAM,QAAQE,KAAS,GACnD;AACU,UAAA4F,IAAO9F,EAAM,WAAWE,CAAK;AAEnB,IAAA2F,KAAAA,KAAe,KAAKA,IAAeC,GACpCD,KAAA;AAAA,EACnB;AAEO,SAAAA;AACX;AAEO,SAASE,EAAsBtF,GACtC;AACI,MAAIiF,IAAO;AACX,aAAW1F,KAASS;AAAkB,IAAAiF,KAAA1F;AAE/B,SAAA0F;AACX;ACpDO,SAASM,EAAWhG,GAC3B;AACW,SAAA,GAAGA,EAAM,OAAO,CAAC,EAAE,aAAa,GAAGA,EAAM,MAAM,CAAC,CAAC;AAC5D;ACHO,MAAMiG,IAAU;"}
package/dist/core.umd.cjs CHANGED
@@ -1,6 +1,6 @@
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 J=Object.defineProperty;var V=(o,c,a)=>c in o?J(o,c,{enumerable:!0,configurable:!0,writable:!0,value:a}):o[c]=a;var l=(o,c,a)=>(V(o,typeof c!="symbol"?c+"":c,a),a);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+=`
1
+ (function(o,a){typeof exports=="object"&&typeof module<"u"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(o=typeof globalThis<"u"?globalThis:o||self,a(o.Core={}))})(this,function(o){"use strict";var z=Object.defineProperty;var V=(o,a,l)=>a in o?z(o,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):o[a]=l;var c=(o,a,l)=>(V(o,typeof a!="symbol"?a+"":a,l),l);class a extends Error{static FromUnknown(e){if(e instanceof a)return e;if(e instanceof Error){const t=new a(e.message);return t.stack=e.stack,t.name=e.name,t}return new a(`${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 a{constructor(e){l(this,"_iterator");l(this,"return");l(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 a(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 a(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 a(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){l(this,"_elements");this._elements=new a(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 m{constructor(e){l(this,"_elements");this._elements=new a(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 m(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 m(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,h;if(n.has(r))[u,h]=n.get(r),u+=1;else if(t!==void 0)u=0,h=t;else{n.set(r,[0,i]);continue}h=e(r,h,i,u),n.set(r,[u,h])}return new f(function*(){for(const[r,[i,u]]of n)yield[r,u]})}unique(){const e=this._elements;return new m(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]})}first(){const e=new Map;for(const[t,n]of this._elements)e.has(t)||e.set(t,n);return new f(function*(){for(const[t,n]of e)yield[t,n]})}last(){const e=new Map;for(const[t,n]of this._elements)e.set(t,n);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 _{constructor(e){l(this,"_elements");this._elements=new a(e)}filter(e){return new _(this._elements.filter(e))}map(e){return new _(this._elements.map(e))}unique(){return new _(this._elements.unique())}byKey(e){return new m(this._elements.map((t,n)=>[e(t,n),t]))}}class g{constructor(e=!0){l(this,"_preferPersistence");l(this,"_volatile");l(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 v{constructor(){l(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 p{constructor(e,t){l(this,"_isPending");l(this,"_isFulfilled");l(this,"_isRejected");l(this,"_resolve");l(this,"_reject");l(this,"_promise");this._isPending=!0,this._isFulfilled=!1,this._isRejected=!1;let n,r;const i=(d,z)=>{n=d,r=z};let u;e?u=d=>(this._isPending=!1,this._isFulfilled=!0,e(d)):u=d=>(this._isPending=!1,this._isFulfilled=!0,d);let h;t?h=d=>(this._isPending=!1,this._isRejected=!0,t(d)):h=d=>(this._isPending=!1,this._isRejected=!0,d),this._promise=new Promise(i).then(u,h),this._resolve=n,this._reject=r}get isPending(){return this._isPending}get isFulfilled(){return this._isFulfilled}get isRejected(){return this._isRejected}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 b{constructor(e){l(this,"_isPending");l(this,"_isFulfilled");l(this,"_isRejected");l(this,"_promise");this._isPending=!0,this._isFulfilled=!1,this._isRejected=!1;const t=r=>(this._isPending=!1,this._isFulfilled=!0,r),n=r=>(this._isPending=!1,this._isRejected=!0,r);this._promise=new Promise(e).then(t,n)}get isPending(){return this._isPending}get isFulfilled(){return this._isFulfilled}get isRejected(){return this._isRejected}then(e,t){return this._promise.then(e,t)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}get[Symbol.toStringTag](){return"SmartPromise"}}class k{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 M(s){return new Promise((e,t)=>setTimeout(e,s))}async function P(){return new Promise((s,e)=>requestAnimationFrame(()=>s()))}var y=(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))(y||{});function S(s,e,t=864e5){return Math.floor((e.getTime()-s.getTime())/t)}function j(s,e,t=864e5){return new a(function*(){const n=e.getTime();let r=s.getTime();for(;r<n;)yield new Date(r),r+=t})}function R(s,e=864e5){return new Date(Math.floor(s.getTime()/e)*e)}async function x(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 F(s){if(Array.isArray(s))return s.length;let e=0;for(const t of s)e+=1;return e}function I(s,e,t=1){return new a(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 A(s){return new a(function*(){const e=new Set;for(const t of s)e.has(t)||(e.add(t),yield t)})}function w(s,e){return new a(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 E(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 w(s,e))t+=r*i,n+=i;return t/n}function O(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 q(s){let e=0;for(const t of s)e+=t;return e}function C(s){return`${s.charAt(0).toUpperCase()}${s.slice(1)}`}const $="1.3.3";o.AggregatedIterator=m,o.Aggregator=_,o.DateUnit=y,o.DeferredPromise=p,o.Exception=c,o.JsonStorage=g,o.Random=k,o.ReducedIterator=f,o.SmartIterator=a,o.SmartPromise=b,o.Subscribers=v,o.VERSION=$,o.average=E,o.capitalize=C,o.count=F,o.dateDifference=S,o.dateRange=j,o.dateRound=R,o.delay=M,o.hash=O,o.loadScript=x,o.nextAnimationFrame=P,o.range=I,o.shuffle=T,o.sum=q,o.unique=A,o.zip=w,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
5
+ Caused by ${t}`)}get[Symbol.toStringTag](){return"Exception"}}class l{constructor(e){c(this,"_iterator");c(this,"return");c(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)}get[Symbol.toStringTag](){return"SmartIterator"}[Symbol.iterator](){return this}}class f{constructor(e){c(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)]})}keys(){const e=this._elements;return new l(function*(){for(const[t]of e)yield t})}items(){return this._elements}values(){const e=this._elements;return new l(function*(){for(const[t,n]of e)yield n})}toArray(){return Array.from(this.values())}toMap(){return new Map(this.items())}toObject(){return Object.fromEntries(this.items())}get[Symbol.toStringTag](){return"ReducedIterator"}}class m{constructor(e){c(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 m(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 m(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,h;if(n.has(r))[u,h]=n.get(r),u+=1;else if(t!==void 0)u=0,h=t(r);else{n.set(r,[0,i]);continue}h=e(r,h,i,u),n.set(r,[u,h])}return new f(function*(){for(const[r,[i,u]]of n)yield[r,u]})}unique(){const e=this._elements;return new m(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]})}first(){const e=new Map;for(const[t,n]of this._elements)e.has(t)||e.set(t,n);return new f(function*(){for(const[t,n]of e)yield[t,n]})}last(){const e=new Map;for(const[t,n]of this._elements)e.set(t,n);return new f(function*(){for(const[t,n]of e)yield[t,n]})}keys(){const e=this._elements;return new l(function*(){for(const[t]of e)yield t})}items(){return this._elements}values(){const e=this._elements;return new l(function*(){for(const[t,n]of e)yield 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}get[Symbol.toStringTag](){return"AggregatedIterator"}}class _{constructor(e){c(this,"_elements");this._elements=new l(e)}filter(e){return new _(this._elements.filter(e))}map(e){return new _(this._elements.map(e))}unique(){return new _(this._elements.unique())}groupBy(e){return new m(this._elements.map((t,n)=>[e(t,n),t]))}get[Symbol.toStringTag](){return"Aggregator"}}class w{constructor(e=!0){c(this,"_preferPersistence");c(this,"_volatile");c(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)}get[Symbol.toStringTag](){return"JsonStorage"}}class v{constructor(){c(this,"_subscribers");this._subscribers=[]}add(e){this._subscribers.push(e)}remove(e){const t=this._subscribers.indexOf(e);if(t<0)throw new a("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))}get[Symbol.toStringTag](){return"Subscribers"}}class b{constructor(e,t){c(this,"_isPending");c(this,"_isFulfilled");c(this,"_isRejected");c(this,"_resolve");c(this,"_reject");c(this,"_promise");this._isPending=!0,this._isFulfilled=!1,this._isRejected=!1;let n,r;const i=(d,J)=>{n=d,r=J};let u;e?u=d=>(this._isPending=!1,this._isFulfilled=!0,e(d)):u=d=>(this._isPending=!1,this._isFulfilled=!0,d);let h;t?h=d=>(this._isPending=!1,this._isRejected=!0,t(d)):h=d=>(this._isPending=!1,this._isRejected=!0,d),this._promise=new Promise(i).then(u,h),this._resolve=n,this._reject=r}get isPending(){return this._isPending}get isFulfilled(){return this._isFulfilled}get isRejected(){return this._isRejected}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 S{constructor(e){c(this,"_isPending");c(this,"_isFulfilled");c(this,"_isRejected");c(this,"_promise");this._isPending=!0,this._isFulfilled=!1,this._isRejected=!1;const t=r=>(this._isPending=!1,this._isFulfilled=!0,r),n=r=>(this._isPending=!1,this._isRejected=!0,r);this._promise=new Promise(e).then(t,n)}get isPending(){return this._isPending}get isFulfilled(){return this._isFulfilled}get isRejected(){return this._isRejected}then(e,t){return this._promise.then(e,t)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}get[Symbol.toStringTag](){return"SmartPromise"}}class p{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 k(s){return new Promise((e,t)=>setTimeout(e,s))}async function M(){return new Promise((s,e)=>requestAnimationFrame(()=>s()))}var g=(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))(g||{});function P(s,e,t=864e5){return Math.floor((e.getTime()-s.getTime())/t)}function j(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 R(s,e=864e5){return new Date(Math.floor(s.getTime()/e)*e)}async function T(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 x(s){if(Array.isArray(s))return s.length;let e=0;for(const t of s)e+=1;return e}function I(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 F(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 A(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 E(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 O(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 q(s){let e=0;for(const t of s)e+=t;return e}function C(s){return`${s.charAt(0).toUpperCase()}${s.slice(1)}`}const $="1.4.0";o.AggregatedIterator=m,o.Aggregator=_,o.DateUnit=g,o.DeferredPromise=b,o.Exception=a,o.JsonStorage=w,o.Random=p,o.ReducedIterator=f,o.SmartIterator=l,o.SmartPromise=S,o.Subscribers=v,o.VERSION=$,o.average=E,o.capitalize=C,o.count=x,o.dateDifference=P,o.dateRange=j,o.dateRound=R,o.delay=k,o.hash=O,o.loadScript=T,o.nextAnimationFrame=M,o.range=I,o.shuffle=F,o.sum=q,o.unique=A,o.zip=y,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
6
6
  //# sourceMappingURL=core.umd.cjs.map
@@ -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/json-storage.ts","../src/models/subscribers.ts","../src/models/promises/deferred-promise.ts","../src/models/promises/smart-promise.ts","../src/utils/random.ts","../src/utils/async.ts","../src/utils/date.ts","../src/utils/dom.ts","../src/utils/iterator.ts","../src/utils/math.ts","../src/utils/string.ts","../src/index.ts"],"sourcesContent":["export default class Exception extends Error\n{\n public static FromUnknown(error: unknown): Exception\n {\n if (error instanceof Exception)\n {\n return error;\n }\n if (error instanceof Error)\n {\n const exc = new Exception(error.message);\n\n exc.stack = error.stack;\n exc.name = error.name;\n\n return exc;\n }\n\n return new Exception(`${error}`);\n }\n\n public constructor(message: string, cause?: unknown, name = \"Exception\")\n {\n super(message);\n\n this.cause = cause;\n this.name = name;\n\n if (cause)\n {\n if (cause instanceof Error)\n {\n this.stack += `\\n\\nCaused by ${cause.stack}`;\n }\n else\n {\n this.stack += `\\n\\nCaused by ${cause}`;\n }\n }\n }\n}\n","import type { GeneratorFunction, Iteratee, Reducer } from \"../types.js\";\n\nexport default class SmartIterator<T, R = void, N = undefined> implements Iterator<T, R, N>\n{\n protected _iterator: Iterator<T, R, N>;\n\n public return?: (value?: R) => IteratorResult<T, R>;\n public throw?: (error?: unknown) => IteratorResult<T, R>;\n\n public constructor(iterable: Iterable<T>);\n public constructor(iterator: Iterator<T, R, N>);\n public constructor(generatorFn: GeneratorFunction<T, R, N>);\n public constructor(argument: Iterable<T> | Iterator<T, R, N> | GeneratorFunction<T, R, N>);\n public constructor(argument: Iterable<T> | Iterator<T, R, N> | GeneratorFunction<T, R, N>)\n {\n if (argument instanceof Function)\n {\n this._iterator = argument();\n }\n else if (Symbol.iterator in argument)\n {\n this._iterator = argument[Symbol.iterator]() as Iterator<T, R, N>;\n }\n else\n {\n this._iterator = argument;\n }\n\n if (this._iterator.return) { this.return = (value?: R) => this._iterator.return!(value); }\n if (this._iterator.throw) { this.throw = (error?: unknown) => this._iterator.throw!(error); }\n }\n\n public every(predicate: Iteratee<T, boolean>): boolean\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n\n if (result.done) { return true; }\n if (!(predicate(result.value, index))) { return false; }\n\n index += 1;\n }\n }\n public some(predicate: Iteratee<T, boolean>): boolean\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n\n if (result.done) { return false; }\n if (predicate(result.value, index)) { return true; }\n\n index += 1;\n }\n }\n\n public filter(predicate: Iteratee<T, boolean>): SmartIterator<T, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<T, R>(function* ()\n {\n let index = 0;\n\n while (true)\n {\n const result = iterator.next();\n\n if (result.done) { return result.value; }\n if (predicate(result.value, index)) { yield result.value; }\n\n index += 1;\n }\n });\n }\n public map<V>(iteratee: Iteratee<T, V>): SmartIterator<V, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<V, R>(function* ()\n {\n let index = 0;\n\n while (true)\n {\n const result = iterator.next();\n if (result.done) { return result.value; }\n\n yield iteratee(result.value, index);\n\n index += 1;\n }\n });\n }\n public reduce<A>(reducer: Reducer<T, A>, initialValue?: A): A\n {\n let index = 0;\n let accumulator = initialValue;\n if (accumulator === undefined)\n {\n const result = this._iterator.next();\n if (result.done) { throw new TypeError(\"Reduce of empty iterator with no initial value\"); }\n\n accumulator = (result.value as unknown) as A;\n index += 1;\n }\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return accumulator; }\n\n accumulator = reducer(accumulator, result.value, index);\n\n index += 1;\n }\n }\n\n public enumerate(): SmartIterator<[number, T], R>\n {\n return this.map((value, index) => [index, value]);\n }\n public unique(): SmartIterator<T, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<T, R>(function* ()\n {\n const values = new Set<T>();\n\n while (true)\n {\n const result = iterator.next();\n\n if (result.done) { return result.value; }\n if (values.has(result.value)) { continue; }\n\n values.add(result.value);\n\n yield result.value;\n }\n });\n }\n\n public count(): number\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return index; }\n\n index += 1;\n }\n }\n public forEach(iteratee: Iteratee<T>): void\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return; }\n\n iteratee(result.value, index);\n\n index += 1;\n }\n }\n\n public next(...values: N extends undefined ? [] : [N]): IteratorResult<T, R>\n {\n return this._iterator.next(...values);\n }\n\n public toArray(): T[]\n {\n return Array.from(this as Iterable<T>);\n }\n\n public [Symbol.iterator](): SmartIterator<T, R, N> { return this; }\n}\n","import SmartIterator from \"../smart-iterator.js\";\n\nimport type { KeyIteratee } from \"./types.js\";\nimport type { GeneratorFunction } from \"../../types.js\";\n\nexport default class ReducedIterator<K extends PropertyKey, T>\n{\n protected _elements: SmartIterator<[K, T]>;\n\n public constructor(iterable: Iterable<[K, T]>);\n public constructor(iterator: Iterator<[K, T]>);\n public constructor(generatorFn: GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public filter(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, T>\n {\n const elements = this._elements;\n\n return new ReducedIterator(function* ()\n {\n for (const [index, [key, element]] of elements.enumerate())\n {\n if (predicate(key, element, index))\n {\n yield [key, element];\n }\n }\n });\n }\n public map<V>(iteratee: KeyIteratee<K, T, V>): ReducedIterator<K, V>\n {\n const elements = this._elements;\n\n return new ReducedIterator(function* ()\n {\n for (const [index, [key, element]] of elements.enumerate())\n {\n yield [key, iteratee(key, element, index)];\n }\n });\n }\n\n public toArray(): T[]\n {\n return Array.from(this.toMap().values());\n }\n public toMap(): Map<K, T>\n {\n return new Map(this._elements.toArray());\n }\n public toObject(): Record<K, T>\n {\n return Object.fromEntries(this._elements.toArray()) as Record<K, T>;\n }\n}\n","import ReducedIterator from \"./reduced-iterator.js\";\nimport SmartIterator from \"../smart-iterator.js\";\n\nimport type { KeyIteratee, KeyReducer } from \"./types.js\";\nimport type { GeneratorFunction } from \"../../types.js\";\n\nexport default class AggregatedIterator<K extends PropertyKey, T>\n{\n protected _elements: SmartIterator<[K, T]>;\n\n public constructor(iterable: Iterable<[K, T]>);\n public constructor(iterator: Iterator<[K, T]>);\n public constructor(generatorFn: GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public every(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, boolean>\n {\n const indexes = new Map<K, [number, boolean]>();\n\n for (const [key, element] of this._elements)\n {\n const [index, result] = indexes.get(key) ?? [0, true];\n\n if (!(result)) { continue; }\n\n indexes.set(key, [index + 1, predicate(key, element, index)]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, result]] of indexes)\n {\n yield [key, result];\n }\n });\n }\n public some(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, boolean>\n {\n const indexes = new Map<K, [number, boolean]>();\n\n for (const [key, element] of this._elements)\n {\n const [index, result] = indexes.get(key) ?? [0, false];\n\n if (result) { continue; }\n\n indexes.set(key, [index + 1, predicate(key, element, index)]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, result]] of indexes)\n {\n yield [key, result];\n }\n });\n }\n\n public filter(predicate: KeyIteratee<K, T, boolean>): AggregatedIterator<K, T>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const indexes = new Map<K, number>();\n\n for (const [key, element] of elements)\n {\n const index = indexes.get(key) ?? 0;\n\n indexes.set(key, index + 1);\n\n if (predicate(key, element, index)) { yield [key, element]; }\n }\n });\n }\n public map<V>(iteratee: KeyIteratee<K, T, V>): AggregatedIterator<K, V>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const indexes = new Map<K, number>();\n\n for (const [key, element] of elements)\n {\n const index = indexes.get(key) ?? 0;\n\n indexes.set(key, index + 1);\n\n yield [key, iteratee(key, element, index)];\n }\n });\n }\n public reduce<A>(reducer: KeyReducer<K, T, A>, initialValue?: A): ReducedIterator<K, A>\n {\n const accumulators = new Map<K, [number, A]>();\n\n for (const [key, element] of this._elements)\n {\n let index: number;\n let accumulator: A;\n\n if (accumulators.has(key))\n {\n [index, accumulator] = accumulators.get(key)!;\n\n index += 1;\n }\n else if (initialValue !== undefined)\n {\n index = 0;\n accumulator = initialValue;\n }\n else\n {\n accumulators.set(key, [0, (element as unknown) as A]);\n\n continue;\n }\n\n accumulator = reducer(key, accumulator, element, index);\n\n accumulators.set(key, [index, accumulator]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, accumulator]] of accumulators)\n {\n yield [key, accumulator];\n }\n });\n }\n\n public unique(): AggregatedIterator<K, T>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const keys = new Map<K, Set<T>>();\n\n for (const [key, element] of elements)\n {\n const values = keys.get(key) ?? new Set<T>();\n\n if (values.has(element)) { continue; }\n\n values.add(element);\n keys.set(key, values);\n\n yield [key, element];\n }\n });\n }\n\n public count(): ReducedIterator<K, number>\n {\n const counters = new Map<K, number>();\n\n for (const [key] of this._elements)\n {\n const count = counters.get(key) ?? 0;\n\n counters.set(key, count + 1);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, count] of counters)\n {\n yield [key, count];\n }\n });\n }\n public first(): ReducedIterator<K, T>\n {\n const firsts = new Map<K, T>();\n\n for (const [key, element] of this._elements)\n {\n if (firsts.has(key)) { continue; }\n\n firsts.set(key, element);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, element] of firsts)\n {\n yield [key, element];\n }\n });\n }\n public last(): ReducedIterator<K, T>\n {\n const lasts = new Map<K, T>();\n\n for (const [key, element] of this._elements)\n {\n lasts.set(key, element);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, element] of lasts)\n {\n yield [key, element];\n }\n });\n }\n\n public toArray(): T[][]\n {\n return Array.from(this.toMap().values());\n }\n public toMap(): Map<K, T[]>\n {\n const groups = new Map<K, T[]>();\n\n for (const [key, element] of this._elements)\n {\n const value = groups.get(key) ?? [];\n\n value.push(element);\n groups.set(key, value);\n }\n\n return groups;\n }\n public toObject(): Record<K, T[]>\n {\n const groups = { } as Record<K, T[]>;\n\n for (const [key, element] of this._elements)\n {\n const value = groups[key] ?? [];\n\n value.push(element);\n groups[key] = value;\n }\n\n return groups;\n }\n}\n","import AggregatedIterator from \"./aggregated-iterator.js\";\nimport ReducedIterator from \"./reduced-iterator.js\";\nimport SmartIterator from \"../smart-iterator.js\";\n\nimport type { GeneratorFunction, Iteratee } from \"../../types.js\";\n\nexport default class Aggregator<T>\n{\n protected _elements: SmartIterator<T>;\n\n public constructor(iterable: Iterable<T>);\n public constructor(iterator: Iterator<T>);\n public constructor(generatorFn: GeneratorFunction<T>);\n public constructor(argument: Iterable<T> | Iterator<T> | GeneratorFunction<T>);\n public constructor(argument: Iterable<T> | Iterator<T> | GeneratorFunction<T>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public filter(predicate: Iteratee<T, boolean>): Aggregator<T>\n {\n return new Aggregator(this._elements.filter(predicate));\n }\n public map<V>(iteratee: Iteratee<T, V>): Aggregator<V>\n {\n return new Aggregator(this._elements.map(iteratee));\n }\n\n public unique(): Aggregator<T>\n {\n return new Aggregator(this._elements.unique());\n }\n\n public byKey<K extends PropertyKey>(iteratee: Iteratee<T, K>): AggregatedIterator<K, T>\n {\n return new AggregatedIterator(this._elements.map((element, index) =>\n {\n const key = iteratee(element, index);\n\n return [key, element];\n }));\n }\n}\n\nexport { AggregatedIterator, ReducedIterator };\n","/* eslint-disable no-trailing-spaces */\n\n/**\n * A wrapper around the `Storage` API to store and retrieve JSON values.\n *\n * It allows to handle either the `sessionStorage` or the `localStorage`\n * storage at the same time, depending on the required use case.\n */\nexport default class JsonStorage\n{\n protected _preferPersistence: boolean;\n\n protected _volatile: Storage;\n protected _persistent: Storage;\n\n public constructor(preferPersistence = true)\n {\n this._preferPersistence = preferPersistence;\n\n this._volatile = window.sessionStorage;\n this._persistent = window.localStorage;\n }\n\n protected _get<T>(storage: Storage, propertyName: string): T | undefined;\n protected _get<T>(storage: Storage, propertyName: string, defaultValue: T): T;\n protected _get<T>(storage: Storage, propertyName: string, defaultValue?: T): T | undefined;\n protected _get<T>(storage: Storage, propertyName: string, defaultValue?: T): T | undefined\n {\n const propertyValue = storage.getItem(propertyName);\n if (propertyValue)\n {\n try\n {\n return JSON.parse(propertyValue);\n }\n catch (error)\n {\n // eslint-disable-next-line no-console\n console.warn(\n `The \"${propertyValue}\" value for \"${propertyName}\"` +\n \" property cannot be parsed. Clearing the storage...\");\n\n storage.removeItem(propertyName);\n }\n }\n\n return defaultValue;\n }\n protected _set<T>(storage: Storage, propertyName: string, newValue?: T): void\n {\n const encodedValue = JSON.stringify(newValue);\n if (encodedValue)\n {\n storage.setItem(propertyName, encodedValue);\n }\n else\n {\n storage.removeItem(propertyName);\n }\n }\n\n /**\n * Retrieves the value with the specified name from the corresponding storage.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n * @param persistent Whether to use the persistent `localStorage` or the volatile `sessionStorage`.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public get<T>(propertyName: string, defaultValue: undefined, persistent?: boolean): T | undefined;\n public get<T>(propertyName: string, defaultValue: T, persistent?: boolean): T ;\n public get<T>(propertyName: string, defaultValue?: T, persistent?: boolean): T | undefined;\n public get<T>(propertyName: string, defaultValue?: T, persistent = this._preferPersistence): T | undefined\n {\n const storage = persistent ? this._persistent : this._volatile;\n\n return this._get<T>(storage, propertyName, defaultValue);\n }\n /**\n * Retrieves the value with the specified name from the volatile `sessionStorage`.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public recall<T>(propertyName: string): T | undefined;\n public recall<T>(propertyName: string, defaultValue: T): T;\n public recall<T>(propertyName: string, defaultValue?: T): T | undefined;\n public recall<T>(propertyName: string, defaultValue?: T): T | undefined\n {\n return this._get<T>(this._volatile, propertyName, defaultValue);\n }\n /**\n * Retrieves the value with the specified name looking first in the\n * volatile `sessionStorage` and then in the persistent `localStorage`.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public retrieve<T>(propertyName: string): T | undefined;\n public retrieve<T>(propertyName: string, defaultValue: T): T;\n public retrieve<T>(propertyName: string, defaultValue?: T): T | undefined;\n public retrieve<T>(propertyName: string, defaultValue?: T): T | undefined\n {\n return this.recall<T>(propertyName) ?? this.read<T>(propertyName, defaultValue);\n }\n /**\n * Retrieves the value with the specified name from the persistent `localStorage`.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public read<T>(propertyName: string): T | undefined;\n public read<T>(propertyName: string, defaultValue: T): T;\n public read<T>(propertyName: string, defaultValue?: T): T | undefined;\n public read<T>(propertyName: string, defaultValue?: T): T | undefined\n {\n return this._get<T>(this._persistent, propertyName, defaultValue);\n }\n\n /**\n * Checks whether the property with the specified name exists in the corresponding storage.\n *\n * @param propertyName The name of the property to check.\n * @param persistent Whether to use the persistent `localStorage` or the volatile `sessionStorage`.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public has(propertyName: string, persistent?: boolean): boolean\n {\n const storage = persistent ? this._persistent : this._volatile;\n\n return storage.getItem(propertyName) !== null;\n }\n /**\n * Checks whether the property with the specified name exists in the volatile `sessionStorage`.\n *\n * @param propertyName The name of the property to check.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public knows(propertyName: string): boolean\n {\n return this._volatile.getItem(propertyName) !== null;\n }\n /**\n * Checks whether the property with the specified name exists looking first in the\n * volatile `sessionStorage` and then in the persistent `localStorage`.\n *\n * @param propertyName The name of the property to check.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public find(propertyName: string): boolean\n {\n return this.knows(propertyName) ?? this.exists(propertyName);\n }\n /**\n * Checks whether the property with the specified name exists in the persistent `localStorage`.\n *\n * @param propertyName The name of the property to check.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public exists(propertyName: string): boolean\n {\n return this._persistent.getItem(propertyName) !== null;\n }\n\n /**\n * Sets the value with the specified name in the corresponding storage.\n * If the value is `undefined`, the property is removed from the storage.\n *\n * @param propertyName The name of the property to set.\n * @param newValue The new value to set.\n * @param persistent Whether to use the persistent `localStorage` or the volatile `sessionStorage`.\n */\n public set<T>(propertyName: string, newValue?: T, persistent = this._preferPersistence): void\n {\n const storage = persistent ? this._persistent : this._volatile;\n\n this._set<T>(storage, propertyName, newValue);\n }\n /**\n * Sets the value with the specified name in the volatile `sessionStorage`.\n * If the value is `undefined`, the property is removed from the storage.\n *\n * @param propertyName The name of the property to set.\n * @param newValue The new value to set.\n */\n public remember<T>(propertyName: string, newValue?: T): void\n {\n this._set<T>(this._volatile, propertyName, newValue);\n }\n /**\n * Sets the value with the specified name in the persistent `localStorage`.\n * If the value is `undefined`, the property is removed from the storage.\n *\n * @param propertyName The name of the property to set.\n * @param newValue The new value to set.\n */\n public write<T>(propertyName: string, newValue?: T): void\n {\n this._set<T>(this._persistent, propertyName, newValue);\n }\n\n /**\n * Removes the value with the specified name from the volatile `sessionStorage`.\n *\n * @param propertyName The name of the property to remove.\n */\n public forget(propertyName: string): void\n {\n this._volatile.removeItem(propertyName);\n }\n /**\n * Removes the value with the specified name from the persistent `localStorage`.\n *\n * @param propertyName The name of the property to remove.\n */\n public erase(propertyName: string): void\n {\n this._persistent.removeItem(propertyName);\n }\n /**\n * Removes the value with the specified name from all the storages.\n *\n * @param propertyName The name of the property to remove.\n */\n public clear(propertyName: string): void\n {\n this._volatile.removeItem(propertyName);\n this._persistent.removeItem(propertyName);\n }\n}\n","import Exception from \"./exception.js\";\n\nexport default class Subscribers<P extends unknown[] = [], R = void, T extends (...args: P) => R = (...args: P) => R>\n{\n protected _subscribers: T[];\n\n public constructor()\n {\n this._subscribers = [];\n }\n\n public add(subscriber: T): void\n {\n this._subscribers.push(subscriber);\n }\n public remove(subscriber: T): void\n {\n const index = this._subscribers.indexOf(subscriber);\n if (index < 0)\n {\n throw new Exception(\"Unable to remove the requested subscriber. It was not found.\");\n }\n\n this._subscribers.splice(index, 1);\n }\n\n public call(...args: P): R[]\n {\n return this._subscribers\n .slice()\n .map((subscriber) => subscriber(...args));\n }\n}\n","import type {\n PromiseResolver,\n PromiseRejecter,\n FulfilledHandler,\n RejectedHandler,\n PromiseExecutor\n\n} from \"../../types.js\";\n\nexport default class DeferredPromise<T = void, E = unknown, F = T, R = never>\n{\n protected _isPending: boolean;\n protected _isFulfilled: boolean;\n protected _isRejected: boolean;\n\n protected _resolve!: PromiseResolver<T>;\n protected _reject!: PromiseRejecter<E>;\n\n protected _promise: Promise<F | R>;\n\n public constructor(onFulfilled?: FulfilledHandler<T, F> | null, onRejected?: RejectedHandler<E, R> | null)\n {\n this._isPending = true;\n this._isFulfilled = false;\n this._isRejected = false;\n\n let _resolve: PromiseResolver<T>;\n let _reject: PromiseRejecter<E>;\n\n const executor: PromiseExecutor<T, E> = (resolve, reject) =>\n {\n _resolve = resolve;\n _reject = reject;\n };\n\n let _onFulfilled: FulfilledHandler<T, F>;\n if (onFulfilled)\n {\n _onFulfilled = (value) =>\n {\n this._isPending = false;\n this._isFulfilled = true;\n\n return onFulfilled!(value);\n };\n }\n else\n {\n _onFulfilled = (value) =>\n {\n this._isPending = false;\n this._isFulfilled = true;\n\n return (value as unknown) as F;\n };\n }\n\n let _onRejected: RejectedHandler<E, R>;\n if (onRejected)\n {\n _onRejected = (reason) =>\n {\n this._isPending = false;\n this._isRejected = true;\n\n return onRejected!(reason);\n };\n }\n else\n {\n _onRejected = (reason) =>\n {\n this._isPending = false;\n this._isRejected = true;\n\n return (reason as unknown) as R;\n };\n }\n\n this._promise = new Promise<T>(executor)\n .then(_onFulfilled, _onRejected);\n\n this._resolve = _resolve!;\n this._reject = _reject!;\n }\n\n public get isPending(): boolean { return this._isPending; }\n public get isFulfilled(): boolean { return this._isFulfilled; }\n public get isRejected(): boolean { return this._isRejected; }\n\n public get resolve(): PromiseResolver<T> { return this._resolve; }\n public get reject(): PromiseRejecter<E> { return this._reject; }\n\n public then<N = F | R, H = R>(\n onFulfilled?: FulfilledHandler<F | R, N> | null,\n onRejected?: RejectedHandler<R, H> | null): Promise<N | H>\n {\n return this._promise.then(onFulfilled, onRejected);\n }\n public catch<H = R>(onRejected?: RejectedHandler<R, H> | null): Promise<F | R | H>\n {\n return this._promise.catch(onRejected);\n }\n public finally(onFinally?: (() => void) | null): Promise<F | R>\n {\n return this._promise.finally(onFinally);\n }\n\n public watch(promise: Promise<T>): this\n {\n promise.then(this.resolve, this.reject);\n\n return this;\n }\n\n public get [Symbol.toStringTag]() { return \"DeferredPromise\"; }\n}\n","import type { FulfilledHandler, PromiseExecutor, RejectedHandler } from \"../../types.js\";\n\nexport default class SmartPromise<T = void, E = unknown>\n{\n protected _isPending: boolean;\n protected _isFulfilled: boolean;\n protected _isRejected: boolean;\n\n protected _promise: Promise<T | E>;\n\n public constructor(executor: PromiseExecutor<T, E>)\n {\n this._isPending = true;\n this._isFulfilled = false;\n this._isRejected = false;\n\n const _resolve = (result: T): T =>\n {\n this._isPending = false;\n this._isFulfilled = true;\n\n return result;\n };\n const _reject = (reason: E): E =>\n {\n this._isPending = false;\n this._isRejected = true;\n\n return reason;\n };\n\n this._promise = new Promise<T>(executor)\n .then(_resolve, _reject);\n }\n\n public get isPending(): boolean { return this._isPending; }\n public get isFulfilled(): boolean { return this._isFulfilled; }\n public get isRejected(): boolean { return this._isRejected; }\n\n public then<F = T, R = E>(\n onFulfilled?: FulfilledHandler<T | E, F> | null,\n onRejected?: RejectedHandler<E, R> | null): Promise<F | R>\n {\n return this._promise.then(onFulfilled, onRejected);\n }\n public catch<R = E>(onRejected?: RejectedHandler<E, R> | null): Promise<T | E | R>\n {\n return this._promise.catch(onRejected);\n }\n public finally(onFinally?: (() => void) | null): Promise<T | E>\n {\n return this._promise.finally(onFinally);\n }\n\n public get [Symbol.toStringTag]() { return \"SmartPromise\"; }\n}\n","export default class Random\n{\n public static Boolean(ratio: number = 0.5): boolean\n {\n return (Math.random() < ratio);\n }\n\n public static Integer(max: number): number;\n public static Integer(min: number, max: number): number;\n public static Integer(min: number, max?: number): number\n {\n if (max === undefined)\n {\n return Math.floor(Math.random() * min);\n }\n\n return Math.floor(Math.random() * (max - min) + min);\n }\n\n public static Decimal(max: number): number;\n public static Decimal(min: number, max: number): number;\n public static Decimal(min: number, max?: number): number\n {\n if (max === undefined)\n {\n return (Math.random() * min);\n }\n\n return (Math.random() * (max - min) + min);\n }\n\n public static Choice<T>(elements: T[]): T\n {\n return elements[this.Integer(elements.length)];\n }\n\n // eslint-disable-next-line no-useless-constructor\n private constructor() { }\n}\n","export async function delay(milliseconds: number): Promise<void>\n{\n return new Promise<void>((resolve, reject) => setTimeout(resolve, milliseconds));\n}\n\nexport async function nextAnimationFrame(): Promise<void>\n{\n return new Promise<void>((resolve, reject) => requestAnimationFrame(() => resolve()));\n}\n","import { SmartIterator } from \"../models/index.js\";\n\nexport enum DateUnit\n{\n Second = 1000,\n Minute = 60 * Second,\n Hour = 60 * Minute,\n Day = 24 * Hour,\n Week = 7 * Day,\n Month = 30 * Day,\n Year = 365 * Day\n}\n\nexport function dateDifference(start: Date, end: Date, unit = DateUnit.Day): number\n{\n return Math.floor((end.getTime() - start.getTime()) / unit);\n}\n\nexport function dateRange(start: Date, end: Date, offset = DateUnit.Day): SmartIterator<Date>\n{\n return new SmartIterator<Date>(function* ()\n {\n const endTime = end.getTime();\n\n let unixTime: number = start.getTime();\n while (unixTime < endTime)\n {\n yield new Date(unixTime);\n\n unixTime += offset;\n }\n });\n}\n\nexport function dateRound(date: Date, unit = DateUnit.Day): Date\n{\n return new Date(Math.floor(date.getTime() / unit) * unit);\n}\n","export async function loadScript(scriptUrl: string, scriptType = \"text/javascript\"): Promise<void>\n{\n return new Promise<void>((resolve, reject) =>\n {\n const script = document.createElement(\"script\");\n\n script.async = true;\n script.defer = true;\n script.src = scriptUrl;\n script.type = scriptType;\n\n script.onload = () => resolve();\n script.onerror = () => reject();\n\n document.body.appendChild(script);\n });\n}\n","import { SmartIterator } from \"../models/index.js\";\n\nexport function count<T>(elements: Iterable<T>): number\n{\n if (Array.isArray(elements)) { return elements.length; }\n\n let _count = 0;\n for (const _ of elements) { _count += 1; }\n\n return _count;\n}\n\nexport function enumerate<T>(elements: Iterable<T>): SmartIterator<[number, T]>\n{\n return new SmartIterator<[number, T]>(function* ()\n {\n let index = 0;\n\n for (const element of elements)\n {\n yield [index, element];\n\n index += 1;\n }\n });\n}\n\nexport function range(end: number): SmartIterator<number>;\nexport function range(start: number, end: number): SmartIterator<number>;\nexport function range(start: number, end: number, step: number): SmartIterator<number>;\nexport function range(start: number, end?: number, step = 1): SmartIterator<number>\n{\n return new SmartIterator<number>(function* ()\n {\n if (end === undefined)\n {\n end = start;\n start = 0;\n }\n\n if (start > end) { step = step ?? -1; }\n\n for (let index = start; index < end; index += step) { yield index; }\n });\n}\n\nexport function shuffle<T>(iterable: Iterable<T>): T[]\n{\n const array = Array.from(iterable);\n\n for (let index = array.length - 1; index > 0; index -= 1)\n {\n const jndex = Math.floor(Math.random() * (index + 1));\n\n [array[index], array[jndex]] = [array[jndex], array[index]];\n }\n\n return array;\n}\n\nexport function unique<T>(elements: Iterable<T>): SmartIterator<T>\n{\n return new SmartIterator<T>(function* ()\n {\n const values = new Set<T>();\n\n for (const element of elements)\n {\n if (values.has(element)) { continue; }\n\n values.add(element);\n\n yield element;\n }\n });\n}\n\nexport function zip<T, U>(first: Iterable<T>, second: Iterable<U>): SmartIterator<[T, U]>\n{\n return new SmartIterator<[T, U]>(function* ()\n {\n const firstIterator = first[Symbol.iterator]();\n const secondIterator = second[Symbol.iterator]();\n\n while (true)\n {\n const firstResult = firstIterator.next();\n const secondResult = secondIterator.next();\n\n if ((firstResult.done) || (secondResult.done)) { break; }\n\n yield [firstResult.value, secondResult.value];\n }\n });\n}\n","import { zip } from \"./iterator.js\";\n\nexport function average<T extends number>(values: Iterable<T>): number;\nexport function average<T extends number>(values: Iterable<T>, weights: Iterable<number>): number;\nexport function average<T extends number>(values: Iterable<T>, weights?: Iterable<number>): number\n{\n if (weights === undefined)\n {\n let _sum = 0;\n let _count = 0;\n\n for (const value of values)\n {\n _sum += value;\n _count += 1;\n }\n\n return _sum / _count;\n }\n\n let _sum = 0;\n let _count = 0;\n\n for (const [value, weight] of zip(values, weights))\n {\n _sum += value * weight;\n _count += weight;\n }\n\n return _sum / _count;\n}\n\nexport function hash(value: string): number\n{\n let hashedValue = 0;\n for (let index = 0; index < value.length; index += 1)\n {\n const char = value.charCodeAt(index);\n\n hashedValue = ((hashedValue << 5) - hashedValue) + char;\n hashedValue |= 0;\n }\n\n return hashedValue;\n}\n\nexport function sum<T extends number>(values: Iterable<T>): number\n{\n let _sum = 0;\n for (const value of values) { _sum += value; }\n\n return _sum;\n}\n","export function capitalize(value: string): string\n{\n return `${value.charAt(0).toUpperCase()}${value.slice(1)}`;\n}\n","export const VERSION = \"1.3.3\";\n\nexport {\n AggregatedIterator,\n Aggregator,\n DeferredPromise,\n Exception,\n JsonStorage,\n ReducedIterator,\n SmartIterator,\n SmartPromise,\n Subscribers\n\n} from \"./models/index.js\";\n\nexport {\n average,\n capitalize,\n count,\n delay,\n dateDifference,\n dateRange,\n dateRound,\n DateUnit,\n hash,\n loadScript,\n nextAnimationFrame,\n Random,\n range,\n shuffle,\n sum,\n unique,\n zip\n\n} from \"./utils/index.js\";\n\nexport type {\n Constructor,\n FulfilledHandler,\n GeneratorFunction,\n Interval,\n Iteratee,\n MaybePromise,\n PromiseExecutor,\n PromiseRejecter,\n PromiseResolver,\n Reducer,\n RejectedHandler,\n Timeout\n\n} from \"./types.js\";\n"],"names":["Exception","error","exc","message","cause","name","SmartIterator","argument","__publicField","value","predicate","index","result","iterator","iteratee","reducer","initialValue","accumulator","values","ReducedIterator","elements","key","element","AggregatedIterator","indexes","_","accumulators","keys","counters","count","firsts","lasts","groups","Aggregator","JsonStorage","preferPersistence","storage","propertyName","defaultValue","propertyValue","newValue","encodedValue","persistent","Subscribers","subscriber","args","DeferredPromise","onFulfilled","onRejected","_resolve","_reject","executor","resolve","reject","_onFulfilled","_onRejected","reason","onFinally","promise","SmartPromise","Random","ratio","min","max","delay","milliseconds","nextAnimationFrame","DateUnit","dateDifference","start","end","unit","dateRange","offset","endTime","unixTime","dateRound","date","loadScript","scriptUrl","scriptType","script","_count","range","step","shuffle","iterable","array","jndex","unique","zip","first","second","firstIterator","secondIterator","firstResult","secondResult","average","weights","_sum","weight","hash","hashedValue","char","sum","capitalize","VERSION"],"mappings":"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,K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EAAOjB,CAClB,CAEA,IAAIiB,EAAO,EACPjB,EAAS,EAEb,SAAW,CAACzE,EAAO2F,CAAM,IAAKV,EAAIxE,EAAQgF,CAAO,EAE7CC,GAAQ1F,EAAQ2F,EACNlB,GAAAkB,EAGd,OAAOD,EAAOjB,CAClB,CAEO,SAASmB,EAAK5F,EACrB,CACI,IAAI6F,EAAc,EAClB,QAAS3F,EAAQ,EAAGA,EAAQF,EAAM,OAAQE,GAAS,EACnD,CACU,MAAA4F,EAAO9F,EAAM,WAAWE,CAAK,EAEnB2F,GAAAA,GAAe,GAAKA,EAAeC,EACpCD,GAAA,CACnB,CAEO,OAAAA,CACX,CAEO,SAASE,EAAsBtF,EACtC,CACI,IAAIiF,EAAO,EACX,UAAW1F,KAASS,EAAkBiF,GAAA1F,EAE/B,OAAA0F,CACX,CCpDO,SAASM,EAAWhG,EAC3B,CACW,MAAA,GAAGA,EAAM,OAAO,CAAC,EAAE,aAAa,GAAGA,EAAM,MAAM,CAAC,CAAC,EAC5D,CCHO,MAAMiG,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/json-storage.ts","../src/models/subscribers.ts","../src/models/promises/deferred-promise.ts","../src/models/promises/smart-promise.ts","../src/utils/random.ts","../src/utils/async.ts","../src/utils/date.ts","../src/utils/dom.ts","../src/utils/iterator.ts","../src/utils/math.ts","../src/utils/string.ts","../src/index.ts"],"sourcesContent":["export default class Exception extends Error\n{\n public static FromUnknown(error: unknown): Exception\n {\n if (error instanceof Exception)\n {\n return error;\n }\n if (error instanceof Error)\n {\n const exc = new Exception(error.message);\n\n exc.stack = error.stack;\n exc.name = error.name;\n\n return exc;\n }\n\n return new Exception(`${error}`);\n }\n\n public constructor(message: string, cause?: unknown, name = \"Exception\")\n {\n super(message);\n\n this.cause = cause;\n this.name = name;\n\n if (cause)\n {\n if (cause instanceof Error)\n {\n this.stack += `\\n\\nCaused by ${cause.stack}`;\n }\n else\n {\n this.stack += `\\n\\nCaused by ${cause}`;\n }\n }\n }\n\n public get [Symbol.toStringTag]() { return \"Exception\"; }\n}\n","import type { GeneratorFunction, Iteratee, Reducer } from \"../types.js\";\n\nexport default class SmartIterator<T, R = void, N = undefined> implements Iterator<T, R, N>\n{\n protected _iterator: Iterator<T, R, N>;\n\n public return?: (value?: R) => IteratorResult<T, R>;\n public throw?: (error?: unknown) => IteratorResult<T, R>;\n\n public constructor(iterable: Iterable<T>);\n public constructor(iterator: Iterator<T, R, N>);\n public constructor(generatorFn: GeneratorFunction<T, R, N>);\n public constructor(argument: Iterable<T> | Iterator<T, R, N> | GeneratorFunction<T, R, N>);\n public constructor(argument: Iterable<T> | Iterator<T, R, N> | GeneratorFunction<T, R, N>)\n {\n if (argument instanceof Function)\n {\n this._iterator = argument();\n }\n else if (Symbol.iterator in argument)\n {\n this._iterator = argument[Symbol.iterator]() as Iterator<T, R, N>;\n }\n else\n {\n this._iterator = argument;\n }\n\n if (this._iterator.return) { this.return = (value?: R) => this._iterator.return!(value); }\n if (this._iterator.throw) { this.throw = (error?: unknown) => this._iterator.throw!(error); }\n }\n\n public every(predicate: Iteratee<T, boolean>): boolean\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n\n if (result.done) { return true; }\n if (!(predicate(result.value, index))) { return false; }\n\n index += 1;\n }\n }\n public some(predicate: Iteratee<T, boolean>): boolean\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n\n if (result.done) { return false; }\n if (predicate(result.value, index)) { return true; }\n\n index += 1;\n }\n }\n\n public filter(predicate: Iteratee<T, boolean>): SmartIterator<T, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<T, R>(function* ()\n {\n let index = 0;\n\n while (true)\n {\n const result = iterator.next();\n\n if (result.done) { return result.value; }\n if (predicate(result.value, index)) { yield result.value; }\n\n index += 1;\n }\n });\n }\n public map<V>(iteratee: Iteratee<T, V>): SmartIterator<V, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<V, R>(function* ()\n {\n let index = 0;\n\n while (true)\n {\n const result = iterator.next();\n if (result.done) { return result.value; }\n\n yield iteratee(result.value, index);\n\n index += 1;\n }\n });\n }\n public reduce(reducer: Reducer<T, T>): T;\n public reduce<A>(reducer: Reducer<T, A>, initialValue: A): A;\n public reduce<A>(reducer: Reducer<T, A>, initialValue?: A): A\n {\n let index = 0;\n let accumulator = initialValue;\n if (accumulator === undefined)\n {\n const result = this._iterator.next();\n if (result.done) { throw new TypeError(\"Reduce of empty iterator with no initial value\"); }\n\n accumulator = (result.value as unknown) as A;\n index += 1;\n }\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return accumulator; }\n\n accumulator = reducer(accumulator, result.value, index);\n\n index += 1;\n }\n }\n\n public enumerate(): SmartIterator<[number, T], R>\n {\n return this.map((value, index) => [index, value]);\n }\n public unique(): SmartIterator<T, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<T, R>(function* ()\n {\n const values = new Set<T>();\n\n while (true)\n {\n const result = iterator.next();\n\n if (result.done) { return result.value; }\n if (values.has(result.value)) { continue; }\n\n values.add(result.value);\n\n yield result.value;\n }\n });\n }\n\n public count(): number\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return index; }\n\n index += 1;\n }\n }\n public forEach(iteratee: Iteratee<T>): void\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return; }\n\n iteratee(result.value, index);\n\n index += 1;\n }\n }\n\n public next(...values: N extends undefined ? [] : [N]): IteratorResult<T, R>\n {\n return this._iterator.next(...values);\n }\n\n public toArray(): T[]\n {\n return Array.from(this as Iterable<T>);\n }\n\n public get [Symbol.toStringTag]() { return \"SmartIterator\"; }\n\n public [Symbol.iterator](): SmartIterator<T, R, N> { return this; }\n}\n","import SmartIterator from \"../smart-iterator.js\";\n\nimport type { KeyIteratee } from \"./types.js\";\nimport type { GeneratorFunction } from \"../../types.js\";\n\nexport default class ReducedIterator<K extends PropertyKey, T>\n{\n protected _elements: SmartIterator<[K, T]>;\n\n public constructor(iterable: Iterable<[K, T]>);\n public constructor(iterator: Iterator<[K, T]>);\n public constructor(generatorFn: GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public filter(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, T>\n {\n const elements = this._elements;\n\n return new ReducedIterator(function* ()\n {\n for (const [index, [key, element]] of elements.enumerate())\n {\n if (predicate(key, element, index))\n {\n yield [key, element];\n }\n }\n });\n }\n public map<V>(iteratee: KeyIteratee<K, T, V>): ReducedIterator<K, V>\n {\n const elements = this._elements;\n\n return new ReducedIterator(function* ()\n {\n for (const [index, [key, element]] of elements.enumerate())\n {\n yield [key, iteratee(key, element, index)];\n }\n });\n }\n\n public keys(): SmartIterator<K>\n {\n const elements = this._elements;\n\n return new SmartIterator<K>(function* ()\n {\n for (const [key] of elements)\n {\n yield key;\n }\n });\n }\n public items(): SmartIterator<[K, T]>\n {\n return this._elements;\n }\n public values(): SmartIterator<T>\n {\n const elements = this._elements;\n\n return new SmartIterator<T>(function* ()\n {\n for (const [_, element] of elements)\n {\n yield element;\n }\n });\n }\n\n public toArray(): T[]\n {\n return Array.from(this.values());\n }\n public toMap(): Map<K, T>\n {\n return new Map(this.items());\n }\n public toObject(): Record<K, T>\n {\n return Object.fromEntries(this.items()) as Record<K, T>;\n }\n\n public get [Symbol.toStringTag]() { return \"ReducedIterator\"; }\n}\n","import ReducedIterator from \"./reduced-iterator.js\";\nimport SmartIterator from \"../smart-iterator.js\";\n\nimport type { KeyIteratee, KeyReducer } from \"./types.js\";\nimport type { GeneratorFunction } from \"../../types.js\";\n\nexport default class AggregatedIterator<K extends PropertyKey, T>\n{\n protected _elements: SmartIterator<[K, T]>;\n\n public constructor(iterable: Iterable<[K, T]>);\n public constructor(iterator: Iterator<[K, T]>);\n public constructor(generatorFn: GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public every(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, boolean>\n {\n const indexes = new Map<K, [number, boolean]>();\n\n for (const [key, element] of this._elements)\n {\n const [index, result] = indexes.get(key) ?? [0, true];\n\n if (!(result)) { continue; }\n\n indexes.set(key, [index + 1, predicate(key, element, index)]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, result]] of indexes)\n {\n yield [key, result];\n }\n });\n }\n public some(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, boolean>\n {\n const indexes = new Map<K, [number, boolean]>();\n\n for (const [key, element] of this._elements)\n {\n const [index, result] = indexes.get(key) ?? [0, false];\n\n if (result) { continue; }\n\n indexes.set(key, [index + 1, predicate(key, element, index)]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, result]] of indexes)\n {\n yield [key, result];\n }\n });\n }\n\n public filter(predicate: KeyIteratee<K, T, boolean>): AggregatedIterator<K, T>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const indexes = new Map<K, number>();\n\n for (const [key, element] of elements)\n {\n const index = indexes.get(key) ?? 0;\n\n indexes.set(key, index + 1);\n\n if (predicate(key, element, index)) { yield [key, element]; }\n }\n });\n }\n public map<V>(iteratee: KeyIteratee<K, T, V>): AggregatedIterator<K, V>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const indexes = new Map<K, number>();\n\n for (const [key, element] of elements)\n {\n const index = indexes.get(key) ?? 0;\n\n indexes.set(key, index + 1);\n\n yield [key, iteratee(key, element, index)];\n }\n });\n }\n public reduce(reducer: KeyReducer<K, T, T>): ReducedIterator<K, T>;\n public reduce<A>(reducer: KeyReducer<K, T, A>, initialValue: (key: K) => A): ReducedIterator<K, A>;\n public reduce<A>(reducer: KeyReducer<K, T, A>, initialValue?: (key: K) => A): ReducedIterator<K, A>\n {\n const accumulators = new Map<K, [number, A]>();\n\n for (const [key, element] of this._elements)\n {\n let index: number;\n let accumulator: A;\n\n if (accumulators.has(key))\n {\n [index, accumulator] = accumulators.get(key)!;\n\n index += 1;\n }\n else if (initialValue !== undefined)\n {\n index = 0;\n accumulator = initialValue(key);\n }\n else\n {\n accumulators.set(key, [0, (element as unknown) as A]);\n\n continue;\n }\n\n accumulator = reducer(key, accumulator, element, index);\n\n accumulators.set(key, [index, accumulator]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, accumulator]] of accumulators)\n {\n yield [key, accumulator];\n }\n });\n }\n\n public unique(): AggregatedIterator<K, T>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const keys = new Map<K, Set<T>>();\n\n for (const [key, element] of elements)\n {\n const values = keys.get(key) ?? new Set<T>();\n\n if (values.has(element)) { continue; }\n\n values.add(element);\n keys.set(key, values);\n\n yield [key, element];\n }\n });\n }\n\n public count(): ReducedIterator<K, number>\n {\n const counters = new Map<K, number>();\n\n for (const [key] of this._elements)\n {\n const count = counters.get(key) ?? 0;\n\n counters.set(key, count + 1);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, count] of counters)\n {\n yield [key, count];\n }\n });\n }\n public first(): ReducedIterator<K, T>\n {\n const firsts = new Map<K, T>();\n\n for (const [key, element] of this._elements)\n {\n if (firsts.has(key)) { continue; }\n\n firsts.set(key, element);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, element] of firsts)\n {\n yield [key, element];\n }\n });\n }\n public last(): ReducedIterator<K, T>\n {\n const lasts = new Map<K, T>();\n\n for (const [key, element] of this._elements)\n {\n lasts.set(key, element);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, element] of lasts)\n {\n yield [key, element];\n }\n });\n }\n\n public keys(): SmartIterator<K>\n {\n const elements = this._elements;\n\n return new SmartIterator<K>(function* ()\n {\n for (const [key] of elements)\n {\n yield key;\n }\n });\n }\n public items(): SmartIterator<[K, T]>\n {\n return this._elements;\n }\n public values(): SmartIterator<T>\n {\n const elements = this._elements;\n\n return new SmartIterator<T>(function* ()\n {\n for (const [_, element] of elements)\n {\n yield element;\n }\n });\n }\n\n public toArray(): T[][]\n {\n return Array.from(this.toMap().values());\n }\n public toMap(): Map<K, T[]>\n {\n const groups = new Map<K, T[]>();\n\n for (const [key, element] of this._elements)\n {\n const value = groups.get(key) ?? [];\n\n value.push(element);\n groups.set(key, value);\n }\n\n return groups;\n }\n public toObject(): Record<K, T[]>\n {\n const groups = { } as Record<K, T[]>;\n\n for (const [key, element] of this._elements)\n {\n const value = groups[key] ?? [];\n\n value.push(element);\n groups[key] = value;\n }\n\n return groups;\n }\n\n public get [Symbol.toStringTag]() { return \"AggregatedIterator\"; }\n}\n","import AggregatedIterator from \"./aggregated-iterator.js\";\nimport ReducedIterator from \"./reduced-iterator.js\";\nimport SmartIterator from \"../smart-iterator.js\";\n\nimport type { GeneratorFunction, Iteratee } 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 groupBy<K extends PropertyKey>(iteratee: Iteratee<T, K>): AggregatedIterator<K, T>\n {\n return new AggregatedIterator(this._elements.map((element, index) =>\n {\n const key = iteratee(element, index);\n\n return [key, element];\n }));\n }\n\n public get [Symbol.toStringTag]() { return \"Aggregator\"; }\n}\n\nexport { AggregatedIterator, ReducedIterator };\n","/* eslint-disable no-trailing-spaces */\n\n/**\n * A wrapper around the `Storage` API to store and retrieve JSON values.\n *\n * It allows to handle either the `sessionStorage` or the `localStorage`\n * storage at the same time, depending on the required use case.\n */\nexport default class JsonStorage\n{\n protected _preferPersistence: boolean;\n\n protected _volatile: Storage;\n protected _persistent: Storage;\n\n public constructor(preferPersistence = true)\n {\n this._preferPersistence = preferPersistence;\n\n this._volatile = window.sessionStorage;\n this._persistent = window.localStorage;\n }\n\n protected _get<T>(storage: Storage, propertyName: string): T | undefined;\n protected _get<T>(storage: Storage, propertyName: string, defaultValue: T): T;\n protected _get<T>(storage: Storage, propertyName: string, defaultValue?: T): T | undefined;\n protected _get<T>(storage: Storage, propertyName: string, defaultValue?: T): T | undefined\n {\n const propertyValue = storage.getItem(propertyName);\n if (propertyValue)\n {\n try\n {\n return JSON.parse(propertyValue);\n }\n catch (error)\n {\n // eslint-disable-next-line no-console\n console.warn(\n `The \"${propertyValue}\" value for \"${propertyName}\"` +\n \" property cannot be parsed. Clearing the storage...\");\n\n storage.removeItem(propertyName);\n }\n }\n\n return defaultValue;\n }\n protected _set<T>(storage: Storage, propertyName: string, newValue?: T): void\n {\n const encodedValue = JSON.stringify(newValue);\n if (encodedValue)\n {\n storage.setItem(propertyName, encodedValue);\n }\n else\n {\n storage.removeItem(propertyName);\n }\n }\n\n /**\n * Retrieves the value with the specified name from the corresponding storage.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n * @param persistent Whether to use the persistent `localStorage` or the volatile `sessionStorage`.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public get<T>(propertyName: string, defaultValue: undefined, persistent?: boolean): T | undefined;\n public get<T>(propertyName: string, defaultValue: T, persistent?: boolean): T ;\n public get<T>(propertyName: string, defaultValue?: T, persistent?: boolean): T | undefined;\n public get<T>(propertyName: string, defaultValue?: T, persistent = this._preferPersistence): T | undefined\n {\n const storage = persistent ? this._persistent : this._volatile;\n\n return this._get<T>(storage, propertyName, defaultValue);\n }\n /**\n * Retrieves the value with the specified name from the volatile `sessionStorage`.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public recall<T>(propertyName: string): T | undefined;\n public recall<T>(propertyName: string, defaultValue: T): T;\n public recall<T>(propertyName: string, defaultValue?: T): T | undefined;\n public recall<T>(propertyName: string, defaultValue?: T): T | undefined\n {\n return this._get<T>(this._volatile, propertyName, defaultValue);\n }\n /**\n * Retrieves the value with the specified name looking first in the\n * volatile `sessionStorage` and then in the persistent `localStorage`.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public retrieve<T>(propertyName: string): T | undefined;\n public retrieve<T>(propertyName: string, defaultValue: T): T;\n public retrieve<T>(propertyName: string, defaultValue?: T): T | undefined;\n public retrieve<T>(propertyName: string, defaultValue?: T): T | undefined\n {\n return this.recall<T>(propertyName) ?? this.read<T>(propertyName, defaultValue);\n }\n /**\n * Retrieves the value with the specified name from the persistent `localStorage`.\n *\n * @param propertyName The name of the property to retrieve.\n * @param defaultValue The default value to return if the property does not exist.\n *\n * @returns The value of the property or the default value if the property does not exist.\n */\n public read<T>(propertyName: string): T | undefined;\n public read<T>(propertyName: string, defaultValue: T): T;\n public read<T>(propertyName: string, defaultValue?: T): T | undefined;\n public read<T>(propertyName: string, defaultValue?: T): T | undefined\n {\n return this._get<T>(this._persistent, propertyName, defaultValue);\n }\n\n /**\n * Checks whether the property with the specified name exists in the corresponding storage.\n *\n * @param propertyName The name of the property to check.\n * @param persistent Whether to use the persistent `localStorage` or the volatile `sessionStorage`.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public has(propertyName: string, persistent?: boolean): boolean\n {\n const storage = persistent ? this._persistent : this._volatile;\n\n return storage.getItem(propertyName) !== null;\n }\n /**\n * Checks whether the property with the specified name exists in the volatile `sessionStorage`.\n *\n * @param propertyName The name of the property to check.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public knows(propertyName: string): boolean\n {\n return this._volatile.getItem(propertyName) !== null;\n }\n /**\n * Checks whether the property with the specified name exists looking first in the\n * volatile `sessionStorage` and then in the persistent `localStorage`.\n *\n * @param propertyName The name of the property to check.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public find(propertyName: string): boolean\n {\n return this.knows(propertyName) ?? this.exists(propertyName);\n }\n /**\n * Checks whether the property with the specified name exists in the persistent `localStorage`.\n *\n * @param propertyName The name of the property to check.\n *\n * @returns `true` if the property exists, `false` otherwise.\n */\n public exists(propertyName: string): boolean\n {\n return this._persistent.getItem(propertyName) !== null;\n }\n\n /**\n * Sets the value with the specified name in the corresponding storage.\n * If the value is `undefined`, the property is removed from the storage.\n *\n * @param propertyName The name of the property to set.\n * @param newValue The new value to set.\n * @param persistent Whether to use the persistent `localStorage` or the volatile `sessionStorage`.\n */\n public set<T>(propertyName: string, newValue?: T, persistent = this._preferPersistence): void\n {\n const storage = persistent ? this._persistent : this._volatile;\n\n this._set<T>(storage, propertyName, newValue);\n }\n /**\n * Sets the value with the specified name in the volatile `sessionStorage`.\n * If the value is `undefined`, the property is removed from the storage.\n *\n * @param propertyName The name of the property to set.\n * @param newValue The new value to set.\n */\n public remember<T>(propertyName: string, newValue?: T): void\n {\n this._set<T>(this._volatile, propertyName, newValue);\n }\n /**\n * Sets the value with the specified name in the persistent `localStorage`.\n * If the value is `undefined`, the property is removed from the storage.\n *\n * @param propertyName The name of the property to set.\n * @param newValue The new value to set.\n */\n public write<T>(propertyName: string, newValue?: T): void\n {\n this._set<T>(this._persistent, propertyName, newValue);\n }\n\n /**\n * Removes the value with the specified name from the volatile `sessionStorage`.\n *\n * @param propertyName The name of the property to remove.\n */\n public forget(propertyName: string): void\n {\n this._volatile.removeItem(propertyName);\n }\n /**\n * Removes the value with the specified name from the persistent `localStorage`.\n *\n * @param propertyName The name of the property to remove.\n */\n public erase(propertyName: string): void\n {\n this._persistent.removeItem(propertyName);\n }\n /**\n * Removes the value with the specified name from all the storages.\n *\n * @param propertyName The name of the property to remove.\n */\n public clear(propertyName: string): void\n {\n this._volatile.removeItem(propertyName);\n this._persistent.removeItem(propertyName);\n }\n\n public get [Symbol.toStringTag]() { return \"JsonStorage\"; }\n}\n","import Exception from \"./exception.js\";\n\nexport default class Subscribers<P extends unknown[] = [], R = void, T extends (...args: P) => R = (...args: P) => R>\n{\n protected _subscribers: T[];\n\n public constructor()\n {\n this._subscribers = [];\n }\n\n public add(subscriber: T): void\n {\n this._subscribers.push(subscriber);\n }\n public remove(subscriber: T): void\n {\n const index = this._subscribers.indexOf(subscriber);\n if (index < 0)\n {\n throw new Exception(\"Unable to remove the requested subscriber. It was not found.\");\n }\n\n this._subscribers.splice(index, 1);\n }\n\n public call(...args: P): R[]\n {\n return this._subscribers\n .slice()\n .map((subscriber) => subscriber(...args));\n }\n\n public get [Symbol.toStringTag]() { return \"Subscribers\"; }\n}\n","import type {\n PromiseResolver,\n PromiseRejecter,\n FulfilledHandler,\n RejectedHandler,\n PromiseExecutor\n\n} from \"../../types.js\";\n\nexport default class DeferredPromise<T = void, E = unknown, F = T, R = never>\n{\n protected _isPending: boolean;\n protected _isFulfilled: boolean;\n protected _isRejected: boolean;\n\n protected _resolve!: PromiseResolver<T>;\n protected _reject!: PromiseRejecter<E>;\n\n protected _promise: Promise<F | R>;\n\n public constructor(onFulfilled?: FulfilledHandler<T, F> | null, onRejected?: RejectedHandler<E, R> | null)\n {\n this._isPending = true;\n this._isFulfilled = false;\n this._isRejected = false;\n\n let _resolve: PromiseResolver<T>;\n let _reject: PromiseRejecter<E>;\n\n const executor: PromiseExecutor<T, E> = (resolve, reject) =>\n {\n _resolve = resolve;\n _reject = reject;\n };\n\n let _onFulfilled: FulfilledHandler<T, F>;\n if (onFulfilled)\n {\n _onFulfilled = (value) =>\n {\n this._isPending = false;\n this._isFulfilled = true;\n\n return onFulfilled!(value);\n };\n }\n else\n {\n _onFulfilled = (value) =>\n {\n this._isPending = false;\n this._isFulfilled = true;\n\n return (value as unknown) as F;\n };\n }\n\n let _onRejected: RejectedHandler<E, R>;\n if (onRejected)\n {\n _onRejected = (reason) =>\n {\n this._isPending = false;\n this._isRejected = true;\n\n return onRejected!(reason);\n };\n }\n else\n {\n _onRejected = (reason) =>\n {\n this._isPending = false;\n this._isRejected = true;\n\n return (reason as unknown) as R;\n };\n }\n\n this._promise = new Promise<T>(executor)\n .then(_onFulfilled, _onRejected);\n\n this._resolve = _resolve!;\n this._reject = _reject!;\n }\n\n public get isPending(): boolean { return this._isPending; }\n public get isFulfilled(): boolean { return this._isFulfilled; }\n public get isRejected(): boolean { return this._isRejected; }\n\n public get resolve(): PromiseResolver<T> { return this._resolve; }\n public get reject(): PromiseRejecter<E> { return this._reject; }\n\n public then<N = F | R, H = R>(\n onFulfilled?: FulfilledHandler<F | R, N> | null,\n onRejected?: RejectedHandler<R, H> | null): Promise<N | H>\n {\n return this._promise.then(onFulfilled, onRejected);\n }\n public catch<H = R>(onRejected?: RejectedHandler<R, H> | null): Promise<F | R | H>\n {\n return this._promise.catch(onRejected);\n }\n public finally(onFinally?: (() => void) | null): Promise<F | R>\n {\n return this._promise.finally(onFinally);\n }\n\n public watch(promise: Promise<T>): this\n {\n promise.then(this.resolve, this.reject);\n\n return this;\n }\n\n public get [Symbol.toStringTag]() { return \"DeferredPromise\"; }\n}\n","import type { FulfilledHandler, PromiseExecutor, RejectedHandler } from \"../../types.js\";\n\nexport default class SmartPromise<T = void, E = unknown>\n{\n protected _isPending: boolean;\n protected _isFulfilled: boolean;\n protected _isRejected: boolean;\n\n protected _promise: Promise<T | E>;\n\n public constructor(executor: PromiseExecutor<T, E>)\n {\n this._isPending = true;\n this._isFulfilled = false;\n this._isRejected = false;\n\n const _resolve = (result: T): T =>\n {\n this._isPending = false;\n this._isFulfilled = true;\n\n return result;\n };\n const _reject = (reason: E): E =>\n {\n this._isPending = false;\n this._isRejected = true;\n\n return reason;\n };\n\n this._promise = new Promise<T>(executor)\n .then(_resolve, _reject);\n }\n\n public get isPending(): boolean { return this._isPending; }\n public get isFulfilled(): boolean { return this._isFulfilled; }\n public get isRejected(): boolean { return this._isRejected; }\n\n public then<F = T, R = E>(\n onFulfilled?: FulfilledHandler<T | E, F> | null,\n onRejected?: RejectedHandler<E, R> | null): Promise<F | R>\n {\n return this._promise.then(onFulfilled, onRejected);\n }\n public catch<R = E>(onRejected?: RejectedHandler<E, R> | null): Promise<T | E | R>\n {\n return this._promise.catch(onRejected);\n }\n public finally(onFinally?: (() => void) | null): Promise<T | E>\n {\n return this._promise.finally(onFinally);\n }\n\n public get [Symbol.toStringTag]() { return \"SmartPromise\"; }\n}\n","export default class Random\n{\n public static Boolean(ratio: number = 0.5): boolean\n {\n return (Math.random() < ratio);\n }\n\n public static Integer(max: number): number;\n public static Integer(min: number, max: number): number;\n public static Integer(min: number, max?: number): number\n {\n if (max === undefined)\n {\n return Math.floor(Math.random() * min);\n }\n\n return Math.floor(Math.random() * (max - min) + min);\n }\n\n public static Decimal(max: number): number;\n public static Decimal(min: number, max: number): number;\n public static Decimal(min: number, max?: number): number\n {\n if (max === undefined)\n {\n return (Math.random() * min);\n }\n\n return (Math.random() * (max - min) + min);\n }\n\n public static Choice<T>(elements: T[]): T\n {\n return elements[this.Integer(elements.length)];\n }\n\n // eslint-disable-next-line no-useless-constructor\n private constructor() { }\n}\n","export async function delay(milliseconds: number): Promise<void>\n{\n return new Promise<void>((resolve, reject) => setTimeout(resolve, milliseconds));\n}\n\nexport async function nextAnimationFrame(): Promise<void>\n{\n return new Promise<void>((resolve, reject) => requestAnimationFrame(() => resolve()));\n}\n","import { SmartIterator } from \"../models/index.js\";\n\nexport enum DateUnit\n{\n Second = 1000,\n Minute = 60 * Second,\n Hour = 60 * Minute,\n Day = 24 * Hour,\n Week = 7 * Day,\n Month = 30 * Day,\n Year = 365 * Day\n}\n\nexport function dateDifference(start: Date, end: Date, unit = DateUnit.Day): number\n{\n return Math.floor((end.getTime() - start.getTime()) / unit);\n}\n\nexport function dateRange(start: Date, end: Date, offset = DateUnit.Day): SmartIterator<Date>\n{\n return new SmartIterator<Date>(function* ()\n {\n const endTime = end.getTime();\n\n let unixTime: number = start.getTime();\n while (unixTime < endTime)\n {\n yield new Date(unixTime);\n\n unixTime += offset;\n }\n });\n}\n\nexport function dateRound(date: Date, unit = DateUnit.Day): Date\n{\n return new Date(Math.floor(date.getTime() / unit) * unit);\n}\n","export async function loadScript(scriptUrl: string, scriptType = \"text/javascript\"): Promise<void>\n{\n return new Promise<void>((resolve, reject) =>\n {\n const script = document.createElement(\"script\");\n\n script.async = true;\n script.defer = true;\n script.src = scriptUrl;\n script.type = scriptType;\n\n script.onload = () => resolve();\n script.onerror = () => reject();\n\n document.body.appendChild(script);\n });\n}\n","import { SmartIterator } from \"../models/index.js\";\n\nexport function count<T>(elements: Iterable<T>): number\n{\n if (Array.isArray(elements)) { return elements.length; }\n\n let _count = 0;\n for (const _ of elements) { _count += 1; }\n\n return _count;\n}\n\nexport function enumerate<T>(elements: Iterable<T>): SmartIterator<[number, T]>\n{\n return new SmartIterator<[number, T]>(function* ()\n {\n let index = 0;\n\n for (const element of elements)\n {\n yield [index, element];\n\n index += 1;\n }\n });\n}\n\nexport function range(end: number): SmartIterator<number>;\nexport function range(start: number, end: number): SmartIterator<number>;\nexport function range(start: number, end: number, step: number): SmartIterator<number>;\nexport function range(start: number, end?: number, step = 1): SmartIterator<number>\n{\n return new SmartIterator<number>(function* ()\n {\n if (end === undefined)\n {\n end = start;\n start = 0;\n }\n\n if (start > end) { step = step ?? -1; }\n\n for (let index = start; index < end; index += step) { yield index; }\n });\n}\n\nexport function shuffle<T>(iterable: Iterable<T>): T[]\n{\n const array = Array.from(iterable);\n\n for (let index = array.length - 1; index > 0; index -= 1)\n {\n const jndex = Math.floor(Math.random() * (index + 1));\n\n [array[index], array[jndex]] = [array[jndex], array[index]];\n }\n\n return array;\n}\n\nexport function unique<T>(elements: Iterable<T>): SmartIterator<T>\n{\n return new SmartIterator<T>(function* ()\n {\n const values = new Set<T>();\n\n for (const element of elements)\n {\n if (values.has(element)) { continue; }\n\n values.add(element);\n\n yield element;\n }\n });\n}\n\nexport function zip<T, U>(first: Iterable<T>, second: Iterable<U>): SmartIterator<[T, U]>\n{\n return new SmartIterator<[T, U]>(function* ()\n {\n const firstIterator = first[Symbol.iterator]();\n const secondIterator = second[Symbol.iterator]();\n\n while (true)\n {\n const firstResult = firstIterator.next();\n const secondResult = secondIterator.next();\n\n if ((firstResult.done) || (secondResult.done)) { break; }\n\n yield [firstResult.value, secondResult.value];\n }\n });\n}\n","import { zip } from \"./iterator.js\";\n\nexport function average<T extends number>(values: Iterable<T>): number;\nexport function average<T extends number>(values: Iterable<T>, weights: Iterable<number>): number;\nexport function average<T extends number>(values: Iterable<T>, weights?: Iterable<number>): number\n{\n if (weights === undefined)\n {\n let _sum = 0;\n let _count = 0;\n\n for (const value of values)\n {\n _sum += value;\n _count += 1;\n }\n\n return _sum / _count;\n }\n\n let _sum = 0;\n let _count = 0;\n\n for (const [value, weight] of zip(values, weights))\n {\n _sum += value * weight;\n _count += weight;\n }\n\n return _sum / _count;\n}\n\nexport function hash(value: string): number\n{\n let hashedValue = 0;\n for (let index = 0; index < value.length; index += 1)\n {\n const char = value.charCodeAt(index);\n\n hashedValue = ((hashedValue << 5) - hashedValue) + char;\n hashedValue |= 0;\n }\n\n return hashedValue;\n}\n\nexport function sum<T extends number>(values: Iterable<T>): number\n{\n let _sum = 0;\n for (const value of values) { _sum += value; }\n\n return _sum;\n}\n","export function capitalize(value: string): string\n{\n return `${value.charAt(0).toUpperCase()}${value.slice(1)}`;\n}\n","export const VERSION = \"1.4.0\";\n\nexport {\n AggregatedIterator,\n Aggregator,\n DeferredPromise,\n Exception,\n JsonStorage,\n ReducedIterator,\n SmartIterator,\n SmartPromise,\n Subscribers\n\n} from \"./models/index.js\";\n\nexport {\n average,\n capitalize,\n count,\n delay,\n dateDifference,\n dateRange,\n dateRound,\n DateUnit,\n hash,\n loadScript,\n nextAnimationFrame,\n Random,\n range,\n shuffle,\n sum,\n unique,\n zip\n\n} from \"./utils/index.js\";\n\nexport type {\n Constructor,\n FulfilledHandler,\n GeneratorFunction,\n Interval,\n Iteratee,\n MaybePromise,\n PromiseExecutor,\n PromiseRejecter,\n PromiseResolver,\n Reducer,\n RejectedHandler,\n Timeout\n\n} from \"./types.js\";\n"],"names":["Exception","error","exc","message","cause","name","SmartIterator","argument","__publicField","value","predicate","index","result","iterator","iteratee","reducer","initialValue","accumulator","values","ReducedIterator","elements","key","element","_","AggregatedIterator","indexes","accumulators","keys","counters","count","firsts","lasts","groups","Aggregator","JsonStorage","preferPersistence","storage","propertyName","defaultValue","propertyValue","newValue","encodedValue","persistent","Subscribers","subscriber","args","DeferredPromise","onFulfilled","onRejected","_resolve","_reject","executor","resolve","reject","_onFulfilled","_onRejected","reason","onFinally","promise","SmartPromise","Random","ratio","min","max","delay","milliseconds","nextAnimationFrame","DateUnit","dateDifference","start","end","unit","dateRange","offset","endTime","unixTime","dateRound","date","loadScript","scriptUrl","scriptType","script","_count","range","step","shuffle","iterable","array","jndex","unique","zip","first","second","firstIterator","secondIterator","firstResult","secondResult","average","weights","_sum","weight","hash","hashedValue","char","sum","capitalize","VERSION"],"mappings":"oYAAA,MAAqBA,UAAkB,KACvC,CACI,OAAc,YAAYC,EAC1B,CACI,GAAIA,aAAiB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AOiB,EAAOjB,CAClB,CAEA,IAAIiB,EAAO,EACPjB,EAAS,EAEb,SAAW,CAACzE,EAAO2F,CAAM,IAAKV,EAAIxE,EAAQgF,CAAO,EAE7CC,GAAQ1F,EAAQ2F,EACNlB,GAAAkB,EAGd,OAAOD,EAAOjB,CAClB,CAEO,SAASmB,EAAK5F,EACrB,CACI,IAAI6F,EAAc,EAClB,QAAS3F,EAAQ,EAAGA,EAAQF,EAAM,OAAQE,GAAS,EACnD,CACU,MAAA4F,EAAO9F,EAAM,WAAWE,CAAK,EAEnB2F,GAAAA,GAAe,GAAKA,EAAeC,EACpCD,GAAA,CACnB,CAEO,OAAAA,CACX,CAEO,SAASE,EAAsBtF,EACtC,CACI,IAAIiF,EAAO,EACX,UAAW1F,KAASS,EAAkBiF,GAAA1F,EAE/B,OAAA0F,CACX,CCpDO,SAASM,EAAWhG,EAC3B,CACW,MAAA,GAAGA,EAAM,OAAO,CAAC,EAAE,aAAa,GAAGA,EAAM,MAAM,CAAC,CAAC,EAC5D,CCHO,MAAMiG,EAAU"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byloth/core",
3
- "version": "1.3.3",
3
+ "version": "1.4.0",
4
4
  "description": "An unopinionated collection of useful functions and classes that I use widely in all my projects. 🔧",
5
5
  "keywords": [
6
6
  "Core",
@@ -57,10 +57,10 @@
57
57
  },
58
58
  "devDependencies": {
59
59
  "@byloth/eslint-config-typescript": "^2.7.0",
60
- "@typescript-eslint/eslint-plugin": "^7.3.1",
61
- "@typescript-eslint/parser": "^7.3.1",
60
+ "@typescript-eslint/eslint-plugin": "^7.4.0",
61
+ "@typescript-eslint/parser": "^7.4.0",
62
62
  "eslint": "^8.57.0",
63
- "typescript": "^5.4.2",
64
- "vite": "^5.1.6"
63
+ "typescript": "^5.4.3",
64
+ "vite": "^5.2.6"
65
65
  }
66
66
  }
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export const VERSION = "1.3.3";
1
+ export const VERSION = "1.4.0";
2
2
 
3
3
  export {
4
4
  AggregatedIterator,
@@ -96,7 +96,9 @@ export default class AggregatedIterator<K extends PropertyKey, T>
96
96
  }
97
97
  });
98
98
  }
99
- public reduce<A>(reducer: KeyReducer<K, T, A>, initialValue?: A): ReducedIterator<K, A>
99
+ public reduce(reducer: KeyReducer<K, T, T>): ReducedIterator<K, T>;
100
+ public reduce<A>(reducer: KeyReducer<K, T, A>, initialValue: (key: K) => A): ReducedIterator<K, A>;
101
+ public reduce<A>(reducer: KeyReducer<K, T, A>, initialValue?: (key: K) => A): ReducedIterator<K, A>
100
102
  {
101
103
  const accumulators = new Map<K, [number, A]>();
102
104
 
@@ -114,7 +116,7 @@ export default class AggregatedIterator<K extends PropertyKey, T>
114
116
  else if (initialValue !== undefined)
115
117
  {
116
118
  index = 0;
117
- accumulator = initialValue;
119
+ accumulator = initialValue(key);
118
120
  }
119
121
  else
120
122
  {
@@ -215,6 +217,35 @@ export default class AggregatedIterator<K extends PropertyKey, T>
215
217
  });
216
218
  }
217
219
 
220
+ public keys(): SmartIterator<K>
221
+ {
222
+ const elements = this._elements;
223
+
224
+ return new SmartIterator<K>(function* ()
225
+ {
226
+ for (const [key] of elements)
227
+ {
228
+ yield key;
229
+ }
230
+ });
231
+ }
232
+ public items(): SmartIterator<[K, T]>
233
+ {
234
+ return this._elements;
235
+ }
236
+ public values(): SmartIterator<T>
237
+ {
238
+ const elements = this._elements;
239
+
240
+ return new SmartIterator<T>(function* ()
241
+ {
242
+ for (const [_, element] of elements)
243
+ {
244
+ yield element;
245
+ }
246
+ });
247
+ }
248
+
218
249
  public toArray(): T[][]
219
250
  {
220
251
  return Array.from(this.toMap().values());
@@ -247,4 +278,6 @@ export default class AggregatedIterator<K extends PropertyKey, T>
247
278
 
248
279
  return groups;
249
280
  }
281
+
282
+ public get [Symbol.toStringTag]() { return "AggregatedIterator"; }
250
283
  }
@@ -31,7 +31,7 @@ export default class Aggregator<T>
31
31
  return new Aggregator(this._elements.unique());
32
32
  }
33
33
 
34
- public byKey<K extends PropertyKey>(iteratee: Iteratee<T, K>): AggregatedIterator<K, T>
34
+ public groupBy<K extends PropertyKey>(iteratee: Iteratee<T, K>): AggregatedIterator<K, T>
35
35
  {
36
36
  return new AggregatedIterator(this._elements.map((element, index) =>
37
37
  {
@@ -40,6 +40,8 @@ export default class Aggregator<T>
40
40
  return [key, element];
41
41
  }));
42
42
  }
43
+
44
+ public get [Symbol.toStringTag]() { return "Aggregator"; }
43
45
  }
44
46
 
45
47
  export { AggregatedIterator, ReducedIterator };
@@ -44,16 +44,47 @@ export default class ReducedIterator<K extends PropertyKey, T>
44
44
  });
45
45
  }
46
46
 
47
+ public keys(): SmartIterator<K>
48
+ {
49
+ const elements = this._elements;
50
+
51
+ return new SmartIterator<K>(function* ()
52
+ {
53
+ for (const [key] of elements)
54
+ {
55
+ yield key;
56
+ }
57
+ });
58
+ }
59
+ public items(): SmartIterator<[K, T]>
60
+ {
61
+ return this._elements;
62
+ }
63
+ public values(): SmartIterator<T>
64
+ {
65
+ const elements = this._elements;
66
+
67
+ return new SmartIterator<T>(function* ()
68
+ {
69
+ for (const [_, element] of elements)
70
+ {
71
+ yield element;
72
+ }
73
+ });
74
+ }
75
+
47
76
  public toArray(): T[]
48
77
  {
49
- return Array.from(this.toMap().values());
78
+ return Array.from(this.values());
50
79
  }
51
80
  public toMap(): Map<K, T>
52
81
  {
53
- return new Map(this._elements.toArray());
82
+ return new Map(this.items());
54
83
  }
55
84
  public toObject(): Record<K, T>
56
85
  {
57
- return Object.fromEntries(this._elements.toArray()) as Record<K, T>;
86
+ return Object.fromEntries(this.items()) as Record<K, T>;
58
87
  }
88
+
89
+ public get [Symbol.toStringTag]() { return "ReducedIterator"; }
59
90
  }
@@ -38,4 +38,6 @@ export default class Exception extends Error
38
38
  }
39
39
  }
40
40
  }
41
+
42
+ public get [Symbol.toStringTag]() { return "Exception"; }
41
43
  }
@@ -238,4 +238,6 @@ export default class JsonStorage
238
238
  this._volatile.removeItem(propertyName);
239
239
  this._persistent.removeItem(propertyName);
240
240
  }
241
+
242
+ public get [Symbol.toStringTag]() { return "JsonStorage"; }
241
243
  }
@@ -99,6 +99,8 @@ export default class SmartIterator<T, R = void, N = undefined> implements Iterat
99
99
  }
100
100
  });
101
101
  }
102
+ public reduce(reducer: Reducer<T, T>): T;
103
+ public reduce<A>(reducer: Reducer<T, A>, initialValue: A): A;
102
104
  public reduce<A>(reducer: Reducer<T, A>, initialValue?: A): A
103
105
  {
104
106
  let index = 0;
@@ -189,5 +191,7 @@ export default class SmartIterator<T, R = void, N = undefined> implements Iterat
189
191
  return Array.from(this as Iterable<T>);
190
192
  }
191
193
 
194
+ public get [Symbol.toStringTag]() { return "SmartIterator"; }
195
+
192
196
  public [Symbol.iterator](): SmartIterator<T, R, N> { return this; }
193
197
  }
@@ -30,4 +30,6 @@ export default class Subscribers<P extends unknown[] = [], R = void, T extends (
30
30
  .slice()
31
31
  .map((subscriber) => subscriber(...args));
32
32
  }
33
+
34
+ public get [Symbol.toStringTag]() { return "Subscribers"; }
33
35
  }
package/src/types.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  export type Constructor<T extends object, P extends unknown[] = any[]> = new (...args: P) => T;
3
3
 
4
4
  export type GeneratorFunction<T, R = void, N = undefined> = () => Generator<T, R, N>;
5
+ export type AsyncGeneratorFunction<T, R = void, N = undefined> = () => AsyncGenerator<T, R, N>;
5
6
  export type Iteratee<T, R = void> = (value: T, index: number) => R;
6
7
  export type Reducer<T, A> = (accumulator: A, value: T, index: number) => A;
7
8