Merge branch 'main' into diff-view-v2

This commit is contained in:
Toddyclipsgg
2025-02-21 00:37:50 -03:00
committed by GitHub
14 changed files with 737 additions and 403 deletions

View File

@@ -1,17 +1,13 @@
export function debounce<Args extends any[]>(fn: (...args: Args) => void, delay = 100) {
if (delay === 0) {
return fn;
}
export function debounce<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => void {
let timeout: NodeJS.Timeout;
let timer: number | undefined;
return function executedFunction(...args: Parameters<T>) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
return function <U>(this: U, ...args: Args) {
const context = this;
clearTimeout(timer);
timer = window.setTimeout(() => {
fn.apply(context, args);
}, delay);
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
}