latex-ub/services/web/frontend/js/infrastructure/promise.ts
2025-05-05 12:24:05 +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
}