Skip to content

Instantly share code, notes, and snippets.

@mattiaerre
Created October 17, 2019 20:50
Show Gist options
  • Save mattiaerre/9c12c8e642d2f84d187c83189a3a5d2d to your computer and use it in GitHub Desktop.
Save mattiaerre/9c12c8e642d2f84d187c83189a3a5d2d to your computer and use it in GitHub Desktop.
async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index += 1) {
// eslint-disable-next-line no-await-in-loop
await callback(array[index], index, array);
}
}
// credit to https://codeburst.io/javascript-async-await-with-foreach-b6ba62bbf404
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment