@8hobbies/test-utils
    Preparing search index...

    Function forEachAtLeastOnce

    • Equivalent to calling array.forEach(callback), while also asserting that the loop has been entered upon at least once.

      Type Parameters

      • T

        The type of the element of array. @param array - The array being looped over. @param callbcak - The callback that is called in each iteration while iterating array. @return undefined. @assert callback` is called at least once.

      Parameters

      • array: readonly T[]
      • callback: (value: T, index: number, array: readonly T[]) => void

      Returns void

      const array = [1, 2, 3] as const;
      forEachAtLeastOnce(array, (n) => {console.log(n)});
    • Similar to the other overload, except that array can be modified within the callback.

      Type Parameters

      • T

      Parameters

      • array: T[]
      • callback: (value: T, index: number, array: T[]) => void

      Returns void