aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/debounce.ts7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/utils/debounce.ts b/src/utils/debounce.ts
new file mode 100644
index 0000000..6a1756b
--- /dev/null
+++ b/src/utils/debounce.ts
@@ -0,0 +1,7 @@
+export function debounce<T extends Function>(func: T, delay = 300): T {
+ let timeout: NodeJS.Timeout;
+ return function (...args: any[]) {
+ clearTimeout(timeout);
+ timeout = setTimeout(() => { func(...args); }, delay);
+ } as any;
+} \ No newline at end of file