Created
January 3, 2021 06:49
-
-
Save okabe-yuya/fbb05d1aa08feac64c8179173ca205fd 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 interval = async (msFunc, callback, continueCond) => { | |
const _interval = async () => { | |
const sleepTime = msFunc(); | |
console.log("sleepTime: ", sleepTime); | |
await new Promise(resolve => { | |
setTimeout(resolve, sleepTime); | |
}); | |
if (continueCond()) { | |
callback(); | |
await _interval(); | |
} | |
}; | |
await _interval(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment