@vaguevoid/fiasco / error / assert
Function: assert()
assert(
condition
,message?
):asserts condition
Defined in: src/error.ts:76
assert throws an error if the condition is false. unlike console.assert, this will prevent execution and allow usage of optional typescript types without guards after an assert.
Parameters
condition
any
message?
string
Returns
asserts condition
Example
ts
function foo(bar?: string) {
assert(bar, "bar is required")
console.log(bar.toUpperCase()) // bar is now a string
}