diff options
author | Joris | 2022-06-11 16:42:33 +0200 |
---|---|---|
committer | Joris | 2022-06-11 16:42:33 +0200 |
commit | 03197b1ab992540b951fcbc6f841cfcd42a757f3 (patch) | |
tree | 2eb5277462b8dfef41e901a945f251725fb7ad8f /src/lib/time.ts | |
parent | 70c672535f36edaeaf1d63d4637830b564271c34 (diff) |
Add kick sequencer
Diffstat (limited to 'src/lib/time.ts')
-rw-r--r-- | src/lib/time.ts | 8 |
1 files changed, 8 insertions, 0 deletions
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<A extends any[]>(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) + } +} |