/** * asyncMap returns the results of applying an async function over an list. * * @param list - Iterable object of items, e.g. an Array, Set, Object.keys * @param asyncTransform * @returns */ export async function asyncMap( list: Iterable, asyncTransform: (item: FromType, index: number) => Promise, ): Promise { const promises: Promise[] = []; let idx = 0; for (const item of list) { promises.push(asyncTransform(item, idx)); idx += 1; } return Promise.all(promises); }