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