Created
January 10, 2018 07:01
-
-
Save CaptainLiao/6359907cef8ba68ab4840bf6327e99af 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
function timeout(ms) { | |
return new Promise((resolve) => setTimeout(resolve, ms)) | |
} | |
async function sleep(time) { | |
await timeout(time) | |
} | |
function throttle (method, context) { | |
clearTimeout(context.timerId); | |
context.timerId = setTimeout(() => { | |
method.call(context); | |
}, 200) | |
} | |
export {sleep, throttle} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment