export default function asyncMap( arr: T[], fn: (cur: T, idx: number, arr: T[]) => Promise, ): Promise { return new Promise((resolve, reject) => { Promise.all(arr.map(fn)).then(resolve).catch(reject); }); }