Permalink
Cannot retrieve contributors at this time
Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign up
Fetching contributors…
| import { Maybe } from './core'; | |
| export class AssertionFailed extends Error { | |
| constructor(message?: string) { | |
| super(message ? `Assertion failed: ${message}` : 'Assertion failed.'); | |
| } | |
| } | |
| export function assert(cond: boolean, message?: string): void { | |
| if (!cond) throw new AssertionFailed(message); | |
| } | |
| export function expect<T>(value: Maybe<T>, message = 'Unexpected null or undefined'): T { | |
| assert(value !== null && value !== undefined, message); | |
| return value as T; | |
| } |