1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-10 19:38:11 +01:00

[PM-5189] Removing custom debounce method that is unused

This commit is contained in:
Cesar Gonzalez 2024-06-20 15:57:34 -05:00
parent 84ff0e83e2
commit 616118b6d8
No known key found for this signature in database
GPG Key ID: 3381A5457F8CCECF

View File

@ -347,28 +347,3 @@ export function throttle(callback: () => void, limit: number) {
}
};
}
/**
* Debounces a callback function to run after a certain amount of time has passed.
*
* @param callback - The callback function to debounce.
* @param wait - The time in milliseconds to wait before running the callback.
* @param immediate - Determines whether the callback should run immediately.
*/
export function debounce(callback: () => void, wait: number, immediate?: boolean) {
let timeoutId: NodeJS.Timeout | number | null = null;
return (...args: unknown[]) => {
if (immediate && !timeoutId) {
callback.apply(this, args);
}
if (timeoutId) {
globalThis.clearTimeout(timeoutId);
}
timeoutId = globalThis.setTimeout(() => {
callback.apply(this, args);
timeoutId = null;
}, wait);
};
}