better-returns
    Preparing search index...

    Function map

    • Transforms the successful value of a Result using a mapping function. If the result is Ok, the apply function is called with its value, and a new Ok result containing the transformed value is returned. If the result is Err, it is returned unchanged.

      Type Parameters

      • T

        The original type of the successful value.

      • E

        The type of the error value.

      • U

        The new type of the successful value after transformation.

      Parameters

      • result: Result<T, E>

        The result to map.

      • apply: (value: T) => U

        The function to apply to the successful value.

      Returns Result<U, E>

      A new Result with the mapped successful value, or the original Err.