Created
August 9, 2016 01:29
-
-
Save asvny/c2aa1cd5c62174f487867d2066fb6159 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function throttle(fn, wait) { | |
var time = Date.now(); | |
return function() { | |
if ((time + wait - Date.now()) < 0) { | |
fn(); | |
time = Date.now(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment