Skip to main content

CommonFindMap

Callable

  • CommonFindMap<Tinp, Tout>(array, predicateMapper, thisArg): 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.


    Parameters

    • array: readonly Tinp[]

      The array in question

    • predicateMapper: (value, index, obj) => 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