From 2cdd09249fadd635e34c1c768ab6c5eb7b2f152c Mon Sep 17 00:00:00 2001 From: OFF0 Date: Wed, 2 Aug 2023 18:20:32 +0200 Subject: [PATCH] utils: type bounce arguments --- src/utils/time.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils/time.ts b/src/utils/time.ts index 1b4c9ee..6423ecf 100644 --- a/src/utils/time.ts +++ b/src/utils/time.ts @@ -5,19 +5,19 @@ * @param {*} time desired interval to execute function * @returns callback */ -export const bounce = ( - fn: () => void, +export const bounce = ( + fn: (...args: T) => void, time: number, ) => { let throttle: number | undefined; let debounce: number | undefined; - return (/*...args*/) => { + return (...args: T) => { if (throttle) { clearTimeout(debounce); - debounce = setTimeout(() => fn(/*...args*/), time); + debounce = setTimeout(() => fn(...args), time); return; } - fn(/*...args*/); + fn(...args); throttle = setTimeout(() => { clearTimeout(throttle); }, time); -- 2.46.2