GitHub Package
the javascript


Contents 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43    101 102 103 201 202 203 204 301 302 303 304 401 402 403 404 501 502 503 504 601 602 603 604    700 701 702 703 704 705 706 707 708 709 710 © 2024 Steen Hansen
01 - What is TypeCzech?

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
Console Output