import { Truthy } from './truthy' export function assert(condition: boolean, error: Error | string): void { truthyOrThrow(condition, error) } export function assertValue( value: T, error: Error | string ): Truthy | never { return truthyOrThrow(value, error) } function truthyOrThrow(x: T, error: Error | string): Truthy | never { if (x) { return x as Truthy } if (error instanceof Error) { throw error } else { throw new Error(error) } }