@byloth/core 2.0.0-rc.2 → 2.0.0-rc.4

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.
@@ -9,7 +9,7 @@ import Publisher from "../publisher.js";
9
9
  export default class Countdown extends GameLoop
10
10
  {
11
11
  protected _deferrer?: DeferredPromise<void>;
12
- protected _publisher: Publisher<[number], void>;
12
+ protected _publisher: Publisher<[number]>;
13
13
 
14
14
  protected _duration: number;
15
15
  public get duration(): number
@@ -76,4 +76,6 @@ export default class Countdown extends GameLoop
76
76
  lastTick = remainingTime;
77
77
  });
78
78
  }
79
+
80
+ public readonly [Symbol.toStringTag]: string = "Countdown";
79
81
  }
@@ -1,10 +1,10 @@
1
1
  export type {
2
- KeyIteratee,
3
- MaybeAsyncKeyIteratee,
4
- KeyTypeGuardIteratee,
5
- MaybeAsyncKeyTypeGuardIteratee,
6
- KeyReducer,
7
- MaybeAsyncKeyReducer
2
+ KeyedIteratee,
3
+ MaybeAsyncKeyedIteratee,
4
+ KeyedTypeGuardIteratee,
5
+ MaybeAsyncKeyedTypeGuardIteratee,
6
+ KeyedReducer,
7
+ MaybeAsyncKeyedReducer
8
8
 
9
9
  } from "./aggregators/types.js";
10
10
 
@@ -17,9 +17,9 @@ export type {
17
17
  MaybeAsyncTypeGuardIteratee,
18
18
  Reducer,
19
19
  MaybeAsyncReducer,
20
- IterLike,
21
- AsyncIterLike,
22
- MaybeAsyncIterLike
20
+ IteratorLike,
21
+ AsyncIteratorLike,
22
+ MaybeAsyncIteratorLike
23
23
 
24
24
  } from "./iterators/types.js";
25
25
 
@@ -1,9 +1,9 @@
1
- export async function delay(milliseconds: number): Promise<void>
1
+ export function delay(milliseconds: number): Promise<void>
2
2
  {
3
- return new Promise<void>((resolve, reject) => setTimeout(resolve, milliseconds));
3
+ return new Promise<void>((resolve) => setTimeout(resolve, milliseconds));
4
4
  }
5
5
 
6
- export async function nextAnimationFrame(): Promise<void>
6
+ export function nextAnimationFrame(): Promise<void>
7
7
  {
8
- return new Promise<void>((resolve, reject) => requestAnimationFrame(() => resolve()));
8
+ return new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));
9
9
  }
package/src/utils/date.ts CHANGED
@@ -1,7 +1,10 @@
1
+
1
2
  import { SmartIterator } from "../models/index.js";
2
3
 
3
4
  export enum TimeUnit
4
5
  {
6
+ /* eslint-disable @typescript-eslint/prefer-literal-enum-member */
7
+
5
8
  Millisecond = 1,
6
9
  Second = 1000,
7
10
  Minute = 60 * Second,
@@ -2,7 +2,7 @@ import { ValueException } from "../models/index.js";
2
2
 
3
3
  export default class Random
4
4
  {
5
- public static Boolean(ratio: number = 0.5): boolean
5
+ public static Boolean(ratio = 0.5): boolean
6
6
  {
7
7
  return (Math.random() < ratio);
8
8
  }
@@ -38,6 +38,7 @@ export default class Random
38
38
  return elements[Random.Index(elements)];
39
39
  }
40
40
 
41
- // eslint-disable-next-line no-useless-constructor
42
- private constructor() { }
41
+ private constructor() { /* ... */ }
42
+
43
+ public readonly [Symbol.toStringTag]: string = "Random";
43
44
  }
@@ -1,46 +0,0 @@
1
- import AggregatedIterator from "./aggregated-iterator.js";
2
-
3
- import { SmartIterator } from "../iterators/index.js";
4
- import type { GeneratorFunction, Iteratee, IterLike, TypeGuardIteratee } from "../iterators/types.js";
5
-
6
- export default class Aggregator<T>
7
- {
8
- protected _elements: SmartIterator<T>;
9
-
10
- public constructor(iterable: Iterable<T>);
11
- public constructor(iterator: Iterator<T>);
12
- public constructor(generatorFn: GeneratorFunction<T>);
13
- public constructor(argument: IterLike<T>);
14
- public constructor(argument: IterLike<T>)
15
- {
16
- this._elements = new SmartIterator(argument);
17
- }
18
-
19
- public filter(predicate: Iteratee<T, boolean>): Aggregator<T>;
20
- public filter<S extends T>(predicate: TypeGuardIteratee<T, S>): Aggregator<S>;
21
- public filter(predicate: Iteratee<T, boolean>): Aggregator<T>
22
- {
23
- return new Aggregator(this._elements.filter(predicate));
24
- }
25
- public map<V>(iteratee: Iteratee<T, V>): Aggregator<V>
26
- {
27
- return new Aggregator(this._elements.map(iteratee));
28
- }
29
-
30
- public unique(): Aggregator<T>
31
- {
32
- return new Aggregator(this._elements.unique());
33
- }
34
-
35
- public groupBy<K extends PropertyKey>(iteratee: Iteratee<T, K>): AggregatedIterator<K, T>
36
- {
37
- return new AggregatedIterator(this._elements.map((element, index) =>
38
- {
39
- const key = iteratee(element, index);
40
-
41
- return [key, element] as [K, T];
42
- }));
43
- }
44
-
45
- public get [Symbol.toStringTag]() { return "Aggregator"; }
46
- }
@@ -1,56 +0,0 @@
1
- import AggregatedAsyncIterator from "./aggregated-async-iterator.js";
2
-
3
- import { SmartAsyncIterator } from "../iterators/index.js";
4
- import type {
5
- AsyncGeneratorFunction,
6
- GeneratorFunction,
7
- MaybeAsyncIterLike,
8
- MaybeAsyncIteratee,
9
- MaybeAsyncTypeGuardIteratee
10
-
11
- } from "../iterators/types.js";
12
-
13
- export default class AsyncAggregator<T>
14
- {
15
- protected _elements: SmartAsyncIterator<T>;
16
-
17
- public constructor(iterable: Iterable<T>);
18
- public constructor(iterable: AsyncIterable<T>);
19
- public constructor(iterator: Iterator<T>);
20
- public constructor(iterator: AsyncIterator<T>);
21
- public constructor(generatorFn: GeneratorFunction<T>);
22
- public constructor(generatorFn: AsyncGeneratorFunction<T>);
23
- public constructor(argument: MaybeAsyncIterLike<T>);
24
- public constructor(argument: MaybeAsyncIterLike<T>)
25
- {
26
- this._elements = new SmartAsyncIterator(argument);
27
- }
28
-
29
- public filter(predicate: MaybeAsyncIteratee<T, boolean>): AsyncAggregator<T>;
30
- public filter<S extends T>(predicate: MaybeAsyncTypeGuardIteratee<T, S>): AsyncAggregator<S>;
31
- public filter(predicate: MaybeAsyncIteratee<T, boolean>): AsyncAggregator<T>
32
- {
33
- return new AsyncAggregator(this._elements.filter(predicate));
34
- }
35
- public map<V>(iteratee: MaybeAsyncIteratee<T, V>): AsyncAggregator<V>
36
- {
37
- return new AsyncAggregator(this._elements.map(iteratee));
38
- }
39
-
40
- public unique(): AsyncAggregator<T>
41
- {
42
- return new AsyncAggregator(this._elements.unique());
43
- }
44
-
45
- public groupBy<K extends PropertyKey>(iteratee: MaybeAsyncIteratee<T, K>): AggregatedAsyncIterator<K, T>
46
- {
47
- return new AggregatedAsyncIterator(this._elements.map(async (element, index) =>
48
- {
49
- const key = await iteratee(element, index);
50
-
51
- return [key, element] as [K, T];
52
- }));
53
- }
54
-
55
- public get [Symbol.toStringTag]() { return "AsyncAggregator"; }
56
- }