Created
July 2, 2024 12:31
-
-
Save RednibCoding/fad82b378cab2b6a1fdab12e99b22c9f to your computer and use it in GitHub Desktop.
js assert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple assert function that throws an error if the test is false | |
*/ | |
export function assert(condition: unknown, msg?: string): asserts condition { | |
if (condition === false) throw new AssertionError(msg); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment