# Function map

- map<T, U>(values, mapper): Promise<U[]>

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

  If the mapper function returns promises or then-ables, the returned promise will wait for all the mapped results to be resolved as well.

  The mapper function for a given item is called as soon as possible, that is, when the promise for that item's index in the input array is fulfilled. This means that multiple promises may be pending concurrently, and that the mapper function may not be applied to elements in the order that they appear in the original array. However, items in the resulting array will always appear in the same order as the input items.

  #### Type Parameters

  - T
  - U

  #### Parameters

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

    The array of values to map over.

  - mapper: ((item: T, index: number) => U | PromiseLike<U>)

    The mapper function to apply to each element.

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

      - #### Parameters

        - item: T
        - index: number

        #### Returns U | PromiseLike<U>

  #### Returns Promise<U[]>