Skip to content

Instantly share code, notes, and snippets.

@olecksamdr
Created December 11, 2018 14:26
Show Gist options
  • Save olecksamdr/c98acf60fbf0c1cd9378dd3fe3d167e8 to your computer and use it in GitHub Desktop.
Save olecksamdr/c98acf60fbf0c1cd9378dd3fe3d167e8 to your computer and use it in GitHub Desktop.
debounce
// debounce :: Number -> (Args -> Any) -> (Args -> Undefined)
// Args = Any
export const debounce = time => (fn) => {
let timeout;
return (...args) => {
clearTimeout(timeout);
timeout = setTimeout(() => fn(...args), time);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment