From d48cafebb277e4ad4b31e883cbe4f55eef9ea4a4 Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 29 May 2021 19:24:41 +0200 Subject: Rewrite in TypeScript --- src/lib/function.ts | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/lib/function.ts (limited to 'src/lib/function.ts') 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); + }; +} -- cgit v1.2.3