Skip to content

Instantly share code, notes, and snippets.

@themarcba
Created March 6, 2020 10:19
Show Gist options
  • Save themarcba/6dda156f5948c30d937459f3eb9ad27c to your computer and use it in GitHub Desktop.
Save themarcba/6dda156f5948c30d937459f3eb9ad27c to your computer and use it in GitHub Desktop.
const timedResolve = name => {
return new Promise(resolve =>
setTimeout(() => {
console.log(name)
resolve()
}, 500 * Math.random()),
)
}
Promise.all([
timedResolve('first'),
timedResolve('second'),
timedResolve('third'),
timedResolve('fourth')]
).then(() => {
console.log('done')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment