mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-09 19:28:06 +01:00
[PM-5189] Removing custom debounce method that is unused
This commit is contained in:
parent
84ff0e83e2
commit
616118b6d8
@ -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);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user