If Err this runs the mapping from ErrorT => Result<ValueT, NewErrorT>, otherwise it returns a new Result containing ValueT
If Ok, this uses the mapping function to transform Value to a new Value, and returns Result<New Value, ErrorT> otherwise it propagates the ErrorT.
Returns the ValueT if Ok, otherwise it returns defaultValue
Converts a Result<ValueT, ErrorT> to an Optional
Returns the ValueT if Ok, otherwise it throws ErrorT. This is the nuclear option, .or(default)
should be preferred.
Used to wrap a potential error throwing function into a safe Result wrapped function. Usage looks like:
const safeJsonParse = Result.wrap<typeof JSON.parse, SyntaxError>(JSON.parse)
Generated using TypeDoc
If Err this runs the mapping from ErrorT => ValueT, otherwise it returns a new Result containing ValueT