From 5f598b5b7322d2e36f3d0778b91ee4854e643c0d Mon Sep 17 00:00:00 2001 From: Timur Manyanov <2737310+darkwebdev@users.noreply.github.com> Date: Thu, 16 Nov 2023 10:07:38 +0100 Subject: [PATCH] [#285] Improve debounce() readability --- src/common/debounce.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/common/debounce.ts b/src/common/debounce.ts index e3bcd36b..8bcf039a 100644 --- a/src/common/debounce.ts +++ b/src/common/debounce.ts @@ -1,9 +1,11 @@ -export const debounce = - ) => ReturnType>(fn: F, ms: number): (...args: Parameters) => void => { - let timer: ReturnType +export function debounce) => ReturnType>( + fn: F, + ms: number +): (...args: Parameters) => void { + let timer: ReturnType - return (...args: Parameters) => { - clearTimeout(timer) - timer = setTimeout(() => fn(...args), ms) - } - } + return (...args) => { + clearTimeout(timer) + timer = setTimeout(() => fn(...args), ms) + } +}