Skip to content

Instantly share code, notes, and snippets.

View SheryConcepts's full-sized avatar
🐢
working

Sheharyar SheryConcepts

🐢
working
View GitHub Profile
@SheryConcepts
SheryConcepts / debounced.ts
Last active July 8, 2023 18:58
Typescript Debouncing Utility Function.
type FunctionType = (...args: any[]) => any;
function debounced<T extends FunctionType>(
func: T,
duration: number
): (...args: Parameters<T>) => ReturnType<T> {
let timeoutId: NodeJS.Timeout;
let result: ReturnType<T>;
return (...args: Parameters<T>) => {