Skip to content

Instantly share code, notes, and snippets.

@bayleedev
Created July 27, 2016 04:12
Show Gist options
  • Save bayleedev/90c1dc94f866edaa33c9b602ddd19cea to your computer and use it in GitHub Desktop.
Save bayleedev/90c1dc94f866edaa33c9b602ddd19cea to your computer and use it in GitHub Desktop.
var debounce = (fn, time) => {
const context = this
let timeout = 0
return function (chr) {
return fn.apply(context, arguments)
}
}
var fn = (args) => {
console.log('meow', args)
return true
}
var fn2 = debounce(fn, 200)
console.log('here', fn2('c'))
console.log('here', fn2('chr'))
console.log('here', fn2('chro')) // here
setTimeout(() => {
console.log('here', fn2('chrom')) // here
}, 300)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment