Skip to content

Instantly share code, notes, and snippets.

@AmesianX
Forked from corycook/debounce.js
Created March 19, 2019 20:39
Show Gist options
  • Select an option

  • Save AmesianX/248dc7798fc91cd937ba6e6baa5b0b62 to your computer and use it in GitHub Desktop.

Select an option

Save AmesianX/248dc7798fc91cd937ba6e6baa5b0b62 to your computer and use it in GitHub Desktop.
A really simple debounce function.
function debounce(fn, ms) {
let id;
return function() {
clearTimeout(id);
id = setTimeout(() => fn.apply(this, arguments), ms);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment