Provide a fallback for a given Result. Behaves like a logical
or: if the result value is an Ok, returns that result;
otherwise, returns the defaultResult value.
This is useful when you want to make sure that something which takes a
Result always ends up getting an Ok variant, by supplying a default value
for the case that you currently have an Err.
import { ok, err, Result, or } from'true-utils/result';
Provide a fallback for a given
Result
. Behaves like a logicalor
: if theresult
value is anOk
, returns thatresult
; otherwise, returns thedefaultResult
value.This is useful when you want to make sure that something which takes a
Result
always ends up getting anOk
variant, by supplying a default value for the case that you currently have anErr
.