From a9486712518b770695b8a5a6cb207d69064dbc67 Mon Sep 17 00:00:00 2001 From: Harvmaster Date: Fri, 7 Aug 2026 01:44:20 +0000 Subject: [PATCH] Use variable for debounce addtion --- source/event-emitter.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/event-emitter.ts b/source/event-emitter.ts index 857f9c4..5ea4070 100644 --- a/source/event-emitter.ts +++ b/source/event-emitter.ts @@ -57,9 +57,13 @@ export class EventEmitter { const listenerEntry: ListenerEntry = { listener, wrappedListener, - ...(debounceMilliseconds !== undefined ? { debounceTime: debounceMilliseconds } : {}), }; + // Set the debounce time if specified. + if (debounceMilliseconds && debounceMilliseconds > 0) { + listenerEntry.debounceTime = debounceMilliseconds; + } + // Add the listener entry to the listeners map. this.#listeners.get(type)?.add(listenerEntry); @@ -94,9 +98,13 @@ export class EventEmitter { listener, wrappedListener: debouncedListener, once: true, - ...(debounceMilliseconds !== undefined ? { debounceTime: debounceMilliseconds } : {}), }; + // Set the debounce time if specified. + if (debounceMilliseconds && debounceMilliseconds > 0) { + listenerEntry.debounceTime = debounceMilliseconds; + } + // Add the listener entry to the listeners map. this.#listeners.get(type)?.add(listenerEntry);