3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

Add getter for Queue.timeout

This commit is contained in:
Dragory 2021-05-22 13:57:54 +03:00
parent c30c9f6224
commit 13e2959ded
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -8,10 +8,14 @@ const DEFAULT_TIMEOUT = 10 * SECONDS;
export class Queue<TQueueFunction extends AnyFn = AnyFn> {
protected running = false;
protected queue: InternalQueueFn[] = [];
protected timeout: number;
protected _timeout: number;
constructor(timeout = DEFAULT_TIMEOUT) {
this.timeout = timeout;
this._timeout = timeout;
}
get timeout(): number {
return this._timeout;
}
/**
@ -49,7 +53,7 @@ export class Queue<TQueueFunction extends AnyFn = AnyFn> {
new Promise(resolve => {
// Either fn() completes or the timeout is reached
void fn().then(resolve);
setTimeout(resolve, this.timeout);
setTimeout(resolve, this._timeout);
}).then(() => this.next());
}