remove temp debounce

This commit is contained in:
Michael Freno
2025-12-20 13:34:18 -05:00
parent 9cea36988c
commit e9a2b00254
7 changed files with 5 additions and 62 deletions

View File

@@ -100,34 +100,3 @@ export function insertSoftHyphens(
})
.join(" ");
}
/**
* Creates a debounced function that delays execution until after specified delay
* @param fn - The function to debounce
* @param delay - Delay in milliseconds
* @returns Debounced function with cancel method
*/
export function debounce<T extends (...args: any[]) => any>(
fn: T,
delay: number
): T & { cancel: () => void } {
let timeoutId: ReturnType<typeof setTimeout> | undefined;
const debounced = function (this: any, ...args: Parameters<T>) {
if (timeoutId !== undefined) {
clearTimeout(timeoutId);
}
timeoutId = setTimeout(() => {
fn.apply(this, args);
}, delay);
} as T & { cancel: () => void };
debounced.cancel = () => {
if (timeoutId !== undefined) {
clearTimeout(timeoutId);
timeoutId = undefined;
}
};
return debounced;
}

View File

@@ -190,33 +190,6 @@ export function sortComments(
}
}
// ============================================================================
// Debounce Utility
// ============================================================================
/**
* Debounces a function call to limit execution frequency
* Useful for window resize and scroll events
*/
export function debounce<T extends (...args: any[]) => any>(
func: T,
wait: number
): (...args: Parameters<T>) => void {
let timeout: ReturnType<typeof setTimeout> | null = null;
return function executedFunction(...args: Parameters<T>) {
const later = () => {
timeout = null;
func(...args);
};
if (timeout !== null) {
clearTimeout(timeout);
}
timeout = setTimeout(later, wait);
};
}
// ============================================================================
// Validation Utilities
// ============================================================================