-
-
Save wodCZ/386a79b091a9fb6cacb24baf3873cb07 to your computer and use it in GitHub Desktop.
JavaScript: async/await with forEach()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function asyncForEach<T>(array: T[], callback: (item: T, index: number, allItems: T[]) => void) { | |
for (let index = 0; index < array.length; index++) { | |
await callback(array[index], index, array); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment