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