Backport passing a collection to a collector

This commit is contained in:
iCrawl
2017-08-24 00:35:44 +02:00
parent 85d195da52
commit bce5b677ad

View File

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