* Makes an assertion, *logging* if it failed.
(assertion: T | false | undefined | null, message: string)
| 95 | * Makes an assertion, *logging* if it failed. |
| 96 | */ |
| 97 | public assert<T>(assertion: T | false | undefined | null, message: string): assertion is T { |
| 98 | if (assertion === false || assertion === undefined || assertion === null) { |
| 99 | this.error(LogTag.RuntimeAssertion, message, { error: new Error('Assertion failed') }); |
| 100 | |
| 101 | if (process.env.JS_DEBUG_THROW_ASSERTIONS) { |
| 102 | throw new Error(message); |
| 103 | } |
| 104 | |
| 105 | debugger; // break when running in development |
| 106 | return false; |
| 107 | } |
| 108 | |
| 109 | return true; |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * @inheritdoc |