Util: Add assertions
This commit is contained in:
parent
c7cdec7d22
commit
4d71efb394
1 changed files with 15 additions and 0 deletions
15
util/assertions.ts
Normal file
15
util/assertions.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
export function VERIFY(condition: boolean, message?: string): asserts condition is true {
|
||||
if (!condition) throw new Error(`VERIFY: ${message ?? 'Condition was not met.'}`);
|
||||
}
|
||||
|
||||
export function VERIFY_NOT_REACHED(message?: string): void {
|
||||
if (message !== undefined) throw new Error(`VERIFY_NOT_REACHED: ${message}`);
|
||||
|
||||
throw new Error('VERIFY_NOT_REACHED');
|
||||
}
|
||||
|
||||
export function TODO(message?: string): void {
|
||||
if (message !== undefined) throw new Error(`TODO: ${message}`);
|
||||
|
||||
throw new Error('TODO');
|
||||
}
|
Loading…
Reference in a new issue