export class AssertionError extends Error { constructor ( message = 'Assertion error!' , ... rest ) { super ( message , ... rest ) ; if ( Error . captureStackTrace ) { Error . captureStackTrace ( this , AssertionError ) ; } this . name = 'AssertionError' ; } } export function assert ( condition , msg ? ) { if ( ! condition ) { throw new AssertionError ( msg ) ; } } export function assertIsDefined < T > ( val ) { if ( val === undefined || val === null ) { throw new AssertionError ( `Expected 'val' to be defined, but received ${ val }` ) ; } }