Function filterMap

filterMap filers and maps an iterable at the same time.

It makes chains of filter and map more concise, as it shortens map().filter().map() to a single call.

  • Type Parameters

    • T
    • U

    Parameters

    • arr: T[]

      An array

    • fn: (value: T, index: number, array: T[]) => Option<U>

      A function that produces an Option.

    • OptionalthisArg: any

      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 U[]

    An array of filtered and mapped values.