Created
April 24, 2020 18:41
-
-
Save anshuraj/73d052a140d45d6fcccd6cd42ee24f53 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
const throttle = (func, delay) => { | |
let last = 0; | |
return function (...args) { | |
const context = this; | |
const now = new Date().getTime(); | |
if (now - last < delay) { | |
return; | |
} | |
last = now; | |
return func(args); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment