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:
parent
c30c9f6224
commit
13e2959ded
1 changed files with 7 additions and 3 deletions
|
@ -8,10 +8,14 @@ const DEFAULT_TIMEOUT = 10 * SECONDS;
|
||||||
export class Queue<TQueueFunction extends AnyFn = AnyFn> {
|
export class Queue<TQueueFunction extends AnyFn = AnyFn> {
|
||||||
protected running = false;
|
protected running = false;
|
||||||
protected queue: InternalQueueFn[] = [];
|
protected queue: InternalQueueFn[] = [];
|
||||||
protected timeout: number;
|
protected _timeout: number;
|
||||||
|
|
||||||
constructor(timeout = DEFAULT_TIMEOUT) {
|
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 => {
|
new Promise(resolve => {
|
||||||
// Either fn() completes or the timeout is reached
|
// Either fn() completes or the timeout is reached
|
||||||
void fn().then(resolve);
|
void fn().then(resolve);
|
||||||
setTimeout(resolve, this.timeout);
|
setTimeout(resolve, this._timeout);
|
||||||
}).then(() => this.next());
|
}).then(() => this.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue