Skip to main content
Module

x/result_js/mod.ts>or

Minimum result type port of Rust
Latest
function or
import { or } from "https://deno.land/x/result_js@2.0.0/mod.ts";

Returns res if the result is Err, otherwise returns the Ok.

Examples

Example 1

import { or } from "https://deno.land/x/result_js/operators/logical.ts";
import { Err, Ok, type Result } from "https://deno.land/x/result_js/spec.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";

declare const result: Result<unknown, unknown>;

assertEquals(or(Ok(0), result), Ok(0));
assertEquals(or(Err(1), result), result);

Parameters

result: Result<T, E>
res: Result<T, E>