@cityssm/unique-timed-entry-queue
Advanced tools
+14
-12
@@ -122,14 +122,16 @@ import Debug from 'debug'; | ||
| } | ||
| const stringEntry = valueToString(entry); | ||
| const timeout = setTimeout(() => { | ||
| this.pendingEntries.delete(stringEntry); | ||
| if (this.queue.includes(entry)) { | ||
| debug(`Entry already in queue, not enqueuing: ${stringEntry}`); | ||
| return; | ||
| } | ||
| this.queue.push(entry); | ||
| this.triggerEvents('enqueue', entry); | ||
| debug(`Enqueued entry: ${stringEntry}`); | ||
| }, delay); | ||
| this.pendingEntries.set(stringEntry, { timeout, value: entry }); | ||
| if (!this.queue.includes(entry)) { | ||
| const stringEntry = valueToString(entry); | ||
| const timeout = setTimeout(() => { | ||
| this.pendingEntries.delete(stringEntry); | ||
| if (this.queue.includes(entry)) { | ||
| debug(`Entry already in queue, not enqueuing: ${stringEntry}`); | ||
| return; | ||
| } | ||
| this.queue.push(entry); | ||
| this.triggerEvents('enqueue', entry); | ||
| debug(`Enqueued entry: ${stringEntry}`); | ||
| }, delay); | ||
| this.pendingEntries.set(stringEntry, { timeout, value: entry }); | ||
| } | ||
| } | ||
@@ -136,0 +138,0 @@ /** |
+14
-12
@@ -173,19 +173,21 @@ import Debug from 'debug' | ||
| const stringEntry = valueToString(entry) | ||
| if (!this.queue.includes(entry)) { | ||
| const stringEntry = valueToString(entry) | ||
| const timeout = setTimeout(() => { | ||
| this.pendingEntries.delete(stringEntry) | ||
| const timeout = setTimeout(() => { | ||
| this.pendingEntries.delete(stringEntry) | ||
| if (this.queue.includes(entry)) { | ||
| debug(`Entry already in queue, not enqueuing: ${stringEntry}`) | ||
| return | ||
| } | ||
| if (this.queue.includes(entry)) { | ||
| debug(`Entry already in queue, not enqueuing: ${stringEntry}`) | ||
| return | ||
| } | ||
| this.queue.push(entry) | ||
| this.triggerEvents('enqueue', entry) | ||
| this.queue.push(entry) | ||
| this.triggerEvents('enqueue', entry) | ||
| debug(`Enqueued entry: ${stringEntry}`) | ||
| }, delay) | ||
| debug(`Enqueued entry: ${stringEntry}`) | ||
| }, delay) | ||
| this.pendingEntries.set(stringEntry, { timeout, value: entry }) | ||
| this.pendingEntries.set(stringEntry, { timeout, value: entry }) | ||
| } | ||
| } | ||
@@ -192,0 +194,0 @@ |
+3
-3
| { | ||
| "name": "@cityssm/unique-timed-entry-queue", | ||
| "version": "0.4.1", | ||
| "version": "0.5.0", | ||
| "description": "A queue with delayed enqueue of unique entries, perfect for queuing update notifications.", | ||
@@ -40,6 +40,6 @@ "keywords": [ | ||
| "@types/debug": "^4.1.13", | ||
| "@types/node": "^25.6.0", | ||
| "eslint-config-cityssm": "^39.1.0", | ||
| "@types/node": "^25.9.1", | ||
| "eslint-config-cityssm": "^40.1.0", | ||
| "prettier-config-cityssm": "^2.1.2" | ||
| } | ||
| } |
33207
0.52%738
0.54%