Created
January 29, 2018 20:23
-
-
Save alexsasharegan/36fed574ececd24889da6bc017ec3c5e 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 processConsecutive(list, func) { | |
let len = list.length | |
let i = 0 | |
return new Promise(resolve => { | |
const iterate = item => { | |
func(item, () => { | |
i++ | |
if (i < len) { | |
return iterate(list[i]) | |
} | |
resolve() | |
}) | |
} | |
iterate(list[i]) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment