The UnknownResult type to unwrap.
The type of the default value.
The error value if Result.Err, otherwise defaultValue.
const okResult = Result.ok('success');
const errResult = Result.err('failure');
assert.isTrue(Result.unwrapErrOr(okResult, 'default') === 'default');
assert.isTrue(Result.unwrapErrOr(errResult, 'default') === 'failure');
const unwrapError = Result.unwrapErrOr('fallback error');
assert.isTrue(unwrapError(Result.err('boom')) === 'boom');
assert.isTrue(unwrapError(Result.ok('no error')) === 'fallback error');
Unwraps a Result, returning the error value or a default value if it is
Result.Ok.
The type of the default value.
The value to return if result is Result.Ok.
The error value if Result.Err, otherwise defaultValue.
const okResult = Result.ok('success');
const errResult = Result.err('failure');
assert.isTrue(Result.unwrapErrOr(okResult, 'default') === 'default');
assert.isTrue(Result.unwrapErrOr(errResult, 'default') === 'failure');
const unwrapError = Result.unwrapErrOr('fallback error');
assert.isTrue(unwrapError(Result.err('boom')) === 'boom');
assert.isTrue(unwrapError(Result.ok('no error')) === 'fallback error');
Unwraps a
Result, returning the error value or a default value if it isResult.Ok.