Function Ok

  • Creates an Ok instance of Result containing the success value. This function is used to represent a successful result in operations that could potentially fail.

    Type Parameters

    • T extends NonUndefined
    • E extends NonUndefined = never

    Parameters

    • val: T

      The value to be contained within the Ok Result.

    Returns OkResult<T, E>

    A Result instance representing success and containing the provided value.

    const successResult = Ok(42);
    console.log(successResult.unwrap()); // Outputs: 42