1
2
3
4
5
// Maps over a collection with an async function.
// Awaits all the promises and returns the mapped data.
export async function promiseMap(data, asyncFunction) {
return await Promise.all(data.map((k) => asyncFunction(k)));
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023