Skip to content

Instantly share code, notes, and snippets.

@fongreecss
Created May 25, 2023 08:17
Show Gist options
  • Save fongreecss/d06b099e30856861feb2c244aa73f298 to your computer and use it in GitHub Desktop.
Save fongreecss/d06b099e30856861feb2c244aa73f298 to your computer and use it in GitHub Desktop.
function delay(fn, ms){
let timer = 0
return function(...args){
clearTimeout(timer)
timer = setTimeout(fn.bind(this, ...args), ms || 0)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment