Skip to content

Instantly share code, notes, and snippets.

@batrudinych
Created January 14, 2019 10:58
Show Gist options
  • Save batrudinych/6229d492e064b7d92427a5d03f2162ee to your computer and use it in GitHub Desktop.
Save batrudinych/6229d492e064b7d92427a5d03f2162ee to your computer and use it in GitHub Desktop.
Running async operations in parallel and harvesting the results
async function take1() {
// Running Promises in parallel
const listOfPromises = listOfArguments.map(asyncOperation);
// Harvesting
const results = [];
for (const promise of listOfPromises) {
const index = await promise;
results.push(index);
}
return results;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment