summaryrefslogtreecommitdiff
path: root/source/helpers/async-for-each.ts
blob: 8c117062cf61c4a76d866d3cc160b1c4bf87a03c (plain) (blame)
1
2
3
4
5
6
7
/** Loop an iterable with the ability to place a non-blocking `await` in the loop itself */
export default async function asyncForEach<Item>(
	iterable: Iterable<Item>,
	iteratee: (item: Item) => Promise<void>,
): Promise<void> {
	await Promise.all([...iterable].map(async item => iteratee(item)));
}