UNPKG

rc-js-util

Version:

A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.

98 lines (48 loc) 1.37 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [rc-js-util](./rc-js-util.md) &gt; [\_Debug](./rc-js-util._debug.md) &gt; [assert](./rc-js-util._debug.assert.md) ## \_Debug.assert() method Throws an `Error` with the given message if the condition is false. **Signature:** ```typescript static assert(this: void, condition: boolean, errorMessage: string): boolean; ``` ## Parameters <table><thead><tr><th> Parameter </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td> this </td><td> void </td><td> </td></tr> <tr><td> condition </td><td> boolean </td><td> </td></tr> <tr><td> errorMessage </td><td> string </td><td> </td></tr> </tbody></table> **Returns:** boolean A boolean value to make linting happy... ## Remarks If `_BUILD.DISABLE_BREAKPOINT_FLAG` is false or unset then a breakpoint will be hit first. Debug asserts are useful for providing hints to the programmer that they aren't meeting the contract of the API. ## Example ```typescript function foo(a1: number) { // not suitable for a production check, the programmer lied about the input type they supplied _BUILD.DEBUG && _Debug.assert(a1 != null, "a1 must be supplied"); } ```