# Function each

- each<T>(values, iterator): Promise<void>

- Iterate over an array, or a promise of an array, which contains promises (or a mix of promises and values) with the given iterator function with the signature `(item, index)` where `item` is the resolved value of a respective promise in the input array. Iteration happens serially. If any promise in the input array is rejected the returned promise is rejected as well.

  If the iterator function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.

  #### Type Parameters

  - T

  #### Parameters

  - values: Iterable<T | PromiseLike<T>, any, any> | PromiseLike<Iterable<T | PromiseLike<T>, any, any>>

    The array of values to iterate over.

  - iterator: ((item: T, index: number) => void | PromiseLike<void>)

    The iterator function to apply to each element.

    - - (item, index): void | PromiseLike<void>

      - #### Parameters

        - item: T
        - index: number

        #### Returns void | PromiseLike<void>

  #### Returns Promise<void>