Created
July 6, 2018 20:46
-
-
Save luan0ap/4fa87e37f1f0585ef2a9288520f5385c to your computer and use it in GitHub Desktop.
Implement a job scheduler which takes in a function f and an integer n, and calls f after n milliseconds.
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
const debounce = (fn = () => {}, wait = 1000) => (...args) => { | |
const delayed = () => fn.apply(this, args) | |
return setTimeout(delayed, wait) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment