import type { OmitStrict } from "./types" ; export class AssertionError extends Error { } export function assert ( condition , message ? ) { if ( ! condition ) { throw new AssertionError ( message || "assertion failed" ) ; } } export function assertNever ( n ) { throw new Error ( `never assertion failed, got value ${ n }` ) ; } export function recordKeys < T extends string > ( o ) { return Object . keys ( o ) as T [ ] ; } export function typesafeUnionMembers < T extends string > ( keys ) { return Object . keys ( keys ) as T [ ] ; } export function typesafePick < T extends object , K extends keyof T > ( o , ... keys ) { const copy = { } as any ; keys . forEach ( ( k ) => { copy [ k ] = o [ k ] ; } ) ; return copy ; } export function typesafeOmit < T extends object , K extends keyof T > ( o , ... keys ) { const copy = { ... o } ; keys . forEach ( ( k ) => { delete copy [ k ] ; } ) ; return copy ; } export function typesafeMapValues < K extends string , V , U > ( o , mapper ) { const result = { } as any ; recordKeys ( o ) . forEach ( ( k ) => { result [ k ] = mapper ( o [ k ] , k ) ; } ) ; return result ; }