Skip to content

Instantly share code, notes, and snippets.

@RednibCoding
Created July 2, 2024 12:31
Show Gist options
  • Save RednibCoding/fad82b378cab2b6a1fdab12e99b22c9f to your computer and use it in GitHub Desktop.
Save RednibCoding/fad82b378cab2b6a1fdab12e99b22c9f to your computer and use it in GitHub Desktop.
js assert
/**
* 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