The UnknownResult type to unwrap.
The Result to unwrap.
The error message to throw if the Result is Result.Err.
The success value if Result.Ok.
const okValue = Result.ok('data');
assert.isTrue(Result.expectToBe(okValue, 'should have value') === 'data');
const expectResult = Result.expectToBe<string>('missing result');
assert.throws(() => expectResult(Result.err('boom')), /missing result/u);
assert.isTrue(expectResult(Result.ok('value')) === 'value');
Unwraps a Result, returning the success value or throwing an error with
the provided message.
The error message to throw if the Result is Result.Err.
The success value if Result.Ok.
const okValue = Result.ok('data');
assert.isTrue(Result.expectToBe(okValue, 'should have value') === 'data');
const expectResult = Result.expectToBe<string>('missing result');
assert.throws(() => expectResult(Result.err('boom')), /missing result/u);
assert.isTrue(expectResult(Result.ok('value')) === 'value');
Unwraps a
Result, returning the success value or throwing an error with the provided message.