The second result.
resA
or resB
.
import { err, ok, or } from "./result.ts";
import { assertEquals } from "../deps.ts";
const success = ok<number>(2);
const failure = err<string>("not a 2");
const lateError = err<string>("late error");
const earlyError = err<string>("early error");
const anotherSuccess = ok<number>(100);
assertEquals(or<string, number>(lateError)(success), success);
assertEquals(or<string, number>(success)(earlyError), success);
assertEquals(or(lateError)(failure), lateError);
assertEquals(or(anotherSuccess)(success), success);
Generated using TypeDoc
Returns
resB
ifresA
is anErr
, otherwise returns the successresA
. The order of arguments is reversed because of that it is useful for partial applying.