2022-10-23 15:00:27 +02:00
|
|
|
import PoorManIntervals from '@joplin/lib/PoorManIntervals';
|
|
|
|
|
2024-04-05 13:16:49 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
2022-10-23 15:00:27 +02:00
|
|
|
function debounce(func: (...args: any[])=> void, timeout: number) {
|
|
|
|
let timer: number;
|
|
|
|
|
2024-04-05 13:16:49 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
2022-10-23 15:00:27 +02:00
|
|
|
return (...args: any[]) => {
|
|
|
|
PoorManIntervals.clearTimeout(timer);
|
|
|
|
timer = PoorManIntervals.setTimeout(() => { func.apply(this, args); }, timeout);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default debounce;
|