Skip to content

Instantly share code, notes, and snippets.

@luan0ap
Created July 6, 2018 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save luan0ap/4fa87e37f1f0585ef2a9288520f5385c to your computer and use it in GitHub Desktop.
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.
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