feat(Collector): return a boolean on checkEnd (#6289)

This commit is contained in:
Rodry
2021-08-05 20:34:17 +01:00
committed by GitHub
parent b4afcf8236
commit f473f43d08
2 changed files with 3 additions and 2 deletions

View File

@@ -207,7 +207,6 @@ class Collector extends EventEmitter {
/**
* Resets the collector's timeout and idle timer.
* @param {CollectorResetTimerOptions} [options] Options for reseting
*/
resetTimer({ time, idle } = {}) {
if (this._timeout) {
@@ -222,10 +221,12 @@ class Collector extends EventEmitter {
/**
* Checks whether the collector should end, and if so, ends it.
* @returns {boolean} Whether the collector ended or not
*/
checkEnd() {
const reason = this.endReason;
if (reason) this.stop(reason);
return Boolean(reason);
}
/**

2
typings/index.d.ts vendored
View File

@@ -474,7 +474,7 @@ export abstract class Collector<K, V, F extends unknown[] = []> extends EventEmi
public filter: CollectorFilter<[V, ...F]>;
public readonly next: Promise<V>;
public options: CollectorOptions<[V, ...F]>;
public checkEnd(): void;
public checkEnd(): boolean;
public handleCollect(...args: unknown[]): Promise<void>;
public handleDispose(...args: unknown[]): Promise<void>;
public stop(reason?: string): void;