Skip to content

Commit

Permalink
fix: only filter the rest of the q when the q has more than one items
Browse files Browse the repository at this point in the history
  • Loading branch information
KieraDOG committed Aug 12, 2024
1 parent 499bea1 commit 526c3a0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/CGDGarageDoor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ export class CGDGarageDoor {
private withRunQ = async (key: string, fn: () => Promise<unknown>) => new Promise((resolve, reject) => {
this.log.debug('Adding to queue');

const [item, ...rest] = this.runQ;
this.runQ = [item, ...rest.filter((item) => item.name !== key)];
if (this.runQ.length > 1) {
const [item, ...rest] = this.runQ;
this.runQ = [item, ...rest.filter((item) => item.name !== key)];
}

this.runQ.push({
name: key,
Expand Down

0 comments on commit 526c3a0

Please sign in to comment.