@w5s/errorFunctionsinvariantinvariant Callableinvariant(condition: false, message?: null | string): neverinvariant(condition: boolean, message?: null | string): asserts conditionAssert that condition is truthy, else throws Error { name: 'InvariantError', message } In production environment, message parameter could be stripped from source in order to reduce file size@exampleinvariant(true, 'this should be true');// passinvariant(false, 'this should be true');// throw new Error('this should be true')
Assert that
condition
is truthy, else throwsError { name: 'InvariantError', message }
In production environment,
message
parameter could be stripped from source in order to reduce file size