This is what I use for similar tasks: ``` suspend ...
# coroutines
u
This is what I use for similar tasks:
Copy code
suspend fun <T, R> Iterable<T>.mapAsync(coroutineContext: CoroutineContext, transform: suspend (T) -> R): List<R> {
    val deferredElements = mutableListOf<Deferred<R>>()
    for (elem in this)
        deferredElements += async(coroutineContext) { transform(elem) }
    return deferredElements.map { it.await() }
}
👍 2