Function find

  • Find a first item which holds true for a given predicate and return it wrapped in Some. Return None when no match is found.

    Type Parameters

    • T

    Parameters

    • predicate: ((_) => boolean)
        • (_): boolean
        • Parameters

          • _: T

          Returns boolean

    Returns ((xs) => Opt<T>)

      • (xs): Opt<T>
      • Parameters

        • xs: readonly T[]

        Returns Opt<T>

    Example

    find((x: number) => x > 0)([-1, 0, 1]) // Some(1)
    find((x: number) => x > 5)([0, 3, 5]) // None

Generated using TypeDoc