chore: Fixed tests
This commit is contained in:
parent
9141fb35d4
commit
5593985884
13 changed files with 139 additions and 66 deletions
|
|
@ -91,6 +91,11 @@ export class TaskQueue
|
|||
return this.activeQueue.length > 0;
|
||||
}
|
||||
|
||||
public hasQueued ()
|
||||
{
|
||||
return this.queue && this.queue.length > 0;
|
||||
}
|
||||
|
||||
public hasActiveOfType (type: any)
|
||||
{
|
||||
for (const entry of this.activeQueue)
|
||||
|
|
@ -109,6 +114,30 @@ export class TaskQueue
|
|||
return job?.promise.promise ?? Promise.resolve();
|
||||
}
|
||||
|
||||
public waitForAll ()
|
||||
{
|
||||
return new Promise((resolve) =>
|
||||
{
|
||||
if (!this.hasActive())
|
||||
{
|
||||
resolve(true);
|
||||
return;
|
||||
}
|
||||
|
||||
const handleEnded = () =>
|
||||
{
|
||||
if (!this.hasActive() && !this.hasQueued())
|
||||
{
|
||||
resolve(true);
|
||||
this.events?.removeListener('ended', handleEnded);
|
||||
this.events?.removeListener('abort', handleEnded);
|
||||
}
|
||||
};
|
||||
this.events?.on('ended', handleEnded);
|
||||
this.events?.on('abort', handleEnded);
|
||||
});
|
||||
}
|
||||
|
||||
public cancelJob (id: string)
|
||||
{
|
||||
const job = this.queue?.find(j => j.id === id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue