Tweakr
    Preparing search index...

    Function series

    • Executes an array of asynchronous tasks sequentially (one after another), returning an array of results in the same order as the tasks.

      Unlike parallelLimit, tasks are not run concurrently.

      Type Parameters

      • T

        The type of each task’s resolved value.

      Parameters

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

        An array of functions returning promises.

      Returns Promise<T[]>

      A promise that resolves to an array of task results.

      const tasks = [
      async () => 1,
      async () => 2,
      async () => 3
      ];
      const results = await series(tasks);
      console.log(results); // [1, 2, 3]

      1.1.0