Skip to content

Instantly share code, notes, and snippets.

@ryuheechul
Created February 21, 2018 08:22
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 ryuheechul/c9234012e2801efe284f5ae20b1c7c5b to your computer and use it in GitHub Desktop.
Save ryuheechul/c9234012e2801efe284f5ae20b1c7c5b to your computer and use it in GitHub Desktop.
an example of no concurrency in JS Promise
function printTo100(n) {
for (i in [...Array(100).keys()]){
console.log(`${n}-${i}`)
}
return Promise.resolve()
}
Promise.all(
printTo100('a'),
printTo100('b'),
printTo100('c'),
printTo100('d'),
printTo100('e'),
printTo100('f')
)
// The result is aaa...bbb...ccc not abcabcabc...
@ryuheechul
Copy link
Author

ryuheechul commented Feb 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment