This page
does not include the TypeCzech library, thus all the code with /**/ is basically ignored.
The Console Output shows that the Person() output has not changed, save the missing error messages that
were generated by TypeCzech.
To enable easy turning on & off of TypeCzech, the below construct is used.
if (typeof TypeCzech === 'function')
type_czech = TypeCzech('LOG-ERRORS')
else
type_czech = { linkUp: (nop) => nop, isActive: (x) => false }
So if the script loading tag is missing then all TypeCzech calls turn linkUp() calls into nops.
Which in turn stops all PRE and POST functions from running.
<script src="TypeCzech.js"></script>
Note that there is a very small performance penalty for keeping the checking functions "as is", when the
TypeCzech library is not present.
All calls to Person below are still intercepted by the stand in type_czech.linkUp() in this example;
but they just bounce through.
type_czech = { linkUp: (nop) => nop, isActive: (x) => false }
So when there is no TypeCzech library, an extra function call tax is incurred.
Because the below code
Person = type_czech.linkUp(Person, PRE_check_Person)
Person(f_name, l_name);
Is transformed into this code, which has an extra function call and an extra return.
Person = function InterceptedPerson (f_name, l_name){
return Person(f_name, l_name);
}
By leaving the code in production, and not loading the library,
it is very easy to turn TypeCzech on & off for live testing.
Of course one can always choose not to load any TypeCzech code to production also.