Execute Asynchronous Functions in Parallel
Code
# Code\n```typescript []\ntype Fn<T> = () => Promise<T>\n\nfunction promiseAll<T>(functions: Fn<T>[]): Promise<T[]> {\n    return new Promise((resolve, reject) => {\n        let resolvedCount = 0;\n        let resolvedPromises = [];\n\n        functions.forEach((fn, index) => {\n            fn()\n                .then(result => {\n                    resolvedCount++;\n                    resolvedPromises[index] = result;\n\n                    if (resolvedCount === functions.length) {\n                        resolve(resolvedPromises);\n                    }\n                })\n                .catch(reject)\n        });\n    });\n};\n```
['TypeScript']