Fix Collector bug where checkEnd is only called on a valid message (#2186)

This commit is contained in:
Steven
2017-12-31 13:21:29 -06:00
committed by Crawl
parent 84e4dd6a99
commit 229eb2be2d

View File

@@ -76,17 +76,18 @@ class Collector extends EventEmitter {
*/ */
handleCollect(...args) { handleCollect(...args) {
const collect = this.collect(...args); const collect = this.collect(...args);
if (!collect || !this.filter(...args, this.collected)) return;
this.collected.set(collect.key, collect.value); if (collect && this.filter(...args, this.collected)) {
this.collected.set(collect.key, collect.value);
/** /**
* Emitted whenever an element is collected. * Emitted whenever an element is collected.
* @event Collector#collect * @event Collector#collect
* @param {*} element The element that got collected * @param {*} element The element that got collected
* @param {...*} args The arguments emitted by the listener * @param {...*} args The arguments emitted by the listener
*/ */
this.emit('collect', collect.value, ...args); this.emit('collect', collect.value, ...args);
}
this.checkEnd(); this.checkEnd();
} }