Function times

  • Invokes the getValue function n times, returning an array of the results.

    Type Parameters

    • R = number

      The return type of the getValue function.

    Parameters

    • Optionaln: number

      The number of times to invoke getValue.

    • OptionalgetValue: ((index: number) => R)

      The function to invoke for each index.

        • (index): R
        • Parameters

          • index: number

          Returns R

    Returns R[]

    An array containing the results of invoking getValue n times.

    times(3, (i) => i * 2); // => [0, 2, 4]
    times(2, () => 'es-toolkit'); // => ['es-toolkit', 'es-toolkit']