fix: in/de-crement max listener for client events (#4168)

This commit is contained in:
SpaceEEC
2020-05-07 23:39:23 +02:00
committed by GitHub
parent 766b91d306
commit 407bc77d34
6 changed files with 40 additions and 9 deletions

View File

@@ -139,6 +139,28 @@ class BaseClient extends EventEmitter {
this._immediates.delete(immediate);
}
/**
* Increments max listeners by one, if they are not zero.
* @private
*/
incrementMaxListeners() {
const maxListeners = this.getMaxListeners();
if (maxListeners !== 0) {
this.setMaxListeners(maxListeners + 1);
}
}
/**
* Decrements max listeners by one, if they are not zero.
* @private
*/
decrementMaxListeners() {
const maxListeners = this.getMaxListeners();
if (maxListeners !== 0) {
this.setMaxListeners(maxListeners - 1);
}
}
toJSON(...props) {
return Util.flatten(this, { domain: false }, ...props);
}