Skip to content

Instantly share code, notes, and snippets.

@aperkaz
Created August 24, 2022 09:27
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 aperkaz/fc312385addf7ca610392e7341f0ddaa to your computer and use it in GitHub Desktop.
Save aperkaz/fc312385addf7ca610392e7341f0ddaa to your computer and use it in GitHub Desktop.
πŸ” asyncForEach utility in TS
async function asyncForEach<T>(
array: T[],
callback: (el: T, index: number, array: T[]) => Promise<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