promiseMap
Script
v2
Fork
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
)
)
)
;
}