From 60e18512ce7ccf1f5d5b793f4b62f5db2522221d Mon Sep 17 00:00:00 2001 From: samsamson33 Date: Thu, 27 Feb 2020 10:10:12 -0500 Subject: [PATCH] Revert "feat(Collector): allow collectors to be consumed by for-await-of loops (#3269)" This reverts commit f913c26d81a6afde6a79eb18473bad21166f3b0c. --- src/structures/interfaces/Collector.js | 31 -------------------------- typings/index.d.ts | 1 - 2 files changed, 32 deletions(-) diff --git a/src/structures/interfaces/Collector.js b/src/structures/interfaces/Collector.js index 3cd5d387e7c1..cadb44c65a58 100644 --- a/src/structures/interfaces/Collector.js +++ b/src/structures/interfaces/Collector.js @@ -196,37 +196,6 @@ class Collector extends EventEmitter { if (reason) this.stop(reason); } - /** - * Allows collectors to be consumed with for-await-of loops - * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of} - */ - async *[Symbol.asyncIterator]() { - const queue = []; - const onCollect = item => queue.push(item); - this.on('collect', onCollect); - - try { - while (queue.length || !this.ended) { - if (queue.length) { - yield queue.shift(); - } else { - // eslint-disable-next-line no-await-in-loop - await new Promise(resolve => { - const tick = () => { - this.off('collect', tick); - this.off('end', tick); - return resolve(); - }; - this.on('collect', tick); - this.on('end', tick); - }); - } - } - } finally { - this.off('collect', onCollect); - } - } - toJSON() { return Util.flatten(this); } diff --git a/typings/index.d.ts b/typings/index.d.ts index 0d2422b63974..51b0d993c551 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -363,7 +363,6 @@ declare module 'discord.js' { public handleCollect(...args: any[]): void; public handleDispose(...args: any[]): void; public stop(reason?: string): void; - public [Symbol.asyncIterator](): AsyncIterableIterator; public toJSON(): object; protected listener: Function;