Guest User

Untitled

a guest
Oct 19th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.20 KB | None | 0 0
  1. function debounce(fn, delay = 200) {
  2. let pending
  3.  
  4. function postponed(...args) {
  5. pending && clearTimeout(pending)
  6.  
  7. pending = setTimeout(fn.bind(this, ...args), delay)
  8. }
  9.  
  10. return postponed
  11. }
Add Comment
Please, Sign In to add comment