Closes #1707 Reviewed-on: #1711 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
9 lines
316 B
TypeScript
9 lines
316 B
TypeScript
// Misnomer: We have concurrency, not parallelism - oh well!
|
|
export const parallelForeach = async <T>(data: T[], op: (datum: T) => Promise<void>): Promise<void> => {
|
|
const promises: Promise<void>[] = [];
|
|
for (const datum of data) {
|
|
promises.push(op(datum));
|
|
}
|
|
await Promise.all(promises);
|
|
};
|