TypeCzech is a library that enables checking functions to be called before
and after your functions run. These special functions can check for correct types,
certain argument values, and mutation of parameters. TypeCzech requires ECMAScript 2015 (ES6).
In the example to the left, the function before_Person() is executed before
the Person() function while after_Person() is run after the Person() function is finished.
The Person() function's input and output variables and values are accessable
for inspection.
The before & after checking functions signal errors by returning an error message;
an empty string "" or undefined means no error as shown with before_Person(). TypeCzech can be set to simply
log error messages to the console, or to stop execution via an exception as below.
type_czech = TypeCzech('THROW-EXCEPTIONS')
There are several ways to turn off the TypeCzech library for production use.
For example when using the below code, no PRE/POST checking functions are called.
type_czech = TypeCzech()
The before & after checking functions are linked to the function to be tested via this function call.
But parsing is still done.
Person = type_czech.linkUp(Person, before_Person, after_Person)
An example with no after checking function, just leave the after checking function off.
Person = type_czech.linkUp(Person, before_Person)
When there is no before checking function, use undefined as a placeholder.
Person = type_czech.linkUp(Person, undefined, after_Person)
Removable TypeCzech specific code in example is shown with a leading /**/ to distinguish
the difference between the testing code and normal source code.
/**/ highlights TypeCzech specific code