Function asyncTasksParallel

  • Executes an array of asynchronous tasks in parallel and returns an array of results.

    Type Parameters

    • T

    Parameters

    • tasks: (() => Promise<T>)[]

      An array of functions that return a Promise of type T.

    Returns Promise<T[]>

    A Promise that resolves to an array of results of type T.

    Remarks

    This function is useful when you need to perform multiple asynchronous operations concurrently and wait for all of them to complete.

    Typeparam

    T - The type of the result that each asynchronous task returns.

    Example

    [
    async () => await fetch('https://api.example.com/data1'),
    async () => await fetch('https://api.example.com/data2'),
    async () => await fetch('https://api.example.com/data3')
    ].map(task => asyncTasksParallel(task));;
    //=> {results}

Generated using TypeDoc