Skip to main content

CommonFindMap

Callable

  • CommonFindMap<Tinp, Tout>(array: readonly Tinp[], predicateMapper: (value: Tinp, index: number, obj: readonly Tinp[]) => Tout, thisArg?: any): Tout

  • Take an array and find the first element that maps to a user-specified value, returning the mapped value.

    Effectively combines array.find and array.map.


    Type parameters

    • Tinp
    • Tout

    Parameters

    • array: readonly Tinp[]

      The array in question

    • predicateMapper: (value: Tinp, index: number, obj: readonly Tinp[]) => Tout

      A mapping predicate. The first non-nullish return value will be returned by the outer function.

      • optionalthisArg: any = null

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns Tout

      • The mapped value or undefined if no non-nullish value was found