Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function runScript(times, interval, block) {
- function sleep (time) {
- return new Promise((resolve) => setTimeout(resolve, time));
- }
- i = 1;
- thenBlock = (() => {
- block();
- if(++i > times) return;
- sleep(interval).then(thenBlock);
- });
- thenBlock()
- };
- runScript(5, 100, function(){ console.log('test log') })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement