@byloth/core 2.2.5 → 2.2.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byloth/core",
3
- "version": "2.2.5",
3
+ "version": "2.2.6",
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",
@@ -49,16 +49,16 @@
49
49
  },
50
50
  "types": "src/index.ts",
51
51
  "devDependencies": {
52
- "@byloth/eslint-config-typescript": "^3.2.2",
52
+ "@byloth/eslint-config-typescript": "^4.0.0",
53
53
  "@eslint/compat": "^2.0.3",
54
54
  "@types/node": "^22.19.15",
55
- "@vitest/coverage-v8": "^4.0.18",
56
- "eslint": "^9.39.4",
55
+ "@vitest/coverage-v8": "^4.1.2",
56
+ "eslint": "^10.1.0",
57
57
  "husky": "^9.1.7",
58
- "jsdom": "^27.4.0",
59
- "typescript": "^5.9.3",
60
- "vite": "^7.3.1",
61
- "vitest": "^4.0.18"
58
+ "jsdom": "^29.0.1",
59
+ "typescript": "^6.0.2",
60
+ "vite": "^8.0.3",
61
+ "vitest": "^4.1.2"
62
62
  },
63
63
  "scripts": {
64
64
  "dev": "vite",
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export const VERSION = "2.2.5";
1
+ export const VERSION = "2.2.6";
2
2
 
3
3
  export type { Constructor, Interval, Timeout, ValueOf } from "./core/types.js";
4
4
 
@@ -253,7 +253,7 @@ export default class AggregatedAsyncIterator<K extends PropertyKey, T>
253
253
  values.set(key, [index + 1, await predicate(key, element, index)]);
254
254
  }
255
255
 
256
- return new ReducedIterator(function* ()
256
+ return new ReducedIterator(function* (): Generator<[K, boolean]>
257
257
  {
258
258
  for (const [key, [_, result]] of values) { yield [key, result]; }
259
259
  });
@@ -303,7 +303,7 @@ export default class AggregatedAsyncIterator<K extends PropertyKey, T>
303
303
  values.set(key, [index + 1, await predicate(key, element, index)]);
304
304
  }
305
305
 
306
- return new ReducedIterator(function* ()
306
+ return new ReducedIterator(function* (): Generator<[K, boolean]>
307
307
  {
308
308
  for (const [key, [_, result]] of values) { yield [key, result]; }
309
309
  });
@@ -578,7 +578,7 @@ export default class AggregatedAsyncIterator<K extends PropertyKey, T>
578
578
  values.set(key, [index + 1, await reducer(key, accumulator, element, index)]);
579
579
  }
580
580
 
581
- return new ReducedIterator(function* ()
581
+ return new ReducedIterator(function* (): Generator<[K, A]>
582
582
  {
583
583
  for (const [key, [_, accumulator]] of values) { yield [key, accumulator]; }
584
584
  });
@@ -829,7 +829,7 @@ export default class AggregatedAsyncIterator<K extends PropertyKey, T>
829
829
  values.set(key, [index + 1, finding]);
830
830
  }
831
831
 
832
- return new ReducedIterator(function* ()
832
+ return new ReducedIterator(function* (): Generator<[K, T | undefined]>
833
833
  {
834
834
  for (const [key, [_, finding]] of values) { yield [key, finding]; }
835
835
  });
@@ -945,7 +945,7 @@ export default class AggregatedAsyncIterator<K extends PropertyKey, T>
945
945
  counters.set(key, count + 1);
946
946
  }
947
947
 
948
- return new ReducedIterator(function* ()
948
+ return new ReducedIterator(function* (): Generator<[K, number]>
949
949
  {
950
950
  for (const [key, count] of counters) { yield [key, count]; }
951
951
  });
@@ -175,7 +175,7 @@ export default class AggregatedIterator<K extends PropertyKey, T>
175
175
  values.set(key, [index + 1, predicate(key, element, index)]);
176
176
  }
177
177
 
178
- return new ReducedIterator(function* ()
178
+ return new ReducedIterator(function* (): Generator<[K, boolean]>
179
179
  {
180
180
  for (const [key, [_, result]] of values) { yield [key, result]; }
181
181
  });
@@ -224,7 +224,7 @@ export default class AggregatedIterator<K extends PropertyKey, T>
224
224
  values.set(key, [index + 1, predicate(key, element, index)]);
225
225
  }
226
226
 
227
- return new ReducedIterator(function* ()
227
+ return new ReducedIterator(function* (): Generator<[K, boolean]>
228
228
  {
229
229
  for (const [key, [_, result]] of values) { yield [key, result]; }
230
230
  });
@@ -303,7 +303,7 @@ export default class AggregatedIterator<K extends PropertyKey, T>
303
303
  {
304
304
  const elements = this._elements;
305
305
 
306
- return new AggregatedIterator(function* ()
306
+ return new AggregatedIterator(function* (): Generator<[K, T]>
307
307
  {
308
308
  const indexes = new Map<K, number>();
309
309
  for (const [key, element] of elements)
@@ -352,7 +352,7 @@ export default class AggregatedIterator<K extends PropertyKey, T>
352
352
  {
353
353
  const elements = this._elements;
354
354
 
355
- return new AggregatedIterator(function* ()
355
+ return new AggregatedIterator(function* (): Generator<[K, V]>
356
356
  {
357
357
  const indexes = new Map<K, number>();
358
358
  for (const [key, element] of elements)
@@ -496,7 +496,7 @@ export default class AggregatedIterator<K extends PropertyKey, T>
496
496
  values.set(key, [index + 1, reducer(key, accumulator, element, index)]);
497
497
  }
498
498
 
499
- return new ReducedIterator(function* ()
499
+ return new ReducedIterator(function* (): Generator<[K, A]>
500
500
  {
501
501
  for (const [key, [_, accumulator]] of values) { yield [key, accumulator]; }
502
502
  });
@@ -542,7 +542,7 @@ export default class AggregatedIterator<K extends PropertyKey, T>
542
542
  {
543
543
  const elements = this._elements;
544
544
 
545
- return new AggregatedIterator(function* ()
545
+ return new AggregatedIterator(function* (): Generator<[K, V]>
546
546
  {
547
547
  const indexes = new Map<K, number>();
548
548
  for (const [key, element] of elements)
@@ -594,7 +594,7 @@ export default class AggregatedIterator<K extends PropertyKey, T>
594
594
  {
595
595
  const elements = this._elements;
596
596
 
597
- return new AggregatedIterator(function* ()
597
+ return new AggregatedIterator(function* (): Generator<[K, T]>
598
598
  {
599
599
  const indexes = new Map<K, number>();
600
600
  for (const [key, element] of elements)
@@ -645,7 +645,7 @@ export default class AggregatedIterator<K extends PropertyKey, T>
645
645
  {
646
646
  const elements = this._elements;
647
647
 
648
- return new AggregatedIterator(function* ()
648
+ return new AggregatedIterator(function* (): Generator<[K, T]>
649
649
  {
650
650
  const indexes = new Map<K, number>();
651
651
  for (const [key, element] of elements)
@@ -740,7 +740,7 @@ export default class AggregatedIterator<K extends PropertyKey, T>
740
740
  values.set(key, [index + 1, finding]);
741
741
  }
742
742
 
743
- return new ReducedIterator(function* ()
743
+ return new ReducedIterator(function* (): Generator<[K, T | undefined]>
744
744
  {
745
745
  for (const [key, [_, finding]] of values) { yield [key, finding]; }
746
746
  });
@@ -807,7 +807,7 @@ export default class AggregatedIterator<K extends PropertyKey, T>
807
807
  {
808
808
  const elements = this._elements;
809
809
 
810
- return new AggregatedIterator(function* ()
810
+ return new AggregatedIterator(function* (): Generator<[K, T]>
811
811
  {
812
812
  const keys = new Map<K, Set<T>>();
813
813
  for (const [key, element] of elements)
@@ -855,7 +855,7 @@ export default class AggregatedIterator<K extends PropertyKey, T>
855
855
  counters.set(key, count + 1);
856
856
  }
857
857
 
858
- return new ReducedIterator(function* ()
858
+ return new ReducedIterator(function* (): Generator<[K, number]>
859
859
  {
860
860
  for (const [key, count] of counters) { yield [key, count]; }
861
861
  });
@@ -932,7 +932,7 @@ export default class AggregatedIterator<K extends PropertyKey, T>
932
932
  {
933
933
  const elements = this._elements;
934
934
 
935
- return new AggregatedIterator(function* ()
935
+ return new AggregatedIterator(function* (): Generator<[J, T]>
936
936
  {
937
937
  const indexes = new Map<K, number>();
938
938
  for (const [key, element] of elements)
@@ -289,7 +289,7 @@ export default class ReducedIterator<K extends PropertyKey, T>
289
289
  {
290
290
  const elements = this._elements.enumerate();
291
291
 
292
- return new ReducedIterator(function* ()
292
+ return new ReducedIterator(function* (): Generator<[K, T]>
293
293
  {
294
294
  for (const [index, [key, element]] of elements)
295
295
  {
@@ -335,7 +335,7 @@ export default class ReducedIterator<K extends PropertyKey, T>
335
335
  {
336
336
  const elements = this._elements.enumerate();
337
337
 
338
- return new ReducedIterator(function* ()
338
+ return new ReducedIterator(function* (): Generator<[K, V]>
339
339
  {
340
340
  for (const [index, [key, element]] of elements)
341
341
  {
@@ -472,7 +472,7 @@ export default class ReducedIterator<K extends PropertyKey, T>
472
472
  {
473
473
  const elements = this._elements.enumerate();
474
474
 
475
- return new AggregatedIterator(function* ()
475
+ return new AggregatedIterator(function* (): Generator<[K, V]>
476
476
  {
477
477
  for (const [index, [key, element]] of elements)
478
478
  {
@@ -524,7 +524,7 @@ export default class ReducedIterator<K extends PropertyKey, T>
524
524
  {
525
525
  const elements = this._elements.enumerate();
526
526
 
527
- return new ReducedIterator(function* ()
527
+ return new ReducedIterator(function* (): Generator<[K, T]>
528
528
  {
529
529
  for (const [index, [key, element]] of elements)
530
530
  {
@@ -572,7 +572,7 @@ export default class ReducedIterator<K extends PropertyKey, T>
572
572
  {
573
573
  const elements = this._elements.enumerate();
574
574
 
575
- return new ReducedIterator(function* ()
575
+ return new ReducedIterator(function* (): Generator<[K, T]>
576
576
  {
577
577
  for (const [index, [key, element]] of elements)
578
578
  {
@@ -726,7 +726,7 @@ export default class ReducedIterator<K extends PropertyKey, T>
726
726
  {
727
727
  const elements = this._elements;
728
728
 
729
- return new ReducedIterator(function* ()
729
+ return new ReducedIterator(function* (): Generator<[K, T]>
730
730
  {
731
731
  const values = new Set<T>();
732
732
  for (const [key, element] of elements)
@@ -838,7 +838,7 @@ export default class ReducedIterator<K extends PropertyKey, T>
838
838
  {
839
839
  const elements = this._elements.enumerate();
840
840
 
841
- return new AggregatedIterator(function* ()
841
+ return new AggregatedIterator(function* (): Generator<[J, T]>
842
842
  {
843
843
  for (const [index, [key, element]] of elements)
844
844
  {
@@ -102,7 +102,7 @@ export function count<T>(elements: Iterable<T>): number
102
102
  */
103
103
  export function enumerate<T>(elements: Iterable<T>): SmartIterator<[number, T]>
104
104
  {
105
- return new SmartIterator<[number, T]>(function* ()
105
+ return new SmartIterator<[number, T]>(function* (): Generator<[number, T]>
106
106
  {
107
107
  let index = 0;
108
108
  for (const element of elements)
@@ -314,7 +314,7 @@ export function zip<T, U>(first: Iterable<T>, second: Iterable<U>): SmartIterato
314
314
  const firstIterator = first[Symbol.iterator]();
315
315
  const secondIterator = second[Symbol.iterator]();
316
316
 
317
- return new SmartIterator<[T, U]>(function* ()
317
+ return new SmartIterator<[T, U]>(function* (): Generator<[T, U]>
318
318
  {
319
319
  while (true)
320
320
  {