Skip to content

Instantly share code, notes, and snippets.

@shapeshifta78
Forked from tcase360/debounce.js
Created November 8, 2017 17:39
Show Gist options
  • Save shapeshifta78/9b6bfab21fac63c72a3243fe62f519b0 to your computer and use it in GitHub Desktop.
Save shapeshifta78/9b6bfab21fac63c72a3243fe62f519b0 to your computer and use it in GitHub Desktop.
Debounce function in ES6
const debounce = (fn, time) => {
let timeout;
return function() {
const functionCall = () => fn.apply(this, arguments);
clearTimeout(timeout);
timeout = setTimeout(functionCall, time);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment