The UnknownOptional type to unwrap.
The Optional to unwrap.
The error message to throw if the Optional is
None.
The contained value if Some.
const optionalValue = Optional.some('data');
assert.isTrue(Optional.expectToBe(optionalValue, 'value expected') === 'data');
const expectValue = Optional.expectToBe<string>('missing optional');
assert.throws(() => expectValue(Optional.none), /missing optional/u);
assert.isTrue(expectValue(Optional.some('present')) === 'present');
Unwraps an Optional, returning the contained value or throwing an error
with the provided message.
The error message to throw if the Optional is
None.
The contained value if Some.
const optionalValue = Optional.some('data');
assert.isTrue(Optional.expectToBe(optionalValue, 'value expected') === 'data');
const expectValue = Optional.expectToBe<string>('missing optional');
assert.throws(() => expectValue(Optional.none), /missing optional/u);
assert.isTrue(expectValue(Optional.some('present')) === 'present');
Unwraps an
Optional, returning the contained value or throwing an error with the provided message.