Skip to content

Instantly share code, notes, and snippets.

@mflisikowski
Forked from tcase360/debounce.js
Created September 12, 2017 15:04
Show Gist options
  • Save mflisikowski/cea742e3fee5ab46a36243ad92cdacb7 to your computer and use it in GitHub Desktop.
Save mflisikowski/cea742e3fee5ab46a36243ad92cdacb7 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