refactor: commands from menu

This commit is contained in:
2023-08-04 13:48:12 +02:00
parent b95cfcc5b4
commit f9638c35fc
12 changed files with 317 additions and 114 deletions

View File

@@ -76,3 +76,15 @@ export const createStreamResponse = () => {
enqueue,
};
};
export function debounce<T extends (...args: Parameters<T>) => void>(
this: ThisParameterType<T>,
fn: T,
delay = 300,
) {
let timer: ReturnType<typeof setTimeout> | undefined;
return (...args: Parameters<T>) => {
clearTimeout(timer);
timer = setTimeout(() => fn.apply(this, args), delay);
};
}