fix(Collector): throw an error if a non-function was provided as filter (#5034)

This commit is contained in:
SpaceEEC
2020-12-08 20:11:44 +01:00
committed by GitHub
parent 09d07553ab
commit 7365f40300

View File

@@ -1,6 +1,7 @@
'use strict';
const EventEmitter = require('events');
const { TypeError } = require('../../errors');
const Collection = require('../../util/Collection');
const Util = require('../../util/Util');
@@ -74,6 +75,10 @@ class Collector extends EventEmitter {
*/
this._idletimeout = null;
if (typeof filter !== 'function') {
throw new TypeError('INVALID_TYPE', 'filter', 'function');
}
this.handleCollect = this.handleCollect.bind(this);
this.handleDispose = this.handleDispose.bind(this);