overleaf-cep/services/web/frontend/js/infrastructure/promise.ts
Alf Eaton 2fbb4615f9 Convert utility functions to TypeScript (#22658)
* Convert event-tracking to TypeScript

* Convert local-storage to TypeScript

* Convert mapSeries to TypeScript

* Convert SessionStorage to TypeScript

* Convert account-upgrade to TypeScript

* Convert isValidTeXFile to TypeScript

* Convert date functions to TypeScript

* Convert EventEmitter to TypeScript

* Convert isNetworkError to TypeScript

* Convert webpack-public-path to TypeScript

* Convert displayNameForUser to TypeScript

GitOrigin-RevId: 79c5a2d1101fcd520f3116f0f4af29d974189d94
2025-01-16 09:05:36 +00:00

13 lines
302 B
TypeScript

/**
* run `fn` in series for all values, and resolve with an array of the results
*/
export const mapSeries = async <T = any, V = any>(
values: T[],
fn: (item: T) => Promise<V>
) => {
const output: V[] = []
for (const value of values) {
output.push(await fn(value))
}
return output
}