Skip to content

Commit

Permalink
fix(js): fix debounce function
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour committed Nov 14, 2020
1 parent e33e6ca commit 82e6f4e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/autocomplete-js/src/utils/debounce.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export function debounce(fn: Function, time: number) {
let timerId: ReturnType<typeof setTimeout> | undefined = undefined;

return function () {
return function (...args: unknown[]) {
if (timerId) {
clearTimeout(timerId);
}

timerId = setTimeout(fn(), time);
timerId = setTimeout(() => fn(...args), time);
};
}

0 comments on commit 82e6f4e

Please sign in to comment.