Created
July 27, 2016 04:12
-
-
Save bayleedev/90c1dc94f866edaa33c9b602ddd19cea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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