Skip to content

Instantly share code, notes, and snippets.

@kalisjoshua
Last active January 4, 2022 21:15
Show Gist options
  • Save kalisjoshua/d401b0b333f89e3a1d4df33d63d6379d to your computer and use it in GitHub Desktop.
Save kalisjoshua/d401b0b333f89e3a1d4df33d63d6379d to your computer and use it in GitHub Desktop.
const debounce = (fn, delay) => {
let pending
return function postponed (...args) {
pending && clearTimeout(pending)
pending = setTimeout(fn.bind(this, ...args), delay || 200)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment