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
03 - Turn Off TypeCzech by Not Loading Library

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.

Console Output