From 03197b1ab992540b951fcbc6f841cfcd42a757f3 Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 11 Jun 2022 16:42:33 +0200 Subject: Add kick sequencer --- src/lib/time.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/lib/time.ts (limited to 'src/lib/time.ts') diff --git a/src/lib/time.ts b/src/lib/time.ts new file mode 100644 index 0000000..d85e935 --- /dev/null +++ b/src/lib/time.ts @@ -0,0 +1,8 @@ +export function debounce(f: (...args: A) => void, timeout: number): (...args: A) => void { + let interval: number | undefined = undefined + + return (...args: A) => { + clearTimeout(interval) + interval = setTimeout(() => f.apply(this, args), timeout) + } +} -- cgit v1.2.3