Clear timeout IDs from array after execution

This commit is contained in:
Amish Shah
2016-08-30 14:20:28 +01:00
parent 680ac48e3d
commit 4f41a86dd3
2 changed files with 8 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@@ -149,6 +149,8 @@ class Client extends EventEmitter {
this.token = null;
this.email = null;
this.password = null;
this._timeouts = [];
this._intervals = [];
resolve();
})
.catch(reject);
@@ -160,7 +162,11 @@ class Client extends EventEmitter {
}
setTimeout(...params) {
this._timeouts.push(setTimeout(...params));
const restParams = params.slice(1);
this._timeouts.push(setTimeout(() => {
this._timeouts.splice(this._timeouts.indexOf(params[0]), 1);
params[0]();
}, ...restParams));
}
/**