Created
August 12, 2016 13:25
-
-
Save asvny/462a8b10676d630b5e53ac5290ac21d8 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, ms) { | |
var last = (new Date()).getTime(); | |
return (function() { | |
var now = (new Date()).getTime(); | |
if (now - last > ms) { | |
last = now; | |
fn.apply(null, arguments); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment