Pass the collection of X collected in collectors (#1594)

...to the filter function.
This commit is contained in:
bdistin
2017-08-20 16:13:08 -05:00
committed by Crawl
parent 8b8a365e99
commit 9c2e3b8978

View File

@@ -5,6 +5,7 @@ const EventEmitter = require('events');
* Filter to be applied to the collector.
* @typedef {Function} CollectorFilter
* @param {...*} args Any arguments received by the listener
* @param {Collection} collection The items collected by this collector
* @returns {boolean} To collect or not collect
*/
@@ -75,7 +76,7 @@ class Collector extends EventEmitter {
*/
handleCollect(...args) {
const collect = this.collect(...args);
if (!collect || !this.filter(...args)) return;
if (!collect || !this.filter(...args, this.collected)) return;
this.collected.set(collect.key, collect.value);