Guest User

Untitled

a guest
Apr 20th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. /**
  2. * @module Debouncer
  3. */
  4. class Debouncer {
  5.  
  6. /**
  7. * @param {funciton} fn
  8. * @param {number} time
  9. * @returns {function}
  10. */
  11. debounce(fn, time) {
  12. let timeout = 100;
  13.  
  14. return () => {
  15. const functionCall = () => fn.apply(this, arguments);
  16.  
  17. clearTimeout(timeout);
  18. timeout = setTimeout(functionCall, time);
  19. };
  20. }
  21. }
  22.  
  23. export default Debouncer;
Add Comment
Please, Sign In to add comment