method Result.prototype.or
Result.prototype.or<U>(other: Result<U, E>): Result<T | U, E>

Returns this result if Ok, otherwise returns the fallback result.

Examples

Example 1

const result = fetchFromCache()
  .or(fetchFromDatabase())
  .or(fetchFromAPI());

Type Parameters

The type of the fallback Ok value

Parameters

other: Result<U, E>

The fallback Result to use if this is Err

Return Type

Result<T | U, E>

This result if Ok, otherwise the fallback

Usage

import { Result } from "result/mod.ts";