@praha/byethrow
    Preparing search index...

    Function orElse

    Chains the next computation using the error value of a Result or ResultAsync. If the original result is a Success, it is returned unchanged. Otherwise, the provided function is called, and its result is returned as-is.

    The input Result or ResultAsync.

    The result type returned by fn.

    import { Result } from '@praha/byethrow';

    const result = Result.pipe(
    Result.succeed(42),
    Result.orElse((error) => Result.succeed(0)),
    );
    // { type: 'Success', value: 42 }
    const result = Result.pipe(
    Result.fail('original error'),
    Result.orElse((error) => Result.succeed('default value')),
    );
    // result: { type: 'Success', value: 'default value' }
    const result = Result.pipe(
    Result.fail('original error'),
    Result.orElse((error) => Result.fail('new error: ' + error)),
    );
    // result: { type: 'Failure', error: 'new error: original error' }

    pipe - It is recommended to use this function with the pipe function for better readability and composability.