better-returns
    Preparing search index...

    Function then

    • Chains a function that returns a Result to an existing Result. If the result is Ok, the apply function is called with its value, and its returned Result is returned. If the result is Err, it is returned unchanged. This is similar to map, but apply also returns a Result, allowing for sequential operations.

      Type Parameters

      • T

        The original type of the successful value.

      • U

        The new type of the successful value after chaining.

      • E

        The type of the error value.

      Parameters

      • result: Result<T, E>

        The initial result.

      • apply: (value: T) => Result<U, E>

        The function to apply to the successful value, which itself returns a Result.

      Returns Result<U, E>

      A new Result from the chained operation, or the original Err.