asrt
A small library to verify preconditions and postconditions.
Usage
; { ; ; return x + y;}
always() and assert() functions throw an AssertionError if the condition is false:
always1 > 0; // okalways1 < 0; // throws AssertionError
never() does the same but in reverse:
never1 > 0; // throws AssertionErrornever1 < 0; // ok
TypeScript
Asrt functions always() and assert() are typed to assert that the condition you pass them are true, which gives you certainty that your variable is of a given type at runtime.
declare ;
;alwaystypeof x === 'string';; // TypeScript knows that x must be a string, your IDE can suggest toUpperCase() method