Skip to content

Instantly share code, notes, and snippets.

@robotlolita
Created December 19, 2013 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robotlolita/8033418 to your computer and use it in GitHub Desktop.
Save robotlolita/8033418 to your computer and use it in GitHub Desktop.
[p1, p2, p3, p4].reduce(function(result, current){
return result.then(function(context) {
return context.done? context
: /* otherwise */ b.then(function(value) {
return shouldWeGoOn(value)? { done: false, values: context.concat([value]) }
: /* otherwise */ { done: true, values: context }
})
})
}, Promise.of({ done: false, values: [] })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment