• Select performs a filter and a mapper inside of a reduce, only iterating the list one time.

    Type Parameters

    • T
    • K

    Parameters

    • array: readonly T[]
    • mapper: ((item, index) => K)
        • (item, index): K
        • Parameters

          • item: T
          • index: number

          Returns K

    • condition: ((item, index) => boolean)
        • (item, index): boolean
        • Parameters

          • item: T
          • index: number

          Returns boolean

    Returns K[]

    Example

    select([1, 2, 3, 4], x => x*x, x > 2) == [9, 16]