aboutsummaryrefslogtreecommitdiff
path: root/src/lib/function.ts
diff options
context:
space:
mode:
authorJoris2021-05-29 19:24:41 +0200
committerJoris2021-05-29 19:24:41 +0200
commitd48cafebb277e4ad4b31e883cbe4f55eef9ea4a4 (patch)
tree7f04fb49defa5fbc7984b0eee60bb7ce16a37ae2 /src/lib/function.ts
parent4e3cd92a8063a70dab9ae0ccafd0552c78c6e005 (diff)
Rewrite in TypeScript
Diffstat (limited to 'src/lib/function.ts')
-rw-r--r--src/lib/function.ts7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/lib/function.ts b/src/lib/function.ts
new file mode 100644
index 0000000..db7b436
--- /dev/null
+++ b/src/lib/function.ts
@@ -0,0 +1,7 @@
+export function debounce(func: any, timeout = 300){
+ let timer: any;
+ return (...args: any) => {
+ clearTimeout(timer);
+ timer = setTimeout(() => { func.apply(this, args); }, timeout);
+ };
+}