UNPKG

@uxland/functional

Version:
7 lines (6 loc) 254 B
export type ConditionFactory = () => any; export const invariant = (condition: any | ConditionFactory, message?: string) =>{ condition = typeof condition === 'function' ? condition() : condition; if(!condition) throw new Error(message); };