export class AssertionError extends Error { override name = 'AssertionError'; constructor(message: string) { super(message); } } /** Asserts that the provided condition is truthy */ export function assert(condition: unknown, message = ''): asserts condition { if (!condition) throw new AssertionError(message); } /** Asserts that the provided value is a non-array/non-null object */ export function assertObject(value: V, message?: string): asserts value is V extends unknown[] ? never : NonNullable { assert(typeof value === 'object' && value !== null && !Array.isArray(value), message); } /** Asserts that the provided value is a non-empty string */ export function assertString(value: unknown, message?: string): asserts value is string { assert(typeof value === 'string' && value.length > 0, message); }