Skip to content

Instantly share code, notes, and snippets.

@arayaryoma
Created November 14, 2019 14:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arayaryoma/1299e0f791ad34742da6f5a3f1845a47 to your computer and use it in GitHub Desktop.
Save arayaryoma/1299e0f791ad34742da6f5a3f1845a47 to your computer and use it in GitHub Desktop.
Frequently used utility functions for TypeScript
const asyncForEach = async <T>(array: T[], callback: (item: T, index?: number) => Promise<unknown>): Promise<void> => {
for (let i = 0; i < array.length; i++) {
await callback(array[i], i);
}
return
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment