Class Some<T>

Represents a value that is present (Some<T>).

Type Parameters

  • T

    The type of the contained value.

Hierarchy (view full)

Constructors

Methods

  • Returns Some<T> if the predicate is met, otherwise returns None.

    Parameters

    • predicate: ((value: T) => boolean)

      A condition to check.

        • (value): boolean
        • Parameters

          • value: T

          Returns boolean

    Returns Option<T>

    • Some<T> if condition is met, otherwise None.
  • Executes the ifSome function with the contained value.

    Type Parameters

    • U

      The return type.

    Parameters

    • _ifNone: (() => U)

      (Unused) Function to call if None.

        • (): U
        • Returns U

    • ifSome: ((value: T) => U)

      Function to call with the value if Some<T>.

        • (value): U
        • Parameters

          • value: T

          Returns U

    Returns U

    • The result of calling ifSome.
  • Transforms the contained value using the provided function.

    Type Parameters

    • U

      The return type after transformation.

    Parameters

    • fn: ((value: T) => U)

      The transformation function.

        • (value): U
        • Parameters

          • value: T

          Returns U

    Returns Option<U>

    • A Some<U> containing the transformed value.