@byloth/core 1.5.0-rc.4 → 1.5.0-rc.5

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
@@ -114,21 +114,21 @@ class l {
114
114
  return this;
115
115
  }
116
116
  }
117
- class c {
117
+ class a {
118
118
  constructor(e) {
119
119
  u(this, "_elements");
120
120
  this._elements = new l(e);
121
121
  }
122
122
  filter(e) {
123
123
  const t = this._elements;
124
- return new c(function* () {
124
+ return new a(function* () {
125
125
  for (const [n, [r, o]] of t.enumerate())
126
126
  e(r, o, n) && (yield [r, o]);
127
127
  });
128
128
  }
129
129
  map(e) {
130
130
  const t = this._elements;
131
- return new c(function* () {
131
+ return new a(function* () {
132
132
  for (const [n, [r, o]] of t.enumerate())
133
133
  yield [r, e(r, o, n)];
134
134
  });
@@ -174,7 +174,7 @@ class h {
174
174
  const [o, i] = t.get(n) ?? [0, !0];
175
175
  i && t.set(n, [o + 1, e(n, r, o)]);
176
176
  }
177
- return new c(function* () {
177
+ return new a(function* () {
178
178
  for (const [n, [r, o]] of t)
179
179
  yield [n, o];
180
180
  });
@@ -185,7 +185,7 @@ class h {
185
185
  const [o, i] = t.get(n) ?? [0, !1];
186
186
  i || t.set(n, [o + 1, e(n, r, o)]);
187
187
  }
188
- return new c(function* () {
188
+ return new a(function* () {
189
189
  for (const [n, [r, o]] of t)
190
190
  yield [n, o];
191
191
  });
@@ -213,18 +213,18 @@ class h {
213
213
  reduce(e, t) {
214
214
  const n = /* @__PURE__ */ new Map();
215
215
  for (const [r, o] of this._elements) {
216
- let i, a;
216
+ let i, c;
217
217
  if (n.has(r))
218
- [i, a] = n.get(r), i += 1;
218
+ [i, c] = n.get(r), i += 1;
219
219
  else if (t !== void 0)
220
- i = 0, a = t(r);
220
+ i = 0, c = t(r);
221
221
  else {
222
222
  n.set(r, [0, o]);
223
223
  continue;
224
224
  }
225
- a = e(r, a, o, i), n.set(r, [i, a]);
225
+ c = e(r, c, o, i), n.set(r, [i, c]);
226
226
  }
227
- return new c(function* () {
227
+ return new a(function* () {
228
228
  for (const [r, [o, i]] of n)
229
229
  yield [r, i];
230
230
  });
@@ -245,7 +245,7 @@ class h {
245
245
  const n = e.get(t) ?? 0;
246
246
  e.set(t, n + 1);
247
247
  }
248
- return new c(function* () {
248
+ return new a(function* () {
249
249
  for (const [t, n] of e)
250
250
  yield [t, n];
251
251
  });
@@ -254,7 +254,7 @@ class h {
254
254
  const e = /* @__PURE__ */ new Map();
255
255
  for (const [t, n] of this._elements)
256
256
  e.has(t) || e.set(t, n);
257
- return new c(function* () {
257
+ return new a(function* () {
258
258
  for (const [t, n] of e)
259
259
  yield [t, n];
260
260
  });
@@ -263,7 +263,7 @@ class h {
263
263
  const e = /* @__PURE__ */ new Map();
264
264
  for (const [t, n] of this._elements)
265
265
  e.set(t, n);
266
- return new c(function* () {
266
+ return new a(function* () {
267
267
  for (const [t, n] of e)
268
268
  yield [t, n];
269
269
  });
@@ -567,14 +567,15 @@ class w {
567
567
  return "SmartPromise";
568
568
  }
569
569
  }
570
- class P extends w {
570
+ class j extends w {
571
571
  constructor(t, n) {
572
- super((r, o) => {
573
- this._resolve = r, this._reject = o;
572
+ let r, o;
573
+ super((i, c) => {
574
+ r = i, o = c;
574
575
  });
575
576
  u(this, "_resolve");
576
577
  u(this, "_reject");
577
- this._promise.then(t, n);
578
+ this._promise.then(t, n), this._resolve = r, this._reject = o;
578
579
  }
579
580
  get resolve() {
580
581
  return this._resolve;
@@ -589,7 +590,7 @@ class P extends w {
589
590
  return "DeferredPromise";
590
591
  }
591
592
  }
592
- class j extends w {
593
+ class P extends w {
593
594
  constructor(e, t) {
594
595
  super((n, r) => {
595
596
  const o = (d) => {
@@ -692,8 +693,8 @@ function S(s, e) {
692
693
  function Y(s, e) {
693
694
  if (e === void 0) {
694
695
  let o = 0, i = 0;
695
- for (const a of s)
696
- o += a, i += 1;
696
+ for (const c of s)
697
+ o += c, i += 1;
697
698
  if (i === 0)
698
699
  throw new _("You must provide at least one value.");
699
700
  return o / i;
@@ -724,21 +725,21 @@ function B(s) {
724
725
  function H(s) {
725
726
  return `${s.charAt(0).toUpperCase()}${s.slice(1)}`;
726
727
  }
727
- const W = "1.5.0-rc.4";
728
+ const W = "1.5.0-rc.5";
728
729
  export {
729
730
  h as AggregatedIterator,
730
731
  m as Aggregator,
731
732
  b as DateUnit,
732
- P as DeferredPromise,
733
+ j as DeferredPromise,
733
734
  f as Exception,
734
735
  T as JsonStorage,
735
736
  E as Random,
736
- c as ReducedIterator,
737
+ a as ReducedIterator,
737
738
  v as ReferenceException,
738
739
  l as SmartIterator,
739
740
  w as SmartPromise,
740
741
  M as Subscribers,
741
- j as TimedPromise,
742
+ P as TimedPromise,
742
743
  x as TimeoutException,
743
744
  W as VERSION,
744
745
  _ as ValueException,
package/dist/core.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"core.js","sources":["../src/models/smart-iterator.ts","../src/models/aggregators/reduced-iterator.ts","../src/models/aggregators/aggregated-iterator.ts","../src/models/aggregators/index.ts","../src/models/exceptions/core.ts","../src/models/exceptions/index.ts","../src/models/json-storage.ts","../src/models/subscribers.ts","../src/models/promises/smart-promise.ts","../src/models/promises/deferred-promise.ts","../src/models/promises/timed-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":["import type { GeneratorFunction, Iteratee, TypeGuardIteratee, Reducer } from \"../types.js\";\n\nexport default class SmartIterator<T, R = void, N = undefined> implements Iterator<T, R, N>\n{\n protected _iterator: Iterator<T, R, N>;\n\n public return?: (value?: R) => IteratorResult<T, R>;\n public throw?: (error?: unknown) => IteratorResult<T, R>;\n\n public constructor(iterable: Iterable<T>);\n public constructor(iterator: Iterator<T, R, N>);\n public constructor(generatorFn: GeneratorFunction<T, R, N>);\n public constructor(argument: Iterable<T> | Iterator<T, R, N> | GeneratorFunction<T, R, N>);\n public constructor(argument: Iterable<T> | Iterator<T, R, N> | GeneratorFunction<T, R, N>)\n {\n if (argument instanceof Function)\n {\n this._iterator = argument();\n }\n else if (Symbol.iterator in argument)\n {\n this._iterator = argument[Symbol.iterator]() as Iterator<T, R, N>;\n }\n else\n {\n this._iterator = argument;\n }\n\n if (this._iterator.return) { this.return = (value?: R) => this._iterator.return!(value); }\n if (this._iterator.throw) { this.throw = (error?: unknown) => this._iterator.throw!(error); }\n }\n\n public every(predicate: Iteratee<T, boolean>): boolean\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n\n if (result.done) { return true; }\n if (!(predicate(result.value, index))) { return false; }\n\n index += 1;\n }\n }\n public some(predicate: Iteratee<T, boolean>): boolean\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n\n if (result.done) { return false; }\n if (predicate(result.value, index)) { return true; }\n\n index += 1;\n }\n }\n\n public filter(predicate: Iteratee<T, boolean>): SmartIterator<T, R>;\n public filter<S extends T>(predicate: TypeGuardIteratee<T, S>): SmartIterator<T, S>;\n public filter(predicate: Iteratee<T, boolean>): SmartIterator<T, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<T, R>(function* ()\n {\n let index = 0;\n\n while (true)\n {\n const result = iterator.next();\n\n if (result.done) { return result.value; }\n if (predicate(result.value, index)) { yield result.value; }\n\n index += 1;\n }\n });\n }\n public map<V>(iteratee: Iteratee<T, V>): SmartIterator<V, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<V, R>(function* ()\n {\n let index = 0;\n\n while (true)\n {\n const result = iterator.next();\n if (result.done) { return result.value; }\n\n yield iteratee(result.value, index);\n\n index += 1;\n }\n });\n }\n public reduce(reducer: Reducer<T, T>): T;\n public reduce<A>(reducer: Reducer<T, A>, initialValue: A): A;\n public reduce<A>(reducer: Reducer<T, A>, initialValue?: A): A\n {\n let index = 0;\n let accumulator = initialValue;\n if (accumulator === undefined)\n {\n const result = this._iterator.next();\n if (result.done) { throw new TypeError(\"Reduce of empty iterator with no initial value\"); }\n\n accumulator = (result.value as unknown) as A;\n index += 1;\n }\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return accumulator; }\n\n accumulator = reducer(accumulator, result.value, index);\n\n index += 1;\n }\n }\n\n public enumerate(): SmartIterator<[number, T], R>\n {\n return this.map((value, index) => [index, value]);\n }\n public unique(): SmartIterator<T, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<T, R>(function* ()\n {\n const values = new Set<T>();\n\n while (true)\n {\n const result = iterator.next();\n\n if (result.done) { return result.value; }\n if (values.has(result.value)) { continue; }\n\n values.add(result.value);\n\n yield result.value;\n }\n });\n }\n\n public count(): number\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return index; }\n\n index += 1;\n }\n }\n public forEach(iteratee: Iteratee<T>): void\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return; }\n\n iteratee(result.value, index);\n\n index += 1;\n }\n }\n\n public next(...values: N extends undefined ? [] : [N]): IteratorResult<T, R>\n {\n return this._iterator.next(...values);\n }\n\n public toArray(): T[]\n {\n return Array.from(this as Iterable<T>);\n }\n\n public get [Symbol.toStringTag]() { return \"SmartIterator\"; }\n\n public [Symbol.iterator](): SmartIterator<T, R, N> { return this; }\n}\n","import SmartIterator from \"../smart-iterator.js\";\n\nimport type { KeyIteratee, KeyTypeGuardIteratee } from \"./types.js\";\nimport type { GeneratorFunction } from \"../../types.js\";\n\nexport default class ReducedIterator<K extends PropertyKey, T>\n{\n protected _elements: SmartIterator<[K, T]>;\n\n public constructor(iterable: Iterable<[K, T]>);\n public constructor(iterator: Iterator<[K, T]>);\n public constructor(generatorFn: GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public filter(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, T>;\n public filter<S extends T>(predicate: KeyTypeGuardIteratee<K, T, S>): ReducedIterator<K, S>;\n public filter(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, T>\n {\n const elements = this._elements;\n\n return new ReducedIterator(function* ()\n {\n for (const [index, [key, element]] of elements.enumerate())\n {\n if (predicate(key, element, index))\n {\n yield [key, element];\n }\n }\n });\n }\n public map<V>(iteratee: KeyIteratee<K, T, V>): ReducedIterator<K, V>\n {\n const elements = this._elements;\n\n return new ReducedIterator(function* ()\n {\n for (const [index, [key, element]] of elements.enumerate())\n {\n yield [key, iteratee(key, element, index)];\n }\n });\n }\n\n public keys(): SmartIterator<K>\n {\n const elements = this._elements;\n\n return new SmartIterator<K>(function* ()\n {\n for (const [key] of elements)\n {\n yield key;\n }\n });\n }\n public items(): SmartIterator<[K, T]>\n {\n return this._elements;\n }\n public values(): SmartIterator<T>\n {\n const elements = this._elements;\n\n return new SmartIterator<T>(function* ()\n {\n for (const [_, element] of elements)\n {\n yield element;\n }\n });\n }\n\n public toArray(): T[]\n {\n return Array.from(this.values());\n }\n public toMap(): Map<K, T>\n {\n return new Map(this.items());\n }\n public toObject(): Record<K, T>\n {\n return Object.fromEntries(this.items()) as Record<K, T>;\n }\n\n public get [Symbol.toStringTag]() { return \"ReducedIterator\"; }\n}\n","import ReducedIterator from \"./reduced-iterator.js\";\nimport SmartIterator from \"../smart-iterator.js\";\n\nimport type { KeyIteratee, KeyTypeGuardIteratee, KeyReducer } from \"./types.js\";\nimport type { GeneratorFunction } from \"../../types.js\";\n\nexport default class AggregatedIterator<K extends PropertyKey, T>\n{\n protected _elements: SmartIterator<[K, T]>;\n\n public constructor(iterable: Iterable<[K, T]>);\n public constructor(iterator: Iterator<[K, T]>);\n public constructor(generatorFn: GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public every(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, boolean>\n {\n const indexes = new Map<K, [number, boolean]>();\n\n for (const [key, element] of this._elements)\n {\n const [index, result] = indexes.get(key) ?? [0, true];\n\n if (!(result)) { continue; }\n\n indexes.set(key, [index + 1, predicate(key, element, index)]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, result]] of indexes)\n {\n yield [key, result];\n }\n });\n }\n public some(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, boolean>\n {\n const indexes = new Map<K, [number, boolean]>();\n\n for (const [key, element] of this._elements)\n {\n const [index, result] = indexes.get(key) ?? [0, false];\n\n if (result) { continue; }\n\n indexes.set(key, [index + 1, predicate(key, element, index)]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, result]] of indexes)\n {\n yield [key, result];\n }\n });\n }\n\n public filter(predicate: KeyIteratee<K, T, boolean>): AggregatedIterator<K, T>;\n public filter<S extends T>(predicate: KeyTypeGuardIteratee<K, T, S>): AggregatedIterator<K, S>;\n public filter(predicate: KeyIteratee<K, T, boolean>): AggregatedIterator<K, T>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const indexes = new Map<K, number>();\n\n for (const [key, element] of elements)\n {\n const index = indexes.get(key) ?? 0;\n\n indexes.set(key, index + 1);\n\n if (predicate(key, element, index)) { yield [key, element]; }\n }\n });\n }\n public map<V>(iteratee: KeyIteratee<K, T, V>): AggregatedIterator<K, V>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const indexes = new Map<K, number>();\n\n for (const [key, element] of elements)\n {\n const index = indexes.get(key) ?? 0;\n\n indexes.set(key, index + 1);\n\n yield [key, iteratee(key, element, index)];\n }\n });\n }\n public reduce(reducer: KeyReducer<K, T, T>): ReducedIterator<K, T>;\n public reduce<A>(reducer: KeyReducer<K, T, A>, initialValue: (key: K) => A): ReducedIterator<K, A>;\n public reduce<A>(reducer: KeyReducer<K, T, A>, initialValue?: (key: K) => A): ReducedIterator<K, A>\n {\n const accumulators = new Map<K, [number, A]>();\n\n for (const [key, element] of this._elements)\n {\n let index: number;\n let accumulator: A;\n\n if (accumulators.has(key))\n {\n [index, accumulator] = accumulators.get(key)!;\n\n index += 1;\n }\n else if (initialValue !== undefined)\n {\n index = 0;\n accumulator = initialValue(key);\n }\n else\n {\n accumulators.set(key, [0, (element as unknown) as A]);\n\n continue;\n }\n\n accumulator = reducer(key, accumulator, element, index);\n\n accumulators.set(key, [index, accumulator]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, accumulator]] of accumulators)\n {\n yield [key, accumulator];\n }\n });\n }\n\n public unique(): AggregatedIterator<K, T>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const keys = new Map<K, Set<T>>();\n\n for (const [key, element] of elements)\n {\n const values = keys.get(key) ?? new Set<T>();\n\n if (values.has(element)) { continue; }\n\n values.add(element);\n keys.set(key, values);\n\n yield [key, element];\n }\n });\n }\n\n public count(): ReducedIterator<K, number>\n {\n const counters = new Map<K, number>();\n\n for (const [key] of this._elements)\n {\n const count = counters.get(key) ?? 0;\n\n counters.set(key, count + 1);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, count] of counters)\n {\n yield [key, count];\n }\n });\n }\n public first(): ReducedIterator<K, T>\n {\n const firsts = new Map<K, T>();\n\n for (const [key, element] of this._elements)\n {\n if (firsts.has(key)) { continue; }\n\n firsts.set(key, element);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, element] of firsts)\n {\n yield [key, element];\n }\n });\n }\n public last(): ReducedIterator<K, T>\n {\n const lasts = new Map<K, T>();\n\n for (const [key, element] of this._elements)\n {\n lasts.set(key, element);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, element] of lasts)\n {\n yield [key, element];\n }\n });\n }\n\n public keys(): SmartIterator<K>\n {\n const elements = this._elements;\n\n return new SmartIterator<K>(function* ()\n {\n for (const [key] of elements)\n {\n yield key;\n }\n });\n }\n public items(): SmartIterator<[K, T]>\n {\n return this._elements;\n }\n public values(): SmartIterator<T>\n {\n const elements = this._elements;\n\n return new SmartIterator<T>(function* ()\n {\n for (const [_, element] of elements)\n {\n yield element;\n }\n });\n }\n\n public toArray(): T[][]\n {\n return Array.from(this.toMap().values());\n }\n public toMap(): Map<K, T[]>\n {\n const groups = new Map<K, T[]>();\n\n for (const [key, element] of this._elements)\n {\n const value = groups.get(key) ?? [];\n\n value.push(element);\n groups.set(key, value);\n }\n\n return groups;\n }\n public toObject(): Record<K, T[]>\n {\n const groups = { } as Record<K, T[]>;\n\n for (const [key, element] of this._elements)\n {\n const value = groups[key] ?? [];\n\n value.push(element);\n groups[key] = value;\n }\n\n return groups;\n }\n\n public get [Symbol.toStringTag]() { return \"AggregatedIterator\"; }\n}\n","import AggregatedIterator from \"./aggregated-iterator.js\";\nimport ReducedIterator from \"./reduced-iterator.js\";\nimport SmartIterator from \"../smart-iterator.js\";\n\nimport type { GeneratorFunction, Iteratee, TypeGuardIteratee } from \"../../types.js\";\n\nexport default class Aggregator<T>\n{\n protected _elements: SmartIterator<T>;\n\n public constructor(iterable: Iterable<T>);\n public constructor(iterator: Iterator<T>);\n public constructor(generatorFn: GeneratorFunction<T>);\n public constructor(argument: Iterable<T> | Iterator<T> | GeneratorFunction<T>);\n public constructor(argument: Iterable<T> | Iterator<T> | GeneratorFunction<T>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public filter(predicate: Iteratee<T, boolean>): Aggregator<T>;\n public filter<S extends T>(predicate: TypeGuardIteratee<T, S>): Aggregator<S>;\n public filter(predicate: Iteratee<T, boolean>): Aggregator<T>\n {\n return new Aggregator(this._elements.filter(predicate));\n }\n public map<V>(iteratee: Iteratee<T, V>): Aggregator<V>\n {\n return new Aggregator(this._elements.map(iteratee));\n }\n\n public unique(): Aggregator<T>\n {\n return new Aggregator(this._elements.unique());\n }\n\n public groupBy<K extends PropertyKey>(iteratee: Iteratee<T, K>): AggregatedIterator<K, T>\n {\n return new AggregatedIterator(this._elements.map((element, index) =>\n {\n const key = iteratee(element, index);\n\n return [key, element] as [K, T];\n }));\n }\n\n public get [Symbol.toStringTag]() { return \"Aggregator\"; }\n}\n\nexport { AggregatedIterator, ReducedIterator };\nexport type { KeyIteratee, KeyReducer, KeyTypeGuardIteratee } from \"./types.js\";\n","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 Exception from \"./core.js\";\n\nexport class ReferenceException extends Exception\n{\n public constructor(message: string, cause?: unknown, name = \"ReferenceException\")\n {\n super(message, cause, name);\n }\n\n public get [Symbol.toStringTag]() { return \"ReferenceException\"; }\n}\nexport class TimeoutException extends Exception\n{\n public constructor(message: string, cause?: unknown, name = \"TimeoutException\")\n {\n super(message, cause, name);\n }\n\n public get [Symbol.toStringTag]() { return \"TimeoutException\"; }\n}\nexport class ValueException extends Exception\n{\n public constructor(message: string, cause?: unknown, name = \"ValueException\")\n {\n super(message, cause, name);\n }\n\n public get [Symbol.toStringTag]() { return \"ValueException\"; }\n}\n\nexport { Exception };\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 { ReferenceException } from \"./exceptions/index.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 ReferenceException(\"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 { FulfilledHandler, PromiseExecutor, RejectedHandler } from \"../../types.js\";\n\nexport default class SmartPromise<T = void> implements Promise<T>\n{\n protected _isPending: boolean;\n protected _isFulfilled: boolean;\n protected _isRejected: boolean;\n\n protected _promise: Promise<T>;\n\n public constructor(executor: PromiseExecutor<T>)\n {\n this._isPending = true;\n this._isFulfilled = false;\n this._isRejected = false;\n\n const _onFulfilled = (result: T): T =>\n {\n this._isPending = false;\n this._isFulfilled = true;\n\n return result;\n };\n const _onRejected = (reason: unknown): never =>\n {\n this._isPending = false;\n this._isRejected = true;\n\n throw reason;\n };\n\n this._promise = new Promise<T>(executor)\n .then(_onFulfilled, _onRejected);\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(onFulfilled?: null): Promise<T>;\n public then<F = T>(onFulfilled: FulfilledHandler<T, F>, onRejected?: null): Promise<F>;\n public then<F = T, R = never>(onFulfilled: FulfilledHandler<T, F>, onRejected: RejectedHandler<unknown, R>)\n : Promise<F | R>;\n public then<F = T, R = never>(\n onFulfilled?: FulfilledHandler<T, F> | null,\n onRejected?: RejectedHandler<unknown, R> | null): Promise<F | R>\n {\n return this._promise.then(onFulfilled, onRejected);\n }\n\n public catch(onRejected?: null): Promise<T>;\n public catch<R = never>(onRejected: RejectedHandler<unknown, R>): Promise<T | R>;\n public catch<R = never>(onRejected?: RejectedHandler<unknown, R> | null): Promise<T | R>\n {\n return this._promise.catch(onRejected);\n }\n public finally(onFinally?: (() => void) | null): Promise<T>\n {\n return this._promise.finally(onFinally);\n }\n\n public get [Symbol.toStringTag]() { return \"SmartPromise\"; }\n}\n","import type { PromiseResolver, PromiseRejecter, FulfilledHandler, RejectedHandler } from \"../../types.js\";\n\nimport SmartPromise from \"./smart-promise.js\";\n\nexport default class DeferredPromise<T = void, F = T, R = never> extends SmartPromise<F | R>\n{\n protected _resolve!: PromiseResolver<T>;\n protected _reject!: PromiseRejecter;\n\n public constructor(onFulfilled?: FulfilledHandler<T, F> | null, onRejected?: RejectedHandler<unknown, R> | null)\n {\n super((resolve, reject) =>\n {\n this._resolve = resolve as PromiseResolver<T>;\n this._reject = reject;\n });\n\n this._promise\n .then(onFulfilled as FulfilledHandler<F | R>, onRejected as RejectedHandler<unknown, R>);\n }\n\n public get resolve(): PromiseResolver<T> { return this._resolve; }\n public get reject(): PromiseRejecter { return this._reject; }\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 { MaybePromise, PromiseExecutor } from \"../../types.js\";\nimport { TimeoutException } from \"../exceptions/index.js\";\n\nimport SmartPromise from \"./smart-promise.js\";\n\nexport default class TimedPromise<T = void> extends SmartPromise<T>\n{\n public constructor(executor: PromiseExecutor<T>, timeout?: number)\n {\n super((resolve, reject) =>\n {\n const _resolve = (result: MaybePromise<T>) =>\n {\n clearTimeout(_timeoutId);\n resolve(result);\n };\n const _reject = (reason: unknown) =>\n {\n clearTimeout(_timeoutId);\n reject(reason);\n };\n\n const _timeout = () => _reject(new TimeoutException(\"The operation has timed out.\"));\n const _timeoutId = setTimeout(_timeout, timeout);\n\n executor(_resolve, _reject);\n });\n }\n\n public get [Symbol.toStringTag]() { return \"TimedPromise\"; }\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 { ValueException } from \"../models/exceptions/index.js\";\nimport { 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 _index = 0;\n\n for (const value of values)\n {\n _sum += value;\n _index += 1;\n }\n\n if (_index === 0) { throw new ValueException(\"You must provide at least one value.\"); }\n\n return _sum / _index;\n }\n\n let _sum = 0;\n let _count = 0;\n let _index = 0;\n\n for (const [value, weight] of zip(values, weights))\n {\n _sum += value * weight;\n _count += weight;\n _index += 1;\n }\n\n if (_index === 0) { throw new ValueException(\"You must provide at least one value and weight.\"); }\n if (_count === 0) { throw new ValueException(\"The sum of weights must be greater than zero.\"); }\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.5.0-rc.4\";\n\nexport {\n AggregatedIterator,\n Aggregator,\n DeferredPromise,\n Exception,\n JsonStorage,\n ReducedIterator,\n ReferenceException,\n SmartIterator,\n SmartPromise,\n Subscribers,\n TimedPromise,\n TimeoutException,\n ValueException\n\n} from \"./models/index.js\";\nexport type { KeyIteratee, KeyReducer, KeyTypeGuardIteratee } from \"./models/index.js\";\n\nexport {\n average,\n capitalize,\n count,\n delay,\n dateDifference,\n dateRange,\n dateRound,\n DateUnit,\n hash,\n loadScript,\n nextAnimationFrame,\n Random,\n range,\n shuffle,\n sum,\n unique,\n zip\n\n} from \"./utils/index.js\";\n\nexport type {\n AsyncGeneratorFunction,\n Constructor,\n FulfilledHandler,\n GeneratorFunction,\n Interval,\n Iteratee,\n MaybePromise,\n PromiseExecutor,\n PromiseRejecter,\n PromiseResolver,\n Reducer,\n RejectedHandler,\n Timeout,\n TypeGuardIteratee\n\n} from \"./types.js\";\n"],"names":["SmartIterator","argument","__publicField","value","error","predicate","index","result","iterator","iteratee","reducer","initialValue","accumulator","values","ReducedIterator","elements","key","element","_","AggregatedIterator","indexes","accumulators","keys","counters","count","firsts","lasts","groups","Aggregator","Exception","exc","message","cause","name","ReferenceException","TimeoutException","ValueException","JsonStorage","preferPersistence","storage","propertyName","defaultValue","propertyValue","newValue","encodedValue","persistent","Subscribers","subscriber","args","SmartPromise","executor","_onFulfilled","_onRejected","reason","onFulfilled","onRejected","onFinally","DeferredPromise","resolve","reject","promise","TimedPromise","timeout","_resolve","_timeoutId","_reject","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","_index","weight","hash","hashedValue","char","sum","capitalize","VERSION"],"mappings":";;;AAEA,MAAqBA,EACrB;AAAA,EAUW,YAAYC,GACnB;AAVU,IAAAC,EAAA;AAEH,IAAAA,EAAA;AACA,IAAAA,EAAA;AAQH,IAAID,aAAoB,WAEpB,KAAK,YAAYA,MAEZ,OAAO,YAAYA,IAExB,KAAK,YAAYA,EAAS,OAAO,QAAQ,EAAE,IAI3C,KAAK,YAAYA,GAGjB,KAAK,UAAU,WAAU,KAAK,SAAS,CAACE,MAAc,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AAiD;AAC9F,MAAIoD,MAAW;AAAW,UAAA,IAAIpD,EAAe,+CAA+C;AAE5F,SAAOqE,IAAOjB;AAClB;AAEO,SAASoB,EAAKzG,GACrB;AACI,MAAI0G,IAAc;AAClB,WAASvG,IAAQ,GAAGA,IAAQH,EAAM,QAAQG,KAAS,GACnD;AACU,UAAAwG,IAAO3G,EAAM,WAAWG,CAAK;AAEnB,IAAAuG,KAAAA,KAAe,KAAKA,IAAeC,GACpCD,KAAA;AAAA,EACnB;AAEO,SAAAA;AACX;AAEO,SAASE,EAAsBlG,GACtC;AACI,MAAI4F,IAAO;AACX,aAAWtG,KAASU;AAAkB,IAAA4F,KAAAtG;AAE/B,SAAAsG;AACX;AC5DO,SAASO,EAAW7G,GAC3B;AACW,SAAA,GAAGA,EAAM,OAAO,CAAC,EAAE,aAAa,GAAGA,EAAM,MAAM,CAAC,CAAC;AAC5D;ACHO,MAAM8G,IAAU;"}
1
+ {"version":3,"file":"core.js","sources":["../src/models/smart-iterator.ts","../src/models/aggregators/reduced-iterator.ts","../src/models/aggregators/aggregated-iterator.ts","../src/models/aggregators/index.ts","../src/models/exceptions/core.ts","../src/models/exceptions/index.ts","../src/models/json-storage.ts","../src/models/subscribers.ts","../src/models/promises/smart-promise.ts","../src/models/promises/deferred-promise.ts","../src/models/promises/timed-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":["import type { GeneratorFunction, Iteratee, TypeGuardIteratee, Reducer } from \"../types.js\";\n\nexport default class SmartIterator<T, R = void, N = undefined> implements Iterator<T, R, N>\n{\n protected _iterator: Iterator<T, R, N>;\n\n public return?: (value?: R) => IteratorResult<T, R>;\n public throw?: (error?: unknown) => IteratorResult<T, R>;\n\n public constructor(iterable: Iterable<T>);\n public constructor(iterator: Iterator<T, R, N>);\n public constructor(generatorFn: GeneratorFunction<T, R, N>);\n public constructor(argument: Iterable<T> | Iterator<T, R, N> | GeneratorFunction<T, R, N>);\n public constructor(argument: Iterable<T> | Iterator<T, R, N> | GeneratorFunction<T, R, N>)\n {\n if (argument instanceof Function)\n {\n this._iterator = argument();\n }\n else if (Symbol.iterator in argument)\n {\n this._iterator = argument[Symbol.iterator]() as Iterator<T, R, N>;\n }\n else\n {\n this._iterator = argument;\n }\n\n if (this._iterator.return) { this.return = (value?: R) => this._iterator.return!(value); }\n if (this._iterator.throw) { this.throw = (error?: unknown) => this._iterator.throw!(error); }\n }\n\n public every(predicate: Iteratee<T, boolean>): boolean\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n\n if (result.done) { return true; }\n if (!(predicate(result.value, index))) { return false; }\n\n index += 1;\n }\n }\n public some(predicate: Iteratee<T, boolean>): boolean\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n\n if (result.done) { return false; }\n if (predicate(result.value, index)) { return true; }\n\n index += 1;\n }\n }\n\n public filter(predicate: Iteratee<T, boolean>): SmartIterator<T, R>;\n public filter<S extends T>(predicate: TypeGuardIteratee<T, S>): SmartIterator<T, S>;\n public filter(predicate: Iteratee<T, boolean>): SmartIterator<T, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<T, R>(function* ()\n {\n let index = 0;\n\n while (true)\n {\n const result = iterator.next();\n\n if (result.done) { return result.value; }\n if (predicate(result.value, index)) { yield result.value; }\n\n index += 1;\n }\n });\n }\n public map<V>(iteratee: Iteratee<T, V>): SmartIterator<V, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<V, R>(function* ()\n {\n let index = 0;\n\n while (true)\n {\n const result = iterator.next();\n if (result.done) { return result.value; }\n\n yield iteratee(result.value, index);\n\n index += 1;\n }\n });\n }\n public reduce(reducer: Reducer<T, T>): T;\n public reduce<A>(reducer: Reducer<T, A>, initialValue: A): A;\n public reduce<A>(reducer: Reducer<T, A>, initialValue?: A): A\n {\n let index = 0;\n let accumulator = initialValue;\n if (accumulator === undefined)\n {\n const result = this._iterator.next();\n if (result.done) { throw new TypeError(\"Reduce of empty iterator with no initial value\"); }\n\n accumulator = (result.value as unknown) as A;\n index += 1;\n }\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return accumulator; }\n\n accumulator = reducer(accumulator, result.value, index);\n\n index += 1;\n }\n }\n\n public enumerate(): SmartIterator<[number, T], R>\n {\n return this.map((value, index) => [index, value]);\n }\n public unique(): SmartIterator<T, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<T, R>(function* ()\n {\n const values = new Set<T>();\n\n while (true)\n {\n const result = iterator.next();\n\n if (result.done) { return result.value; }\n if (values.has(result.value)) { continue; }\n\n values.add(result.value);\n\n yield result.value;\n }\n });\n }\n\n public count(): number\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return index; }\n\n index += 1;\n }\n }\n public forEach(iteratee: Iteratee<T>): void\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return; }\n\n iteratee(result.value, index);\n\n index += 1;\n }\n }\n\n public next(...values: N extends undefined ? [] : [N]): IteratorResult<T, R>\n {\n return this._iterator.next(...values);\n }\n\n public toArray(): T[]\n {\n return Array.from(this as Iterable<T>);\n }\n\n public get [Symbol.toStringTag]() { return \"SmartIterator\"; }\n\n public [Symbol.iterator](): SmartIterator<T, R, N> { return this; }\n}\n","import SmartIterator from \"../smart-iterator.js\";\n\nimport type { KeyIteratee, KeyTypeGuardIteratee } from \"./types.js\";\nimport type { GeneratorFunction } from \"../../types.js\";\n\nexport default class ReducedIterator<K extends PropertyKey, T>\n{\n protected _elements: SmartIterator<[K, T]>;\n\n public constructor(iterable: Iterable<[K, T]>);\n public constructor(iterator: Iterator<[K, T]>);\n public constructor(generatorFn: GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public filter(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, T>;\n public filter<S extends T>(predicate: KeyTypeGuardIteratee<K, T, S>): ReducedIterator<K, S>;\n public filter(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, T>\n {\n const elements = this._elements;\n\n return new ReducedIterator(function* ()\n {\n for (const [index, [key, element]] of elements.enumerate())\n {\n if (predicate(key, element, index))\n {\n yield [key, element];\n }\n }\n });\n }\n public map<V>(iteratee: KeyIteratee<K, T, V>): ReducedIterator<K, V>\n {\n const elements = this._elements;\n\n return new ReducedIterator(function* ()\n {\n for (const [index, [key, element]] of elements.enumerate())\n {\n yield [key, iteratee(key, element, index)];\n }\n });\n }\n\n public keys(): SmartIterator<K>\n {\n const elements = this._elements;\n\n return new SmartIterator<K>(function* ()\n {\n for (const [key] of elements)\n {\n yield key;\n }\n });\n }\n public items(): SmartIterator<[K, T]>\n {\n return this._elements;\n }\n public values(): SmartIterator<T>\n {\n const elements = this._elements;\n\n return new SmartIterator<T>(function* ()\n {\n for (const [_, element] of elements)\n {\n yield element;\n }\n });\n }\n\n public toArray(): T[]\n {\n return Array.from(this.values());\n }\n public toMap(): Map<K, T>\n {\n return new Map(this.items());\n }\n public toObject(): Record<K, T>\n {\n return Object.fromEntries(this.items()) as Record<K, T>;\n }\n\n public get [Symbol.toStringTag]() { return \"ReducedIterator\"; }\n}\n","import ReducedIterator from \"./reduced-iterator.js\";\nimport SmartIterator from \"../smart-iterator.js\";\n\nimport type { KeyIteratee, KeyTypeGuardIteratee, KeyReducer } from \"./types.js\";\nimport type { GeneratorFunction } from \"../../types.js\";\n\nexport default class AggregatedIterator<K extends PropertyKey, T>\n{\n protected _elements: SmartIterator<[K, T]>;\n\n public constructor(iterable: Iterable<[K, T]>);\n public constructor(iterator: Iterator<[K, T]>);\n public constructor(generatorFn: GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public every(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, boolean>\n {\n const indexes = new Map<K, [number, boolean]>();\n\n for (const [key, element] of this._elements)\n {\n const [index, result] = indexes.get(key) ?? [0, true];\n\n if (!(result)) { continue; }\n\n indexes.set(key, [index + 1, predicate(key, element, index)]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, result]] of indexes)\n {\n yield [key, result];\n }\n });\n }\n public some(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, boolean>\n {\n const indexes = new Map<K, [number, boolean]>();\n\n for (const [key, element] of this._elements)\n {\n const [index, result] = indexes.get(key) ?? [0, false];\n\n if (result) { continue; }\n\n indexes.set(key, [index + 1, predicate(key, element, index)]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, result]] of indexes)\n {\n yield [key, result];\n }\n });\n }\n\n public filter(predicate: KeyIteratee<K, T, boolean>): AggregatedIterator<K, T>;\n public filter<S extends T>(predicate: KeyTypeGuardIteratee<K, T, S>): AggregatedIterator<K, S>;\n public filter(predicate: KeyIteratee<K, T, boolean>): AggregatedIterator<K, T>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const indexes = new Map<K, number>();\n\n for (const [key, element] of elements)\n {\n const index = indexes.get(key) ?? 0;\n\n indexes.set(key, index + 1);\n\n if (predicate(key, element, index)) { yield [key, element]; }\n }\n });\n }\n public map<V>(iteratee: KeyIteratee<K, T, V>): AggregatedIterator<K, V>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const indexes = new Map<K, number>();\n\n for (const [key, element] of elements)\n {\n const index = indexes.get(key) ?? 0;\n\n indexes.set(key, index + 1);\n\n yield [key, iteratee(key, element, index)];\n }\n });\n }\n public reduce(reducer: KeyReducer<K, T, T>): ReducedIterator<K, T>;\n public reduce<A>(reducer: KeyReducer<K, T, A>, initialValue: (key: K) => A): ReducedIterator<K, A>;\n public reduce<A>(reducer: KeyReducer<K, T, A>, initialValue?: (key: K) => A): ReducedIterator<K, A>\n {\n const accumulators = new Map<K, [number, A]>();\n\n for (const [key, element] of this._elements)\n {\n let index: number;\n let accumulator: A;\n\n if (accumulators.has(key))\n {\n [index, accumulator] = accumulators.get(key)!;\n\n index += 1;\n }\n else if (initialValue !== undefined)\n {\n index = 0;\n accumulator = initialValue(key);\n }\n else\n {\n accumulators.set(key, [0, (element as unknown) as A]);\n\n continue;\n }\n\n accumulator = reducer(key, accumulator, element, index);\n\n accumulators.set(key, [index, accumulator]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, accumulator]] of accumulators)\n {\n yield [key, accumulator];\n }\n });\n }\n\n public unique(): AggregatedIterator<K, T>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const keys = new Map<K, Set<T>>();\n\n for (const [key, element] of elements)\n {\n const values = keys.get(key) ?? new Set<T>();\n\n if (values.has(element)) { continue; }\n\n values.add(element);\n keys.set(key, values);\n\n yield [key, element];\n }\n });\n }\n\n public count(): ReducedIterator<K, number>\n {\n const counters = new Map<K, number>();\n\n for (const [key] of this._elements)\n {\n const count = counters.get(key) ?? 0;\n\n counters.set(key, count + 1);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, count] of counters)\n {\n yield [key, count];\n }\n });\n }\n public first(): ReducedIterator<K, T>\n {\n const firsts = new Map<K, T>();\n\n for (const [key, element] of this._elements)\n {\n if (firsts.has(key)) { continue; }\n\n firsts.set(key, element);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, element] of firsts)\n {\n yield [key, element];\n }\n });\n }\n public last(): ReducedIterator<K, T>\n {\n const lasts = new Map<K, T>();\n\n for (const [key, element] of this._elements)\n {\n lasts.set(key, element);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, element] of lasts)\n {\n yield [key, element];\n }\n });\n }\n\n public keys(): SmartIterator<K>\n {\n const elements = this._elements;\n\n return new SmartIterator<K>(function* ()\n {\n for (const [key] of elements)\n {\n yield key;\n }\n });\n }\n public items(): SmartIterator<[K, T]>\n {\n return this._elements;\n }\n public values(): SmartIterator<T>\n {\n const elements = this._elements;\n\n return new SmartIterator<T>(function* ()\n {\n for (const [_, element] of elements)\n {\n yield element;\n }\n });\n }\n\n public toArray(): T[][]\n {\n return Array.from(this.toMap().values());\n }\n public toMap(): Map<K, T[]>\n {\n const groups = new Map<K, T[]>();\n\n for (const [key, element] of this._elements)\n {\n const value = groups.get(key) ?? [];\n\n value.push(element);\n groups.set(key, value);\n }\n\n return groups;\n }\n public toObject(): Record<K, T[]>\n {\n const groups = { } as Record<K, T[]>;\n\n for (const [key, element] of this._elements)\n {\n const value = groups[key] ?? [];\n\n value.push(element);\n groups[key] = value;\n }\n\n return groups;\n }\n\n public get [Symbol.toStringTag]() { return \"AggregatedIterator\"; }\n}\n","import AggregatedIterator from \"./aggregated-iterator.js\";\nimport ReducedIterator from \"./reduced-iterator.js\";\nimport SmartIterator from \"../smart-iterator.js\";\n\nimport type { GeneratorFunction, Iteratee, TypeGuardIteratee } from \"../../types.js\";\n\nexport default class Aggregator<T>\n{\n protected _elements: SmartIterator<T>;\n\n public constructor(iterable: Iterable<T>);\n public constructor(iterator: Iterator<T>);\n public constructor(generatorFn: GeneratorFunction<T>);\n public constructor(argument: Iterable<T> | Iterator<T> | GeneratorFunction<T>);\n public constructor(argument: Iterable<T> | Iterator<T> | GeneratorFunction<T>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public filter(predicate: Iteratee<T, boolean>): Aggregator<T>;\n public filter<S extends T>(predicate: TypeGuardIteratee<T, S>): Aggregator<S>;\n public filter(predicate: Iteratee<T, boolean>): Aggregator<T>\n {\n return new Aggregator(this._elements.filter(predicate));\n }\n public map<V>(iteratee: Iteratee<T, V>): Aggregator<V>\n {\n return new Aggregator(this._elements.map(iteratee));\n }\n\n public unique(): Aggregator<T>\n {\n return new Aggregator(this._elements.unique());\n }\n\n public groupBy<K extends PropertyKey>(iteratee: Iteratee<T, K>): AggregatedIterator<K, T>\n {\n return new AggregatedIterator(this._elements.map((element, index) =>\n {\n const key = iteratee(element, index);\n\n return [key, element] as [K, T];\n }));\n }\n\n public get [Symbol.toStringTag]() { return \"Aggregator\"; }\n}\n\nexport { AggregatedIterator, ReducedIterator };\nexport type { KeyIteratee, KeyReducer, KeyTypeGuardIteratee } from \"./types.js\";\n","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 Exception from \"./core.js\";\n\nexport class ReferenceException extends Exception\n{\n public constructor(message: string, cause?: unknown, name = \"ReferenceException\")\n {\n super(message, cause, name);\n }\n\n public get [Symbol.toStringTag]() { return \"ReferenceException\"; }\n}\nexport class TimeoutException extends Exception\n{\n public constructor(message: string, cause?: unknown, name = \"TimeoutException\")\n {\n super(message, cause, name);\n }\n\n public get [Symbol.toStringTag]() { return \"TimeoutException\"; }\n}\nexport class ValueException extends Exception\n{\n public constructor(message: string, cause?: unknown, name = \"ValueException\")\n {\n super(message, cause, name);\n }\n\n public get [Symbol.toStringTag]() { return \"ValueException\"; }\n}\n\nexport { Exception };\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 { ReferenceException } from \"./exceptions/index.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 ReferenceException(\"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 { FulfilledHandler, PromiseExecutor, RejectedHandler } from \"../../types.js\";\n\nexport default class SmartPromise<T = void> implements Promise<T>\n{\n protected _isPending: boolean;\n protected _isFulfilled: boolean;\n protected _isRejected: boolean;\n\n protected _promise: Promise<T>;\n\n public constructor(executor: PromiseExecutor<T>)\n {\n this._isPending = true;\n this._isFulfilled = false;\n this._isRejected = false;\n\n const _onFulfilled = (result: T): T =>\n {\n this._isPending = false;\n this._isFulfilled = true;\n\n return result;\n };\n const _onRejected = (reason: unknown): never =>\n {\n this._isPending = false;\n this._isRejected = true;\n\n throw reason;\n };\n\n this._promise = new Promise<T>(executor)\n .then(_onFulfilled, _onRejected);\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(onFulfilled?: null): Promise<T>;\n public then<F = T>(onFulfilled: FulfilledHandler<T, F>, onRejected?: null): Promise<F>;\n public then<F = T, R = never>(onFulfilled: FulfilledHandler<T, F>, onRejected: RejectedHandler<unknown, R>)\n : Promise<F | R>;\n public then<F = T, R = never>(\n onFulfilled?: FulfilledHandler<T, F> | null,\n onRejected?: RejectedHandler<unknown, R> | null): Promise<F | R>\n {\n return this._promise.then(onFulfilled, onRejected);\n }\n\n public catch(onRejected?: null): Promise<T>;\n public catch<R = never>(onRejected: RejectedHandler<unknown, R>): Promise<T | R>;\n public catch<R = never>(onRejected?: RejectedHandler<unknown, R> | null): Promise<T | R>\n {\n return this._promise.catch(onRejected);\n }\n public finally(onFinally?: (() => void) | null): Promise<T>\n {\n return this._promise.finally(onFinally);\n }\n\n public get [Symbol.toStringTag]() { return \"SmartPromise\"; }\n}\n","import type { PromiseResolver, PromiseRejecter, FulfilledHandler, RejectedHandler } from \"../../types.js\";\n\nimport SmartPromise from \"./smart-promise.js\";\n\nexport default class DeferredPromise<T = void, F = T, R = never> extends SmartPromise<F | R>\n{\n protected _resolve: PromiseResolver<T>;\n protected _reject: PromiseRejecter;\n\n public constructor(onFulfilled?: FulfilledHandler<T, F> | null, onRejected?: RejectedHandler<unknown, R> | null)\n {\n let _resolve: PromiseResolver<T>;\n let _reject: PromiseRejecter;\n\n super((resolve, reject) =>\n {\n // ReferenceError: Must call super constructor in derived class before accessing\n // 'this' or returning from derived constructor.\n //\n _resolve = resolve as PromiseResolver<T>;\n _reject = reject;\n });\n\n this._promise.then(onFulfilled as FulfilledHandler<F | R>, onRejected);\n\n this._resolve = _resolve!;\n this._reject = _reject!;\n }\n\n public get resolve(): PromiseResolver<T> { return this._resolve; }\n public get reject(): PromiseRejecter { return this._reject; }\n\n public watch(otherPromise: PromiseLike<T>): this\n {\n otherPromise.then(this.resolve, this.reject);\n\n return this;\n }\n\n public get [Symbol.toStringTag]() { return \"DeferredPromise\"; }\n}\n","import type { MaybePromise, PromiseExecutor } from \"../../types.js\";\nimport { TimeoutException } from \"../exceptions/index.js\";\n\nimport SmartPromise from \"./smart-promise.js\";\n\nexport default class TimedPromise<T = void> extends SmartPromise<T>\n{\n public constructor(executor: PromiseExecutor<T>, timeout?: number)\n {\n super((resolve, reject) =>\n {\n const _resolve = (result: MaybePromise<T>) =>\n {\n clearTimeout(_timeoutId);\n resolve(result);\n };\n const _reject = (reason: unknown) =>\n {\n clearTimeout(_timeoutId);\n reject(reason);\n };\n\n const _timeout = () => _reject(new TimeoutException(\"The operation has timed out.\"));\n const _timeoutId = setTimeout(_timeout, timeout);\n\n executor(_resolve, _reject);\n });\n }\n\n public get [Symbol.toStringTag]() { return \"TimedPromise\"; }\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 { ValueException } from \"../models/exceptions/index.js\";\nimport { 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 _index = 0;\n\n for (const value of values)\n {\n _sum += value;\n _index += 1;\n }\n\n if (_index === 0) { throw new ValueException(\"You must provide at least one value.\"); }\n\n return _sum / _index;\n }\n\n let _sum = 0;\n let _count = 0;\n let _index = 0;\n\n for (const [value, weight] of zip(values, weights))\n {\n _sum += value * weight;\n _count += weight;\n _index += 1;\n }\n\n if (_index === 0) { throw new ValueException(\"You must provide at least one value and weight.\"); }\n if (_count === 0) { throw new ValueException(\"The sum of weights must be greater than zero.\"); }\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.5.0-rc.5\";\n\nexport {\n AggregatedIterator,\n Aggregator,\n DeferredPromise,\n Exception,\n JsonStorage,\n ReducedIterator,\n ReferenceException,\n SmartIterator,\n SmartPromise,\n Subscribers,\n TimedPromise,\n TimeoutException,\n ValueException\n\n} from \"./models/index.js\";\nexport type { KeyIteratee, KeyReducer, KeyTypeGuardIteratee } from \"./models/index.js\";\n\nexport {\n average,\n capitalize,\n count,\n delay,\n dateDifference,\n dateRange,\n dateRound,\n DateUnit,\n hash,\n loadScript,\n nextAnimationFrame,\n Random,\n range,\n shuffle,\n sum,\n unique,\n zip\n\n} from \"./utils/index.js\";\n\nexport type {\n AsyncGeneratorFunction,\n Constructor,\n FulfilledHandler,\n GeneratorFunction,\n Interval,\n Iteratee,\n MaybePromise,\n PromiseExecutor,\n PromiseRejecter,\n PromiseResolver,\n Reducer,\n RejectedHandler,\n Timeout,\n TypeGuardIteratee\n\n} from \"./types.js\";\n"],"names":["SmartIterator","argument","__publicField","value","error","predicate","index","result","iterator","iteratee","reducer","initialValue","accumulator","values","ReducedIterator","elements","key","element","_","AggregatedIterator","indexes","accumulators","keys","counters","count","firsts","lasts","groups","Aggregator","Exception","exc","message","cause","name","ReferenceException","TimeoutException","ValueException","JsonStorage","preferPersistence","storage","propertyName","defaultValue","propertyValue","newValue","encodedValue","persistent","Subscribers","subscriber","args","SmartPromise","executor","_onFulfilled","_onRejected","reason","onFulfilled","onRejected","onFinally","DeferredPromise","_resolve","_reject","resolve","reject","otherPromise","TimedPromise","timeout","_timeoutId","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","_index","weight","hash","hashedValue","char","sum","capitalize","VERSION"],"mappings":";;;AAEA,MAAqBA,EACrB;AAAA,EAUW,YAAYC,GACnB;AAVU,IAAAC,EAAA;AAEH,IAAAA,EAAA;AACA,IAAAA,EAAA;AAQH,IAAID,aAAoB,WAEpB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AAID,IAAO,GACPjB,IAAS,GACTkB,IAAS;AAEb,aAAW,CAACvG,GAAOwG,CAAM,KAAKX,EAAInF,GAAQ2F,CAAO;AAE7C,IAAAC,KAAQtG,IAAQwG,GACNnB,KAAAmB,GACAD,KAAA;AAGd,MAAIA,MAAW;AAAW,UAAA,IAAItE,EAAe,iDAAiD;AAC9F,MAAIoD,MAAW;AAAW,UAAA,IAAIpD,EAAe,+CAA+C;AAE5F,SAAOqE,IAAOjB;AAClB;AAEO,SAASoB,EAAKzG,GACrB;AACI,MAAI0G,IAAc;AAClB,WAASvG,IAAQ,GAAGA,IAAQH,EAAM,QAAQG,KAAS,GACnD;AACU,UAAAwG,IAAO3G,EAAM,WAAWG,CAAK;AAEnB,IAAAuG,KAAAA,KAAe,KAAKA,IAAeC,GACpCD,KAAA;AAAA,EACnB;AAEO,SAAAA;AACX;AAEO,SAASE,EAAsBlG,GACtC;AACI,MAAI4F,IAAO;AACX,aAAWtG,KAASU;AAAkB,IAAA4F,KAAAtG;AAE/B,SAAAsG;AACX;AC5DO,SAASO,EAAW7G,GAC3B;AACW,SAAA,GAAGA,EAAM,OAAO,CAAC,EAAE,aAAa,GAAGA,EAAM,MAAM,CAAC,CAAC;AAC5D;ACHO,MAAM8G,IAAU;"}
package/dist/core.umd.cjs CHANGED
@@ -1,6 +1,6 @@
1
- (function(o,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(o=typeof globalThis<"u"?globalThis:o||self,u(o.Core={}))})(this,function(o){"use strict";var H=Object.defineProperty;var W=(o,u,a)=>u in o?H(o,u,{enumerable:!0,configurable:!0,writable:!0,value:a}):o[u]=a;var l=(o,u,a)=>(W(o,typeof u!="symbol"?u+"":u,a),a);class u{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 u(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 u(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 u(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 a{constructor(e){l(this,"_elements");this._elements=new u(e)}filter(e){const t=this._elements;return new a(function*(){for(const[n,[r,i]]of t.enumerate())e(r,i,n)&&(yield[r,i])})}map(e){const t=this._elements;return new a(function*(){for(const[n,[r,i]]of t.enumerate())yield[r,e(r,i,n)]})}keys(){const e=this._elements;return new u(function*(){for(const[t]of e)yield t})}items(){return this._elements}values(){const e=this._elements;return new u(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){l(this,"_elements");this._elements=new u(e)}every(e){const t=new Map;for(const[n,r]of this._elements){const[i,c]=t.get(n)??[0,!0];c&&t.set(n,[i+1,e(n,r,i)])}return new a(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,c]=t.get(n)??[0,!1];c||t.set(n,[i+1,e(n,r,i)])}return new a(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 c=n.get(r)??0;n.set(r,c+1),e(r,i,c)&&(yield[r,i])}})}map(e){const t=this._elements;return new m(function*(){const n=new Map;for(const[r,i]of t){const c=n.get(r)??0;n.set(r,c+1),yield[r,e(r,i,c)]}})}reduce(e,t){const n=new Map;for(const[r,i]of this._elements){let c,h;if(n.has(r))[c,h]=n.get(r),c+=1;else if(t!==void 0)c=0,h=t(r);else{n.set(r,[0,i]);continue}h=e(r,h,i,c),n.set(r,[c,h])}return new a(function*(){for(const[r,[i,c]]of n)yield[r,c]})}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 a(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 a(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 a(function*(){for(const[t,n]of e)yield[t,n]})}keys(){const e=this._elements;return new u(function*(){for(const[t]of e)yield t})}items(){return this._elements}values(){const e=this._elements;return new u(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 d{constructor(e){l(this,"_elements");this._elements=new u(e)}filter(e){return new d(this._elements.filter(e))}map(e){return new d(this._elements.map(e))}unique(){return new d(this._elements.unique())}groupBy(e){return new m(this._elements.map((t,n)=>[e(t,n),t]))}get[Symbol.toStringTag](){return"Aggregator"}}class f extends Error{static FromUnknown(e){if(e instanceof f)return e;if(e instanceof Error){const t=new f(e.message);return t.stack=e.stack,t.name=e.name,t}return new f(`${e}`)}constructor(e,t,n="Exception"){super(e),this.cause=t,this.name=n,t&&(t instanceof Error?this.stack+=`
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 H=Object.defineProperty;var W=(o,c,a)=>c in o?H(o,c,{enumerable:!0,configurable:!0,writable:!0,value:a}):o[c]=a;var l=(o,c,a)=>(W(o,typeof c!="symbol"?c+"":c,a),a);class c{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 c(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 c(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 c(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 a{constructor(e){l(this,"_elements");this._elements=new c(e)}filter(e){const t=this._elements;return new a(function*(){for(const[n,[r,i]]of t.enumerate())e(r,i,n)&&(yield[r,i])})}map(e){const t=this._elements;return new a(function*(){for(const[n,[r,i]]of t.enumerate())yield[r,e(r,i,n)]})}keys(){const e=this._elements;return new c(function*(){for(const[t]of e)yield t})}items(){return this._elements}values(){const e=this._elements;return new c(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){l(this,"_elements");this._elements=new c(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 a(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 a(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,f;if(n.has(r))[u,f]=n.get(r),u+=1;else if(t!==void 0)u=0,f=t(r);else{n.set(r,[0,i]);continue}f=e(r,f,i,u),n.set(r,[u,f])}return new a(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 a(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 a(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 a(function*(){for(const[t,n]of e)yield[t,n]})}keys(){const e=this._elements;return new c(function*(){for(const[t]of e)yield t})}items(){return this._elements}values(){const e=this._elements;return new c(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 d{constructor(e){l(this,"_elements");this._elements=new c(e)}filter(e){return new d(this._elements.filter(e))}map(e){return new d(this._elements.map(e))}unique(){return new d(this._elements.unique())}groupBy(e){return new m(this._elements.map((t,n)=>[e(t,n),t]))}get[Symbol.toStringTag](){return"Aggregator"}}class h extends Error{static FromUnknown(e){if(e instanceof h)return e;if(e instanceof Error){const t=new h(e.message);return t.stack=e.stack,t.name=e.name,t}return new h(`${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}`)}get[Symbol.toStringTag](){return"Exception"}}class w extends f{constructor(e,t,n="ReferenceException"){super(e,t,n)}get[Symbol.toStringTag](){return"ReferenceException"}}class v extends f{constructor(e,t,n="TimeoutException"){super(e,t,n)}get[Symbol.toStringTag](){return"TimeoutException"}}class _ extends f{constructor(e,t,n="ValueException"){super(e,t,n)}get[Symbol.toStringTag](){return"ValueException"}}class T{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)}get[Symbol.toStringTag](){return"JsonStorage"}}class k{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 w("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 g{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=>{throw 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 x extends g{constructor(t,n){super((r,i)=>{this._resolve=r,this._reject=i});l(this,"_resolve");l(this,"_reject");this._promise.then(t,n)}get resolve(){return this._resolve}get reject(){return this._reject}watch(t){return t.then(this.resolve,this.reject),this}get[Symbol.toStringTag](){return"DeferredPromise"}}class M extends g{constructor(e,t){super((n,r)=>{const i=y=>{clearTimeout(b),n(y)},c=y=>{clearTimeout(b),r(y)},b=setTimeout(()=>c(new v("The operation has timed out.")),t);e(i,c)})}get[Symbol.toStringTag](){return"TimedPromise"}}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 E(s){return new Promise((e,t)=>setTimeout(e,s))}async function R(){return new Promise((s,e)=>requestAnimationFrame(()=>s()))}var p=(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))(p||{});function j(s,e,t=864e5){return Math.floor((e.getTime()-s.getTime())/t)}function I(s,e,t=864e5){return new u(function*(){const n=e.getTime();let r=s.getTime();for(;r<n;)yield new Date(r),r+=t})}function A(s,e=864e5){return new Date(Math.floor(s.getTime()/e)*e)}async function F(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 O(s){if(Array.isArray(s))return s.length;let e=0;for(const t of s)e+=1;return e}function q(s,e,t=1){return new u(function*(){e===void 0&&(e=s,s=0),s>e&&(t=t??-1);for(let n=s;n<e;n+=t)yield n})}function C(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 V(s){return new u(function*(){const e=new Set;for(const t of s)e.has(t)||(e.add(t),yield t)})}function S(s,e){return new u(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 $(s,e){if(e===void 0){let i=0,c=0;for(const h of s)i+=h,c+=1;if(c===0)throw new _("You must provide at least one value.");return i/c}let t=0,n=0,r=0;for(const[i,c]of S(s,e))t+=i*c,n+=c,r+=1;if(r===0)throw new _("You must provide at least one value and weight.");if(n===0)throw new _("The sum of weights must be greater than zero.");return t/n}function z(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 J(s){let e=0;for(const t of s)e+=t;return e}function Y(s){return`${s.charAt(0).toUpperCase()}${s.slice(1)}`}const B="1.5.0-rc.4";o.AggregatedIterator=m,o.Aggregator=d,o.DateUnit=p,o.DeferredPromise=x,o.Exception=f,o.JsonStorage=T,o.Random=P,o.ReducedIterator=a,o.ReferenceException=w,o.SmartIterator=u,o.SmartPromise=g,o.Subscribers=k,o.TimedPromise=M,o.TimeoutException=v,o.VERSION=B,o.ValueException=_,o.average=$,o.capitalize=Y,o.count=O,o.dateDifference=j,o.dateRange=I,o.dateRound=A,o.delay=E,o.hash=z,o.loadScript=F,o.nextAnimationFrame=R,o.range=q,o.shuffle=C,o.sum=J,o.unique=V,o.zip=S,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
5
+ Caused by ${t}`)}get[Symbol.toStringTag](){return"Exception"}}class w extends h{constructor(e,t,n="ReferenceException"){super(e,t,n)}get[Symbol.toStringTag](){return"ReferenceException"}}class v extends h{constructor(e,t,n="TimeoutException"){super(e,t,n)}get[Symbol.toStringTag](){return"TimeoutException"}}class _ extends h{constructor(e,t,n="ValueException"){super(e,t,n)}get[Symbol.toStringTag](){return"ValueException"}}class T{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)}get[Symbol.toStringTag](){return"JsonStorage"}}class k{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 w("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 g{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=>{throw 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 x extends g{constructor(t,n){let r,i;super((u,f)=>{r=u,i=f});l(this,"_resolve");l(this,"_reject");this._promise.then(t,n),this._resolve=r,this._reject=i}get resolve(){return this._resolve}get reject(){return this._reject}watch(t){return t.then(this.resolve,this.reject),this}get[Symbol.toStringTag](){return"DeferredPromise"}}class M extends g{constructor(e,t){super((n,r)=>{const i=y=>{clearTimeout(b),n(y)},u=y=>{clearTimeout(b),r(y)},b=setTimeout(()=>u(new v("The operation has timed out.")),t);e(i,u)})}get[Symbol.toStringTag](){return"TimedPromise"}}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 j(s){return new Promise((e,t)=>setTimeout(e,s))}async function E(){return new Promise((s,e)=>requestAnimationFrame(()=>s()))}var p=(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))(p||{});function R(s,e,t=864e5){return Math.floor((e.getTime()-s.getTime())/t)}function I(s,e,t=864e5){return new c(function*(){const n=e.getTime();let r=s.getTime();for(;r<n;)yield new Date(r),r+=t})}function A(s,e=864e5){return new Date(Math.floor(s.getTime()/e)*e)}async function F(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 O(s){if(Array.isArray(s))return s.length;let e=0;for(const t of s)e+=1;return e}function q(s,e,t=1){return new c(function*(){e===void 0&&(e=s,s=0),s>e&&(t=t??-1);for(let n=s;n<e;n+=t)yield n})}function C(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 V(s){return new c(function*(){const e=new Set;for(const t of s)e.has(t)||(e.add(t),yield t)})}function S(s,e){return new c(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 $(s,e){if(e===void 0){let i=0,u=0;for(const f of s)i+=f,u+=1;if(u===0)throw new _("You must provide at least one value.");return i/u}let t=0,n=0,r=0;for(const[i,u]of S(s,e))t+=i*u,n+=u,r+=1;if(r===0)throw new _("You must provide at least one value and weight.");if(n===0)throw new _("The sum of weights must be greater than zero.");return t/n}function z(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 J(s){let e=0;for(const t of s)e+=t;return e}function Y(s){return`${s.charAt(0).toUpperCase()}${s.slice(1)}`}const B="1.5.0-rc.5";o.AggregatedIterator=m,o.Aggregator=d,o.DateUnit=p,o.DeferredPromise=x,o.Exception=h,o.JsonStorage=T,o.Random=P,o.ReducedIterator=a,o.ReferenceException=w,o.SmartIterator=c,o.SmartPromise=g,o.Subscribers=k,o.TimedPromise=M,o.TimeoutException=v,o.VERSION=B,o.ValueException=_,o.average=$,o.capitalize=Y,o.count=O,o.dateDifference=R,o.dateRange=I,o.dateRound=A,o.delay=j,o.hash=z,o.loadScript=F,o.nextAnimationFrame=E,o.range=q,o.shuffle=C,o.sum=J,o.unique=V,o.zip=S,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/smart-iterator.ts","../src/models/aggregators/reduced-iterator.ts","../src/models/aggregators/aggregated-iterator.ts","../src/models/aggregators/index.ts","../src/models/exceptions/core.ts","../src/models/exceptions/index.ts","../src/models/json-storage.ts","../src/models/subscribers.ts","../src/models/promises/smart-promise.ts","../src/models/promises/deferred-promise.ts","../src/models/promises/timed-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":["import type { GeneratorFunction, Iteratee, TypeGuardIteratee, Reducer } from \"../types.js\";\n\nexport default class SmartIterator<T, R = void, N = undefined> implements Iterator<T, R, N>\n{\n protected _iterator: Iterator<T, R, N>;\n\n public return?: (value?: R) => IteratorResult<T, R>;\n public throw?: (error?: unknown) => IteratorResult<T, R>;\n\n public constructor(iterable: Iterable<T>);\n public constructor(iterator: Iterator<T, R, N>);\n public constructor(generatorFn: GeneratorFunction<T, R, N>);\n public constructor(argument: Iterable<T> | Iterator<T, R, N> | GeneratorFunction<T, R, N>);\n public constructor(argument: Iterable<T> | Iterator<T, R, N> | GeneratorFunction<T, R, N>)\n {\n if (argument instanceof Function)\n {\n this._iterator = argument();\n }\n else if (Symbol.iterator in argument)\n {\n this._iterator = argument[Symbol.iterator]() as Iterator<T, R, N>;\n }\n else\n {\n this._iterator = argument;\n }\n\n if (this._iterator.return) { this.return = (value?: R) => this._iterator.return!(value); }\n if (this._iterator.throw) { this.throw = (error?: unknown) => this._iterator.throw!(error); }\n }\n\n public every(predicate: Iteratee<T, boolean>): boolean\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n\n if (result.done) { return true; }\n if (!(predicate(result.value, index))) { return false; }\n\n index += 1;\n }\n }\n public some(predicate: Iteratee<T, boolean>): boolean\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n\n if (result.done) { return false; }\n if (predicate(result.value, index)) { return true; }\n\n index += 1;\n }\n }\n\n public filter(predicate: Iteratee<T, boolean>): SmartIterator<T, R>;\n public filter<S extends T>(predicate: TypeGuardIteratee<T, S>): SmartIterator<T, S>;\n public filter(predicate: Iteratee<T, boolean>): SmartIterator<T, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<T, R>(function* ()\n {\n let index = 0;\n\n while (true)\n {\n const result = iterator.next();\n\n if (result.done) { return result.value; }\n if (predicate(result.value, index)) { yield result.value; }\n\n index += 1;\n }\n });\n }\n public map<V>(iteratee: Iteratee<T, V>): SmartIterator<V, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<V, R>(function* ()\n {\n let index = 0;\n\n while (true)\n {\n const result = iterator.next();\n if (result.done) { return result.value; }\n\n yield iteratee(result.value, index);\n\n index += 1;\n }\n });\n }\n public reduce(reducer: Reducer<T, T>): T;\n public reduce<A>(reducer: Reducer<T, A>, initialValue: A): A;\n public reduce<A>(reducer: Reducer<T, A>, initialValue?: A): A\n {\n let index = 0;\n let accumulator = initialValue;\n if (accumulator === undefined)\n {\n const result = this._iterator.next();\n if (result.done) { throw new TypeError(\"Reduce of empty iterator with no initial value\"); }\n\n accumulator = (result.value as unknown) as A;\n index += 1;\n }\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return accumulator; }\n\n accumulator = reducer(accumulator, result.value, index);\n\n index += 1;\n }\n }\n\n public enumerate(): SmartIterator<[number, T], R>\n {\n return this.map((value, index) => [index, value]);\n }\n public unique(): SmartIterator<T, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<T, R>(function* ()\n {\n const values = new Set<T>();\n\n while (true)\n {\n const result = iterator.next();\n\n if (result.done) { return result.value; }\n if (values.has(result.value)) { continue; }\n\n values.add(result.value);\n\n yield result.value;\n }\n });\n }\n\n public count(): number\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return index; }\n\n index += 1;\n }\n }\n public forEach(iteratee: Iteratee<T>): void\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return; }\n\n iteratee(result.value, index);\n\n index += 1;\n }\n }\n\n public next(...values: N extends undefined ? [] : [N]): IteratorResult<T, R>\n {\n return this._iterator.next(...values);\n }\n\n public toArray(): T[]\n {\n return Array.from(this as Iterable<T>);\n }\n\n public get [Symbol.toStringTag]() { return \"SmartIterator\"; }\n\n public [Symbol.iterator](): SmartIterator<T, R, N> { return this; }\n}\n","import SmartIterator from \"../smart-iterator.js\";\n\nimport type { KeyIteratee, KeyTypeGuardIteratee } from \"./types.js\";\nimport type { GeneratorFunction } from \"../../types.js\";\n\nexport default class ReducedIterator<K extends PropertyKey, T>\n{\n protected _elements: SmartIterator<[K, T]>;\n\n public constructor(iterable: Iterable<[K, T]>);\n public constructor(iterator: Iterator<[K, T]>);\n public constructor(generatorFn: GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public filter(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, T>;\n public filter<S extends T>(predicate: KeyTypeGuardIteratee<K, T, S>): ReducedIterator<K, S>;\n public filter(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, T>\n {\n const elements = this._elements;\n\n return new ReducedIterator(function* ()\n {\n for (const [index, [key, element]] of elements.enumerate())\n {\n if (predicate(key, element, index))\n {\n yield [key, element];\n }\n }\n });\n }\n public map<V>(iteratee: KeyIteratee<K, T, V>): ReducedIterator<K, V>\n {\n const elements = this._elements;\n\n return new ReducedIterator(function* ()\n {\n for (const [index, [key, element]] of elements.enumerate())\n {\n yield [key, iteratee(key, element, index)];\n }\n });\n }\n\n public keys(): SmartIterator<K>\n {\n const elements = this._elements;\n\n return new SmartIterator<K>(function* ()\n {\n for (const [key] of elements)\n {\n yield key;\n }\n });\n }\n public items(): SmartIterator<[K, T]>\n {\n return this._elements;\n }\n public values(): SmartIterator<T>\n {\n const elements = this._elements;\n\n return new SmartIterator<T>(function* ()\n {\n for (const [_, element] of elements)\n {\n yield element;\n }\n });\n }\n\n public toArray(): T[]\n {\n return Array.from(this.values());\n }\n public toMap(): Map<K, T>\n {\n return new Map(this.items());\n }\n public toObject(): Record<K, T>\n {\n return Object.fromEntries(this.items()) as Record<K, T>;\n }\n\n public get [Symbol.toStringTag]() { return \"ReducedIterator\"; }\n}\n","import ReducedIterator from \"./reduced-iterator.js\";\nimport SmartIterator from \"../smart-iterator.js\";\n\nimport type { KeyIteratee, KeyTypeGuardIteratee, KeyReducer } from \"./types.js\";\nimport type { GeneratorFunction } from \"../../types.js\";\n\nexport default class AggregatedIterator<K extends PropertyKey, T>\n{\n protected _elements: SmartIterator<[K, T]>;\n\n public constructor(iterable: Iterable<[K, T]>);\n public constructor(iterator: Iterator<[K, T]>);\n public constructor(generatorFn: GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public every(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, boolean>\n {\n const indexes = new Map<K, [number, boolean]>();\n\n for (const [key, element] of this._elements)\n {\n const [index, result] = indexes.get(key) ?? [0, true];\n\n if (!(result)) { continue; }\n\n indexes.set(key, [index + 1, predicate(key, element, index)]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, result]] of indexes)\n {\n yield [key, result];\n }\n });\n }\n public some(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, boolean>\n {\n const indexes = new Map<K, [number, boolean]>();\n\n for (const [key, element] of this._elements)\n {\n const [index, result] = indexes.get(key) ?? [0, false];\n\n if (result) { continue; }\n\n indexes.set(key, [index + 1, predicate(key, element, index)]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, result]] of indexes)\n {\n yield [key, result];\n }\n });\n }\n\n public filter(predicate: KeyIteratee<K, T, boolean>): AggregatedIterator<K, T>;\n public filter<S extends T>(predicate: KeyTypeGuardIteratee<K, T, S>): AggregatedIterator<K, S>;\n public filter(predicate: KeyIteratee<K, T, boolean>): AggregatedIterator<K, T>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const indexes = new Map<K, number>();\n\n for (const [key, element] of elements)\n {\n const index = indexes.get(key) ?? 0;\n\n indexes.set(key, index + 1);\n\n if (predicate(key, element, index)) { yield [key, element]; }\n }\n });\n }\n public map<V>(iteratee: KeyIteratee<K, T, V>): AggregatedIterator<K, V>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const indexes = new Map<K, number>();\n\n for (const [key, element] of elements)\n {\n const index = indexes.get(key) ?? 0;\n\n indexes.set(key, index + 1);\n\n yield [key, iteratee(key, element, index)];\n }\n });\n }\n public reduce(reducer: KeyReducer<K, T, T>): ReducedIterator<K, T>;\n public reduce<A>(reducer: KeyReducer<K, T, A>, initialValue: (key: K) => A): ReducedIterator<K, A>;\n public reduce<A>(reducer: KeyReducer<K, T, A>, initialValue?: (key: K) => A): ReducedIterator<K, A>\n {\n const accumulators = new Map<K, [number, A]>();\n\n for (const [key, element] of this._elements)\n {\n let index: number;\n let accumulator: A;\n\n if (accumulators.has(key))\n {\n [index, accumulator] = accumulators.get(key)!;\n\n index += 1;\n }\n else if (initialValue !== undefined)\n {\n index = 0;\n accumulator = initialValue(key);\n }\n else\n {\n accumulators.set(key, [0, (element as unknown) as A]);\n\n continue;\n }\n\n accumulator = reducer(key, accumulator, element, index);\n\n accumulators.set(key, [index, accumulator]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, accumulator]] of accumulators)\n {\n yield [key, accumulator];\n }\n });\n }\n\n public unique(): AggregatedIterator<K, T>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const keys = new Map<K, Set<T>>();\n\n for (const [key, element] of elements)\n {\n const values = keys.get(key) ?? new Set<T>();\n\n if (values.has(element)) { continue; }\n\n values.add(element);\n keys.set(key, values);\n\n yield [key, element];\n }\n });\n }\n\n public count(): ReducedIterator<K, number>\n {\n const counters = new Map<K, number>();\n\n for (const [key] of this._elements)\n {\n const count = counters.get(key) ?? 0;\n\n counters.set(key, count + 1);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, count] of counters)\n {\n yield [key, count];\n }\n });\n }\n public first(): ReducedIterator<K, T>\n {\n const firsts = new Map<K, T>();\n\n for (const [key, element] of this._elements)\n {\n if (firsts.has(key)) { continue; }\n\n firsts.set(key, element);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, element] of firsts)\n {\n yield [key, element];\n }\n });\n }\n public last(): ReducedIterator<K, T>\n {\n const lasts = new Map<K, T>();\n\n for (const [key, element] of this._elements)\n {\n lasts.set(key, element);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, element] of lasts)\n {\n yield [key, element];\n }\n });\n }\n\n public keys(): SmartIterator<K>\n {\n const elements = this._elements;\n\n return new SmartIterator<K>(function* ()\n {\n for (const [key] of elements)\n {\n yield key;\n }\n });\n }\n public items(): SmartIterator<[K, T]>\n {\n return this._elements;\n }\n public values(): SmartIterator<T>\n {\n const elements = this._elements;\n\n return new SmartIterator<T>(function* ()\n {\n for (const [_, element] of elements)\n {\n yield element;\n }\n });\n }\n\n public toArray(): T[][]\n {\n return Array.from(this.toMap().values());\n }\n public toMap(): Map<K, T[]>\n {\n const groups = new Map<K, T[]>();\n\n for (const [key, element] of this._elements)\n {\n const value = groups.get(key) ?? [];\n\n value.push(element);\n groups.set(key, value);\n }\n\n return groups;\n }\n public toObject(): Record<K, T[]>\n {\n const groups = { } as Record<K, T[]>;\n\n for (const [key, element] of this._elements)\n {\n const value = groups[key] ?? [];\n\n value.push(element);\n groups[key] = value;\n }\n\n return groups;\n }\n\n public get [Symbol.toStringTag]() { return \"AggregatedIterator\"; }\n}\n","import AggregatedIterator from \"./aggregated-iterator.js\";\nimport ReducedIterator from \"./reduced-iterator.js\";\nimport SmartIterator from \"../smart-iterator.js\";\n\nimport type { GeneratorFunction, Iteratee, TypeGuardIteratee } from \"../../types.js\";\n\nexport default class Aggregator<T>\n{\n protected _elements: SmartIterator<T>;\n\n public constructor(iterable: Iterable<T>);\n public constructor(iterator: Iterator<T>);\n public constructor(generatorFn: GeneratorFunction<T>);\n public constructor(argument: Iterable<T> | Iterator<T> | GeneratorFunction<T>);\n public constructor(argument: Iterable<T> | Iterator<T> | GeneratorFunction<T>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public filter(predicate: Iteratee<T, boolean>): Aggregator<T>;\n public filter<S extends T>(predicate: TypeGuardIteratee<T, S>): Aggregator<S>;\n public filter(predicate: Iteratee<T, boolean>): Aggregator<T>\n {\n return new Aggregator(this._elements.filter(predicate));\n }\n public map<V>(iteratee: Iteratee<T, V>): Aggregator<V>\n {\n return new Aggregator(this._elements.map(iteratee));\n }\n\n public unique(): Aggregator<T>\n {\n return new Aggregator(this._elements.unique());\n }\n\n public groupBy<K extends PropertyKey>(iteratee: Iteratee<T, K>): AggregatedIterator<K, T>\n {\n return new AggregatedIterator(this._elements.map((element, index) =>\n {\n const key = iteratee(element, index);\n\n return [key, element] as [K, T];\n }));\n }\n\n public get [Symbol.toStringTag]() { return \"Aggregator\"; }\n}\n\nexport { AggregatedIterator, ReducedIterator };\nexport type { KeyIteratee, KeyReducer, KeyTypeGuardIteratee } from \"./types.js\";\n","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 Exception from \"./core.js\";\n\nexport class ReferenceException extends Exception\n{\n public constructor(message: string, cause?: unknown, name = \"ReferenceException\")\n {\n super(message, cause, name);\n }\n\n public get [Symbol.toStringTag]() { return \"ReferenceException\"; }\n}\nexport class TimeoutException extends Exception\n{\n public constructor(message: string, cause?: unknown, name = \"TimeoutException\")\n {\n super(message, cause, name);\n }\n\n public get [Symbol.toStringTag]() { return \"TimeoutException\"; }\n}\nexport class ValueException extends Exception\n{\n public constructor(message: string, cause?: unknown, name = \"ValueException\")\n {\n super(message, cause, name);\n }\n\n public get [Symbol.toStringTag]() { return \"ValueException\"; }\n}\n\nexport { Exception };\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 { ReferenceException } from \"./exceptions/index.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 ReferenceException(\"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 { FulfilledHandler, PromiseExecutor, RejectedHandler } from \"../../types.js\";\n\nexport default class SmartPromise<T = void> implements Promise<T>\n{\n protected _isPending: boolean;\n protected _isFulfilled: boolean;\n protected _isRejected: boolean;\n\n protected _promise: Promise<T>;\n\n public constructor(executor: PromiseExecutor<T>)\n {\n this._isPending = true;\n this._isFulfilled = false;\n this._isRejected = false;\n\n const _onFulfilled = (result: T): T =>\n {\n this._isPending = false;\n this._isFulfilled = true;\n\n return result;\n };\n const _onRejected = (reason: unknown): never =>\n {\n this._isPending = false;\n this._isRejected = true;\n\n throw reason;\n };\n\n this._promise = new Promise<T>(executor)\n .then(_onFulfilled, _onRejected);\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(onFulfilled?: null): Promise<T>;\n public then<F = T>(onFulfilled: FulfilledHandler<T, F>, onRejected?: null): Promise<F>;\n public then<F = T, R = never>(onFulfilled: FulfilledHandler<T, F>, onRejected: RejectedHandler<unknown, R>)\n : Promise<F | R>;\n public then<F = T, R = never>(\n onFulfilled?: FulfilledHandler<T, F> | null,\n onRejected?: RejectedHandler<unknown, R> | null): Promise<F | R>\n {\n return this._promise.then(onFulfilled, onRejected);\n }\n\n public catch(onRejected?: null): Promise<T>;\n public catch<R = never>(onRejected: RejectedHandler<unknown, R>): Promise<T | R>;\n public catch<R = never>(onRejected?: RejectedHandler<unknown, R> | null): Promise<T | R>\n {\n return this._promise.catch(onRejected);\n }\n public finally(onFinally?: (() => void) | null): Promise<T>\n {\n return this._promise.finally(onFinally);\n }\n\n public get [Symbol.toStringTag]() { return \"SmartPromise\"; }\n}\n","import type { PromiseResolver, PromiseRejecter, FulfilledHandler, RejectedHandler } from \"../../types.js\";\n\nimport SmartPromise from \"./smart-promise.js\";\n\nexport default class DeferredPromise<T = void, F = T, R = never> extends SmartPromise<F | R>\n{\n protected _resolve!: PromiseResolver<T>;\n protected _reject!: PromiseRejecter;\n\n public constructor(onFulfilled?: FulfilledHandler<T, F> | null, onRejected?: RejectedHandler<unknown, R> | null)\n {\n super((resolve, reject) =>\n {\n this._resolve = resolve as PromiseResolver<T>;\n this._reject = reject;\n });\n\n this._promise\n .then(onFulfilled as FulfilledHandler<F | R>, onRejected as RejectedHandler<unknown, R>);\n }\n\n public get resolve(): PromiseResolver<T> { return this._resolve; }\n public get reject(): PromiseRejecter { return this._reject; }\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 { MaybePromise, PromiseExecutor } from \"../../types.js\";\nimport { TimeoutException } from \"../exceptions/index.js\";\n\nimport SmartPromise from \"./smart-promise.js\";\n\nexport default class TimedPromise<T = void> extends SmartPromise<T>\n{\n public constructor(executor: PromiseExecutor<T>, timeout?: number)\n {\n super((resolve, reject) =>\n {\n const _resolve = (result: MaybePromise<T>) =>\n {\n clearTimeout(_timeoutId);\n resolve(result);\n };\n const _reject = (reason: unknown) =>\n {\n clearTimeout(_timeoutId);\n reject(reason);\n };\n\n const _timeout = () => _reject(new TimeoutException(\"The operation has timed out.\"));\n const _timeoutId = setTimeout(_timeout, timeout);\n\n executor(_resolve, _reject);\n });\n }\n\n public get [Symbol.toStringTag]() { return \"TimedPromise\"; }\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 { ValueException } from \"../models/exceptions/index.js\";\nimport { 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 _index = 0;\n\n for (const value of values)\n {\n _sum += value;\n _index += 1;\n }\n\n if (_index === 0) { throw new ValueException(\"You must provide at least one value.\"); }\n\n return _sum / _index;\n }\n\n let _sum = 0;\n let _count = 0;\n let _index = 0;\n\n for (const [value, weight] of zip(values, weights))\n {\n _sum += value * weight;\n _count += weight;\n _index += 1;\n }\n\n if (_index === 0) { throw new ValueException(\"You must provide at least one value and weight.\"); }\n if (_count === 0) { throw new ValueException(\"The sum of weights must be greater than zero.\"); }\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.5.0-rc.4\";\n\nexport {\n AggregatedIterator,\n Aggregator,\n DeferredPromise,\n Exception,\n JsonStorage,\n ReducedIterator,\n ReferenceException,\n SmartIterator,\n SmartPromise,\n Subscribers,\n TimedPromise,\n TimeoutException,\n ValueException\n\n} from \"./models/index.js\";\nexport type { KeyIteratee, KeyReducer, KeyTypeGuardIteratee } from \"./models/index.js\";\n\nexport {\n average,\n capitalize,\n count,\n delay,\n dateDifference,\n dateRange,\n dateRound,\n DateUnit,\n hash,\n loadScript,\n nextAnimationFrame,\n Random,\n range,\n shuffle,\n sum,\n unique,\n zip\n\n} from \"./utils/index.js\";\n\nexport type {\n AsyncGeneratorFunction,\n Constructor,\n FulfilledHandler,\n GeneratorFunction,\n Interval,\n Iteratee,\n MaybePromise,\n PromiseExecutor,\n PromiseRejecter,\n PromiseResolver,\n Reducer,\n RejectedHandler,\n Timeout,\n TypeGuardIteratee\n\n} from \"./types.js\";\n"],"names":["SmartIterator","argument","__publicField","value","error","predicate","index","result","iterator","iteratee","reducer","initialValue","accumulator","values","ReducedIterator","elements","key","element","_","AggregatedIterator","indexes","accumulators","keys","counters","count","firsts","lasts","groups","Aggregator","Exception","exc","message","cause","name","ReferenceException","TimeoutException","ValueException","JsonStorage","preferPersistence","storage","propertyName","defaultValue","propertyValue","newValue","encodedValue","persistent","Subscribers","subscriber","args","SmartPromise","executor","_onFulfilled","_onRejected","reason","onFulfilled","onRejected","onFinally","DeferredPromise","resolve","reject","promise","TimedPromise","timeout","_resolve","_timeoutId","_reject","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","_index","weight","hash","hashedValue","char","sum","capitalize","VERSION"],"mappings":"oYAEA,MAAqBA,CACrB,CAUW,YAAYC,EACnB,CAVUC,EAAA,kBAEHA,EAAA,eACAA,EAAA,cAQCD,aAAoB,SAEpB,KAAK,UAAYA,IAEZ,OAAO,YAAYA,EAExB,KAAK,UAAYA,EAAS,OAAO,QAAQ,EAAE,EAI3C,KAAK,UAAYA,EAGjB,KAAK,UAAU,SAAU,KAAK,OAAUE,GAAc,KAAK,UAAU,OAAQA,CAAK,GAClF,KAAK,UAAU,QAAS,KAAK,MAASC,GAAoB,KAAK,UAAU,MAAOA,CAAK,EAC7F,CAEO,MAAMC,EACb,CACI,IAAIC,EAAQ,EAGZ,OACA,CACU,MAAAC,EAAS,KAAK,UAAU,KAAK,EAEnC,GAAIA,EAAO,KAAe,MAAA,GAC1B,GAAI,CAAEF,EAAUE,EAAO,MAAOD,CAAK,EAAa,MAAA,GAEvCA,GAAA,CACb,CACJ,CACO,KAAKD,EACZ,CACI,IAAIC,EAAQ,EAGZ,OACA,CACU,MAAAC,EAAS,KAAK,UAAU,KAAK,EAEnC,GAAIA,EAAO,KAAe,MAAA,GAC1B,GAAIF,EAAUE,EAAO,MAAOD,CAAK,EAAY,MAAA,GAEpCA,GAAA,CACb,CACJ,CAIO,OAAOD,EACd,CACI,MAAMG,EAAW,KAAK,UAEf,OAAA,IAAIR,EAAoB,WAC/B,CACI,IAAIM,EAAQ,EAEZ,OACA,CACU,MAAAC,EAASC,EAAS,OAExB,GAAID,EAAO,KAAQ,OAAOA,EAAO,MAC7BF,EAAUE,EAAO,MAAOD,CAAK,IAAK,MAAMC,EAAO,OAE1CD,GAAA,CACb,CAAA,CACH,CACL,CACO,IAAOG,EACd,CACI,MAAMD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"version":3,"file":"core.umd.cjs","sources":["../src/models/smart-iterator.ts","../src/models/aggregators/reduced-iterator.ts","../src/models/aggregators/aggregated-iterator.ts","../src/models/aggregators/index.ts","../src/models/exceptions/core.ts","../src/models/exceptions/index.ts","../src/models/json-storage.ts","../src/models/subscribers.ts","../src/models/promises/smart-promise.ts","../src/models/promises/deferred-promise.ts","../src/models/promises/timed-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":["import type { GeneratorFunction, Iteratee, TypeGuardIteratee, Reducer } from \"../types.js\";\n\nexport default class SmartIterator<T, R = void, N = undefined> implements Iterator<T, R, N>\n{\n protected _iterator: Iterator<T, R, N>;\n\n public return?: (value?: R) => IteratorResult<T, R>;\n public throw?: (error?: unknown) => IteratorResult<T, R>;\n\n public constructor(iterable: Iterable<T>);\n public constructor(iterator: Iterator<T, R, N>);\n public constructor(generatorFn: GeneratorFunction<T, R, N>);\n public constructor(argument: Iterable<T> | Iterator<T, R, N> | GeneratorFunction<T, R, N>);\n public constructor(argument: Iterable<T> | Iterator<T, R, N> | GeneratorFunction<T, R, N>)\n {\n if (argument instanceof Function)\n {\n this._iterator = argument();\n }\n else if (Symbol.iterator in argument)\n {\n this._iterator = argument[Symbol.iterator]() as Iterator<T, R, N>;\n }\n else\n {\n this._iterator = argument;\n }\n\n if (this._iterator.return) { this.return = (value?: R) => this._iterator.return!(value); }\n if (this._iterator.throw) { this.throw = (error?: unknown) => this._iterator.throw!(error); }\n }\n\n public every(predicate: Iteratee<T, boolean>): boolean\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n\n if (result.done) { return true; }\n if (!(predicate(result.value, index))) { return false; }\n\n index += 1;\n }\n }\n public some(predicate: Iteratee<T, boolean>): boolean\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n\n if (result.done) { return false; }\n if (predicate(result.value, index)) { return true; }\n\n index += 1;\n }\n }\n\n public filter(predicate: Iteratee<T, boolean>): SmartIterator<T, R>;\n public filter<S extends T>(predicate: TypeGuardIteratee<T, S>): SmartIterator<T, S>;\n public filter(predicate: Iteratee<T, boolean>): SmartIterator<T, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<T, R>(function* ()\n {\n let index = 0;\n\n while (true)\n {\n const result = iterator.next();\n\n if (result.done) { return result.value; }\n if (predicate(result.value, index)) { yield result.value; }\n\n index += 1;\n }\n });\n }\n public map<V>(iteratee: Iteratee<T, V>): SmartIterator<V, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<V, R>(function* ()\n {\n let index = 0;\n\n while (true)\n {\n const result = iterator.next();\n if (result.done) { return result.value; }\n\n yield iteratee(result.value, index);\n\n index += 1;\n }\n });\n }\n public reduce(reducer: Reducer<T, T>): T;\n public reduce<A>(reducer: Reducer<T, A>, initialValue: A): A;\n public reduce<A>(reducer: Reducer<T, A>, initialValue?: A): A\n {\n let index = 0;\n let accumulator = initialValue;\n if (accumulator === undefined)\n {\n const result = this._iterator.next();\n if (result.done) { throw new TypeError(\"Reduce of empty iterator with no initial value\"); }\n\n accumulator = (result.value as unknown) as A;\n index += 1;\n }\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return accumulator; }\n\n accumulator = reducer(accumulator, result.value, index);\n\n index += 1;\n }\n }\n\n public enumerate(): SmartIterator<[number, T], R>\n {\n return this.map((value, index) => [index, value]);\n }\n public unique(): SmartIterator<T, R>\n {\n const iterator = this._iterator;\n\n return new SmartIterator<T, R>(function* ()\n {\n const values = new Set<T>();\n\n while (true)\n {\n const result = iterator.next();\n\n if (result.done) { return result.value; }\n if (values.has(result.value)) { continue; }\n\n values.add(result.value);\n\n yield result.value;\n }\n });\n }\n\n public count(): number\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return index; }\n\n index += 1;\n }\n }\n public forEach(iteratee: Iteratee<T>): void\n {\n let index = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true)\n {\n const result = this._iterator.next();\n if (result.done) { return; }\n\n iteratee(result.value, index);\n\n index += 1;\n }\n }\n\n public next(...values: N extends undefined ? [] : [N]): IteratorResult<T, R>\n {\n return this._iterator.next(...values);\n }\n\n public toArray(): T[]\n {\n return Array.from(this as Iterable<T>);\n }\n\n public get [Symbol.toStringTag]() { return \"SmartIterator\"; }\n\n public [Symbol.iterator](): SmartIterator<T, R, N> { return this; }\n}\n","import SmartIterator from \"../smart-iterator.js\";\n\nimport type { KeyIteratee, KeyTypeGuardIteratee } from \"./types.js\";\nimport type { GeneratorFunction } from \"../../types.js\";\n\nexport default class ReducedIterator<K extends PropertyKey, T>\n{\n protected _elements: SmartIterator<[K, T]>;\n\n public constructor(iterable: Iterable<[K, T]>);\n public constructor(iterator: Iterator<[K, T]>);\n public constructor(generatorFn: GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public filter(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, T>;\n public filter<S extends T>(predicate: KeyTypeGuardIteratee<K, T, S>): ReducedIterator<K, S>;\n public filter(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, T>\n {\n const elements = this._elements;\n\n return new ReducedIterator(function* ()\n {\n for (const [index, [key, element]] of elements.enumerate())\n {\n if (predicate(key, element, index))\n {\n yield [key, element];\n }\n }\n });\n }\n public map<V>(iteratee: KeyIteratee<K, T, V>): ReducedIterator<K, V>\n {\n const elements = this._elements;\n\n return new ReducedIterator(function* ()\n {\n for (const [index, [key, element]] of elements.enumerate())\n {\n yield [key, iteratee(key, element, index)];\n }\n });\n }\n\n public keys(): SmartIterator<K>\n {\n const elements = this._elements;\n\n return new SmartIterator<K>(function* ()\n {\n for (const [key] of elements)\n {\n yield key;\n }\n });\n }\n public items(): SmartIterator<[K, T]>\n {\n return this._elements;\n }\n public values(): SmartIterator<T>\n {\n const elements = this._elements;\n\n return new SmartIterator<T>(function* ()\n {\n for (const [_, element] of elements)\n {\n yield element;\n }\n });\n }\n\n public toArray(): T[]\n {\n return Array.from(this.values());\n }\n public toMap(): Map<K, T>\n {\n return new Map(this.items());\n }\n public toObject(): Record<K, T>\n {\n return Object.fromEntries(this.items()) as Record<K, T>;\n }\n\n public get [Symbol.toStringTag]() { return \"ReducedIterator\"; }\n}\n","import ReducedIterator from \"./reduced-iterator.js\";\nimport SmartIterator from \"../smart-iterator.js\";\n\nimport type { KeyIteratee, KeyTypeGuardIteratee, KeyReducer } from \"./types.js\";\nimport type { GeneratorFunction } from \"../../types.js\";\n\nexport default class AggregatedIterator<K extends PropertyKey, T>\n{\n protected _elements: SmartIterator<[K, T]>;\n\n public constructor(iterable: Iterable<[K, T]>);\n public constructor(iterator: Iterator<[K, T]>);\n public constructor(generatorFn: GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>);\n public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public every(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, boolean>\n {\n const indexes = new Map<K, [number, boolean]>();\n\n for (const [key, element] of this._elements)\n {\n const [index, result] = indexes.get(key) ?? [0, true];\n\n if (!(result)) { continue; }\n\n indexes.set(key, [index + 1, predicate(key, element, index)]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, result]] of indexes)\n {\n yield [key, result];\n }\n });\n }\n public some(predicate: KeyIteratee<K, T, boolean>): ReducedIterator<K, boolean>\n {\n const indexes = new Map<K, [number, boolean]>();\n\n for (const [key, element] of this._elements)\n {\n const [index, result] = indexes.get(key) ?? [0, false];\n\n if (result) { continue; }\n\n indexes.set(key, [index + 1, predicate(key, element, index)]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, result]] of indexes)\n {\n yield [key, result];\n }\n });\n }\n\n public filter(predicate: KeyIteratee<K, T, boolean>): AggregatedIterator<K, T>;\n public filter<S extends T>(predicate: KeyTypeGuardIteratee<K, T, S>): AggregatedIterator<K, S>;\n public filter(predicate: KeyIteratee<K, T, boolean>): AggregatedIterator<K, T>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const indexes = new Map<K, number>();\n\n for (const [key, element] of elements)\n {\n const index = indexes.get(key) ?? 0;\n\n indexes.set(key, index + 1);\n\n if (predicate(key, element, index)) { yield [key, element]; }\n }\n });\n }\n public map<V>(iteratee: KeyIteratee<K, T, V>): AggregatedIterator<K, V>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const indexes = new Map<K, number>();\n\n for (const [key, element] of elements)\n {\n const index = indexes.get(key) ?? 0;\n\n indexes.set(key, index + 1);\n\n yield [key, iteratee(key, element, index)];\n }\n });\n }\n public reduce(reducer: KeyReducer<K, T, T>): ReducedIterator<K, T>;\n public reduce<A>(reducer: KeyReducer<K, T, A>, initialValue: (key: K) => A): ReducedIterator<K, A>;\n public reduce<A>(reducer: KeyReducer<K, T, A>, initialValue?: (key: K) => A): ReducedIterator<K, A>\n {\n const accumulators = new Map<K, [number, A]>();\n\n for (const [key, element] of this._elements)\n {\n let index: number;\n let accumulator: A;\n\n if (accumulators.has(key))\n {\n [index, accumulator] = accumulators.get(key)!;\n\n index += 1;\n }\n else if (initialValue !== undefined)\n {\n index = 0;\n accumulator = initialValue(key);\n }\n else\n {\n accumulators.set(key, [0, (element as unknown) as A]);\n\n continue;\n }\n\n accumulator = reducer(key, accumulator, element, index);\n\n accumulators.set(key, [index, accumulator]);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, [_, accumulator]] of accumulators)\n {\n yield [key, accumulator];\n }\n });\n }\n\n public unique(): AggregatedIterator<K, T>\n {\n const elements = this._elements;\n\n return new AggregatedIterator(function* ()\n {\n const keys = new Map<K, Set<T>>();\n\n for (const [key, element] of elements)\n {\n const values = keys.get(key) ?? new Set<T>();\n\n if (values.has(element)) { continue; }\n\n values.add(element);\n keys.set(key, values);\n\n yield [key, element];\n }\n });\n }\n\n public count(): ReducedIterator<K, number>\n {\n const counters = new Map<K, number>();\n\n for (const [key] of this._elements)\n {\n const count = counters.get(key) ?? 0;\n\n counters.set(key, count + 1);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, count] of counters)\n {\n yield [key, count];\n }\n });\n }\n public first(): ReducedIterator<K, T>\n {\n const firsts = new Map<K, T>();\n\n for (const [key, element] of this._elements)\n {\n if (firsts.has(key)) { continue; }\n\n firsts.set(key, element);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, element] of firsts)\n {\n yield [key, element];\n }\n });\n }\n public last(): ReducedIterator<K, T>\n {\n const lasts = new Map<K, T>();\n\n for (const [key, element] of this._elements)\n {\n lasts.set(key, element);\n }\n\n return new ReducedIterator(function* ()\n {\n for (const [key, element] of lasts)\n {\n yield [key, element];\n }\n });\n }\n\n public keys(): SmartIterator<K>\n {\n const elements = this._elements;\n\n return new SmartIterator<K>(function* ()\n {\n for (const [key] of elements)\n {\n yield key;\n }\n });\n }\n public items(): SmartIterator<[K, T]>\n {\n return this._elements;\n }\n public values(): SmartIterator<T>\n {\n const elements = this._elements;\n\n return new SmartIterator<T>(function* ()\n {\n for (const [_, element] of elements)\n {\n yield element;\n }\n });\n }\n\n public toArray(): T[][]\n {\n return Array.from(this.toMap().values());\n }\n public toMap(): Map<K, T[]>\n {\n const groups = new Map<K, T[]>();\n\n for (const [key, element] of this._elements)\n {\n const value = groups.get(key) ?? [];\n\n value.push(element);\n groups.set(key, value);\n }\n\n return groups;\n }\n public toObject(): Record<K, T[]>\n {\n const groups = { } as Record<K, T[]>;\n\n for (const [key, element] of this._elements)\n {\n const value = groups[key] ?? [];\n\n value.push(element);\n groups[key] = value;\n }\n\n return groups;\n }\n\n public get [Symbol.toStringTag]() { return \"AggregatedIterator\"; }\n}\n","import AggregatedIterator from \"./aggregated-iterator.js\";\nimport ReducedIterator from \"./reduced-iterator.js\";\nimport SmartIterator from \"../smart-iterator.js\";\n\nimport type { GeneratorFunction, Iteratee, TypeGuardIteratee } from \"../../types.js\";\n\nexport default class Aggregator<T>\n{\n protected _elements: SmartIterator<T>;\n\n public constructor(iterable: Iterable<T>);\n public constructor(iterator: Iterator<T>);\n public constructor(generatorFn: GeneratorFunction<T>);\n public constructor(argument: Iterable<T> | Iterator<T> | GeneratorFunction<T>);\n public constructor(argument: Iterable<T> | Iterator<T> | GeneratorFunction<T>)\n {\n this._elements = new SmartIterator(argument);\n }\n\n public filter(predicate: Iteratee<T, boolean>): Aggregator<T>;\n public filter<S extends T>(predicate: TypeGuardIteratee<T, S>): Aggregator<S>;\n public filter(predicate: Iteratee<T, boolean>): Aggregator<T>\n {\n return new Aggregator(this._elements.filter(predicate));\n }\n public map<V>(iteratee: Iteratee<T, V>): Aggregator<V>\n {\n return new Aggregator(this._elements.map(iteratee));\n }\n\n public unique(): Aggregator<T>\n {\n return new Aggregator(this._elements.unique());\n }\n\n public groupBy<K extends PropertyKey>(iteratee: Iteratee<T, K>): AggregatedIterator<K, T>\n {\n return new AggregatedIterator(this._elements.map((element, index) =>\n {\n const key = iteratee(element, index);\n\n return [key, element] as [K, T];\n }));\n }\n\n public get [Symbol.toStringTag]() { return \"Aggregator\"; }\n}\n\nexport { AggregatedIterator, ReducedIterator };\nexport type { KeyIteratee, KeyReducer, KeyTypeGuardIteratee } from \"./types.js\";\n","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 Exception from \"./core.js\";\n\nexport class ReferenceException extends Exception\n{\n public constructor(message: string, cause?: unknown, name = \"ReferenceException\")\n {\n super(message, cause, name);\n }\n\n public get [Symbol.toStringTag]() { return \"ReferenceException\"; }\n}\nexport class TimeoutException extends Exception\n{\n public constructor(message: string, cause?: unknown, name = \"TimeoutException\")\n {\n super(message, cause, name);\n }\n\n public get [Symbol.toStringTag]() { return \"TimeoutException\"; }\n}\nexport class ValueException extends Exception\n{\n public constructor(message: string, cause?: unknown, name = \"ValueException\")\n {\n super(message, cause, name);\n }\n\n public get [Symbol.toStringTag]() { return \"ValueException\"; }\n}\n\nexport { Exception };\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 { ReferenceException } from \"./exceptions/index.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 ReferenceException(\"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 { FulfilledHandler, PromiseExecutor, RejectedHandler } from \"../../types.js\";\n\nexport default class SmartPromise<T = void> implements Promise<T>\n{\n protected _isPending: boolean;\n protected _isFulfilled: boolean;\n protected _isRejected: boolean;\n\n protected _promise: Promise<T>;\n\n public constructor(executor: PromiseExecutor<T>)\n {\n this._isPending = true;\n this._isFulfilled = false;\n this._isRejected = false;\n\n const _onFulfilled = (result: T): T =>\n {\n this._isPending = false;\n this._isFulfilled = true;\n\n return result;\n };\n const _onRejected = (reason: unknown): never =>\n {\n this._isPending = false;\n this._isRejected = true;\n\n throw reason;\n };\n\n this._promise = new Promise<T>(executor)\n .then(_onFulfilled, _onRejected);\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(onFulfilled?: null): Promise<T>;\n public then<F = T>(onFulfilled: FulfilledHandler<T, F>, onRejected?: null): Promise<F>;\n public then<F = T, R = never>(onFulfilled: FulfilledHandler<T, F>, onRejected: RejectedHandler<unknown, R>)\n : Promise<F | R>;\n public then<F = T, R = never>(\n onFulfilled?: FulfilledHandler<T, F> | null,\n onRejected?: RejectedHandler<unknown, R> | null): Promise<F | R>\n {\n return this._promise.then(onFulfilled, onRejected);\n }\n\n public catch(onRejected?: null): Promise<T>;\n public catch<R = never>(onRejected: RejectedHandler<unknown, R>): Promise<T | R>;\n public catch<R = never>(onRejected?: RejectedHandler<unknown, R> | null): Promise<T | R>\n {\n return this._promise.catch(onRejected);\n }\n public finally(onFinally?: (() => void) | null): Promise<T>\n {\n return this._promise.finally(onFinally);\n }\n\n public get [Symbol.toStringTag]() { return \"SmartPromise\"; }\n}\n","import type { PromiseResolver, PromiseRejecter, FulfilledHandler, RejectedHandler } from \"../../types.js\";\n\nimport SmartPromise from \"./smart-promise.js\";\n\nexport default class DeferredPromise<T = void, F = T, R = never> extends SmartPromise<F | R>\n{\n protected _resolve: PromiseResolver<T>;\n protected _reject: PromiseRejecter;\n\n public constructor(onFulfilled?: FulfilledHandler<T, F> | null, onRejected?: RejectedHandler<unknown, R> | null)\n {\n let _resolve: PromiseResolver<T>;\n let _reject: PromiseRejecter;\n\n super((resolve, reject) =>\n {\n // ReferenceError: Must call super constructor in derived class before accessing\n // 'this' or returning from derived constructor.\n //\n _resolve = resolve as PromiseResolver<T>;\n _reject = reject;\n });\n\n this._promise.then(onFulfilled as FulfilledHandler<F | R>, onRejected);\n\n this._resolve = _resolve!;\n this._reject = _reject!;\n }\n\n public get resolve(): PromiseResolver<T> { return this._resolve; }\n public get reject(): PromiseRejecter { return this._reject; }\n\n public watch(otherPromise: PromiseLike<T>): this\n {\n otherPromise.then(this.resolve, this.reject);\n\n return this;\n }\n\n public get [Symbol.toStringTag]() { return \"DeferredPromise\"; }\n}\n","import type { MaybePromise, PromiseExecutor } from \"../../types.js\";\nimport { TimeoutException } from \"../exceptions/index.js\";\n\nimport SmartPromise from \"./smart-promise.js\";\n\nexport default class TimedPromise<T = void> extends SmartPromise<T>\n{\n public constructor(executor: PromiseExecutor<T>, timeout?: number)\n {\n super((resolve, reject) =>\n {\n const _resolve = (result: MaybePromise<T>) =>\n {\n clearTimeout(_timeoutId);\n resolve(result);\n };\n const _reject = (reason: unknown) =>\n {\n clearTimeout(_timeoutId);\n reject(reason);\n };\n\n const _timeout = () => _reject(new TimeoutException(\"The operation has timed out.\"));\n const _timeoutId = setTimeout(_timeout, timeout);\n\n executor(_resolve, _reject);\n });\n }\n\n public get [Symbol.toStringTag]() { return \"TimedPromise\"; }\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 { ValueException } from \"../models/exceptions/index.js\";\nimport { 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 _index = 0;\n\n for (const value of values)\n {\n _sum += value;\n _index += 1;\n }\n\n if (_index === 0) { throw new ValueException(\"You must provide at least one value.\"); }\n\n return _sum / _index;\n }\n\n let _sum = 0;\n let _count = 0;\n let _index = 0;\n\n for (const [value, weight] of zip(values, weights))\n {\n _sum += value * weight;\n _count += weight;\n _index += 1;\n }\n\n if (_index === 0) { throw new ValueException(\"You must provide at least one value and weight.\"); }\n if (_count === 0) { throw new ValueException(\"The sum of weights must be greater than zero.\"); }\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.5.0-rc.5\";\n\nexport {\n AggregatedIterator,\n Aggregator,\n DeferredPromise,\n Exception,\n JsonStorage,\n ReducedIterator,\n ReferenceException,\n SmartIterator,\n SmartPromise,\n Subscribers,\n TimedPromise,\n TimeoutException,\n ValueException\n\n} from \"./models/index.js\";\nexport type { KeyIteratee, KeyReducer, KeyTypeGuardIteratee } from \"./models/index.js\";\n\nexport {\n average,\n capitalize,\n count,\n delay,\n dateDifference,\n dateRange,\n dateRound,\n DateUnit,\n hash,\n loadScript,\n nextAnimationFrame,\n Random,\n range,\n shuffle,\n sum,\n unique,\n zip\n\n} from \"./utils/index.js\";\n\nexport type {\n AsyncGeneratorFunction,\n Constructor,\n FulfilledHandler,\n GeneratorFunction,\n Interval,\n Iteratee,\n MaybePromise,\n PromiseExecutor,\n PromiseRejecter,\n PromiseResolver,\n Reducer,\n RejectedHandler,\n Timeout,\n TypeGuardIteratee\n\n} from \"./types.js\";\n"],"names":["SmartIterator","argument","__publicField","value","error","predicate","index","result","iterator","iteratee","reducer","initialValue","accumulator","values","ReducedIterator","elements","key","element","_","AggregatedIterator","indexes","accumulators","keys","counters","count","firsts","lasts","groups","Aggregator","Exception","exc","message","cause","name","ReferenceException","TimeoutException","ValueException","JsonStorage","preferPersistence","storage","propertyName","defaultValue","propertyValue","newValue","encodedValue","persistent","Subscribers","subscriber","args","SmartPromise","executor","_onFulfilled","_onRejected","reason","onFulfilled","onRejected","onFinally","DeferredPromise","_resolve","_reject","resolve","reject","otherPromise","TimedPromise","timeout","_timeoutId","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","_index","weight","hash","hashedValue","char","sum","capitalize","VERSION"],"mappings":"oYAEA,MAAqBA,CACrB,CAUW,YAAYC,EACnB,CAVUC,EAAA,kBAEHA,EAAA,eACAA,EAAA,cAQCD,aAAoB,SAEpB,KAAK,UAAYA,IAEZ,OAAO,YAAYA,EAExB,KAAK,UAAYA,EAAS,OAAO,QAAQ,EAAE,EAI3C,KAAK,UAAYA,EAGjB,KAAK,UAAU,SAAU,KAAK,OAAUE,GAAc,KAAK,UAAU,OAAQA,CAAK,GAClF,KAAK,UAAU,QAAS,KAAK,MAASC,GAAoB,KAAK,UAAU,MAAOA,CAAK,EAC7F,CAEO,MAAMC,EACb,CACI,IAAIC,EAAQ,EAGZ,OACA,CACU,MAAAC,EAAS,KAAK,UAAU,KAAK,EAEnC,GAAIA,EAAO,KAAe,MAAA,GAC1B,GAAI,CAAEF,EAAUE,EAAO,MAAOD,CAAK,EAAa,MAAA,GAEvCA,GAAA,CACb,CACJ,CACO,KAAKD,EACZ,CACI,IAAIC,EAAQ,EAGZ,OACA,CACU,MAAAC,EAAS,KAAK,UAAU,KAAK,EAEnC,GAAIA,EAAO,KAAe,MAAA,GAC1B,GAAIF,EAAUE,EAAO,MAAOD,CAAK,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GAAS,EACnD,CACU,MAAAwG,EAAO3G,EAAM,WAAWG,CAAK,EAEnBuG,GAAAA,GAAe,GAAKA,EAAeC,EACpCD,GAAA,CACnB,CAEO,OAAAA,CACX,CAEO,SAASE,EAAsBlG,EACtC,CACI,IAAI4F,EAAO,EACX,UAAWtG,KAASU,EAAkB4F,GAAAtG,EAE/B,OAAAsG,CACX,CC5DO,SAASO,EAAW7G,EAC3B,CACW,MAAA,GAAGA,EAAM,OAAO,CAAC,EAAE,aAAa,GAAGA,EAAM,MAAM,CAAC,CAAC,EAC5D,CCHO,MAAM8G,EAAU"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byloth/core",
3
- "version": "1.5.0-rc.4",
3
+ "version": "1.5.0-rc.5",
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",
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export const VERSION = "1.5.0-rc.4";
1
+ export const VERSION = "1.5.0-rc.5";
2
2
 
3
3
  export {
4
4
  AggregatedIterator,
@@ -4,27 +4,35 @@ import SmartPromise from "./smart-promise.js";
4
4
 
5
5
  export default class DeferredPromise<T = void, F = T, R = never> extends SmartPromise<F | R>
6
6
  {
7
- protected _resolve!: PromiseResolver<T>;
8
- protected _reject!: PromiseRejecter;
7
+ protected _resolve: PromiseResolver<T>;
8
+ protected _reject: PromiseRejecter;
9
9
 
10
10
  public constructor(onFulfilled?: FulfilledHandler<T, F> | null, onRejected?: RejectedHandler<unknown, R> | null)
11
11
  {
12
+ let _resolve: PromiseResolver<T>;
13
+ let _reject: PromiseRejecter;
14
+
12
15
  super((resolve, reject) =>
13
16
  {
14
- this._resolve = resolve as PromiseResolver<T>;
15
- this._reject = reject;
17
+ // ReferenceError: Must call super constructor in derived class before accessing
18
+ // 'this' or returning from derived constructor.
19
+ //
20
+ _resolve = resolve as PromiseResolver<T>;
21
+ _reject = reject;
16
22
  });
17
23
 
18
- this._promise
19
- .then(onFulfilled as FulfilledHandler<F | R>, onRejected as RejectedHandler<unknown, R>);
24
+ this._promise.then(onFulfilled as FulfilledHandler<F | R>, onRejected);
25
+
26
+ this._resolve = _resolve!;
27
+ this._reject = _reject!;
20
28
  }
21
29
 
22
30
  public get resolve(): PromiseResolver<T> { return this._resolve; }
23
31
  public get reject(): PromiseRejecter { return this._reject; }
24
32
 
25
- public watch(promise: Promise<T>): this
33
+ public watch(otherPromise: PromiseLike<T>): this
26
34
  {
27
- promise.then(this.resolve, this.reject);
35
+ otherPromise.then(this.resolve, this.reject);
28
36
 
29
37
  return this;
30
38
  }