Documentation
    Preparing search index...
    • Executes an asynchronous function a specified number of times sequentially.

      Executes the function with indices from 0 to count-1 incrementally. Each execution is performed sequentially, and all results are collected into an array.

      Type Parameters

      • T

        The type of the result from each execution

      Parameters

      • count: number

        The number of times to repeat (non-negative integer)

      • closure: (index: number) => Promise<T>

        The asynchronous function to execute repeatedly

      Returns Promise<T[]>

      A Promise resolving to an array of results

        // Generate random data 5 times
      const randomData = await ArrayUtil.asyncRepeat(5, async (index) => {
      await new Promise(resolve => setTimeout(resolve, 100)); // Wait 0.1 seconds
      return {
      id: index,
      value: Math.random(),
      timestamp: new Date().toISOString()
      };
      });
      console.log('Generated data:', randomData);