Skip to content

Instantly share code, notes, and snippets.

@alexsasharegan
Created January 29, 2018 20:23
Show Gist options
  • Save alexsasharegan/36fed574ececd24889da6bc017ec3c5e to your computer and use it in GitHub Desktop.
Save alexsasharegan/36fed574ececd24889da6bc017ec3c5e to your computer and use it in GitHub Desktop.
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