Last active
December 11, 2020 10:01
-
-
Save jupegarnica/3ae9b81a67886b4440e3693eb19da72f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const debounce = (fn, delay = 0) => { | |
| let id; | |
| return (...args) => { | |
| if (id) { | |
| clearTimeout(id); | |
| } | |
| id = setTimeout(fn, delay, ...args); | |
| return id; | |
| }; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment