13 lines
410 B
TypeScript
13 lines
410 B
TypeScript
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
export function assert(condition: any, msg?: string): asserts condition {
|
|
if (!condition) {
|
|
throw new Error(msg || "condition is not truthy");
|
|
}
|
|
}
|
|
|
|
export function assertDefined<T>(value: T | undefined, msg?: string): asserts value is T {
|
|
if (value === undefined) {
|
|
throw new Error(msg || "value is undefined");
|
|
}
|
|
}
|