Class Ok<T>

Represents a successful result (Ok<T>), encapsulating a valid value.

Type Parameters

  • T

    The type of the successful value.

Hierarchy (view full)

Constructors

Methods

  • Executes the ifOk function with the contained value.

    Type Parameters

    • U

      The return type.

    Parameters

    • _ifErr: ((error: never) => U)

      (Unused) Function for Err<E>.

        • (error): U
        • Parameters

          • error: never

          Returns U

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

      Function to apply to the value.

        • (value): U
        • Parameters

          • value: T

          Returns U

    Returns U

    • The result of ifOk(value).
  • Transforms the contained value using a function.

    Type Parameters

    • U

      The return type after transformation.

    Parameters

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

      The function to apply.

        • (value): U
        • Parameters

          • value: T

          Returns U

    Returns Result<U, never>

    • A new Ok<U> containing the transformed value.
  • Maps the error, but since this is Ok<T>, it remains unchanged.

    Type Parameters

    • F

      The new error type.

    Parameters

    • _fn: ((error: never) => F)

      Unused error mapping function.

        • (error): F
        • Parameters

          • error: never

          Returns F

    Returns Result<T, F>

    • Returns itself, as Ok<T> has no error.