-
Notifications
You must be signed in to change notification settings - Fork 0
/
404-Extending-ClassFree-Single.html
288 lines (195 loc) · 13.7 KB
/
404-Extending-ClassFree-Single.html
1
2
3
4
5
6
7
8
9
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<!DOCTYPE html><meta charset="utf-8" />
<title>404 Extending ClassFree Single</title>
<div id="js-div" style="width: 60%" class="code-scroll">
<a href="https://github.com/steenhansen/type-czech" target="_blank" class="git-hub">GitHub Package</a>
<div id="js-code">the javascript</div>
<br />
</div>
<div id="the-explanation" style="width: 40%">
<div class="an-explantion">404 - Extending ClassFree Single</div>
<div id="explanation-text">
<br />
By moving all checking functions to an external file, it is possible to stop the loading and execution of TypeCzech code by commenting out loading of the
scripts. Note that this moves the function signatures and checking code away from the actual functions to be tested.
<pre>
<script s r c = "../../web-resources/TypeCzech.js">
<script s r c = "./404-classfree-external-checks.js">
</pre
>
Thus being left with one instruction that loads and executes the checks when TypeCzech has been imported.
<pre>
if (typeof check_linkUp_first_last_full === 'function') {
check_linkUp_first_last_full()
}
</pre
>
</div>
<div id="console-log">
<div class="a-title">Console Output</div>
<div id="log-text"></div>
<br />
<!-- ---------------TYPE 3--------------------------- -->
<script src="../../web-resources/consolelog.js"></script>
<script src="../../web-resources/TypeCzech.js"></script>
<script src="./404-classfree-external-checks.js"></script>
<link rel="stylesheet" href="../../web-resources/type-czech.css" />
<!-- ----------------TYPE 3-------------------------- -->
<div id="js-fiddles">
<a title="Example-Contents" href="../../example-snippets/example-contents.html">Contents</a>
<a title="00-Readme-Example" href="../../example-snippets/00-Readme-Example.html">00</a>
<a title="01-What-is-TypeCzech" href="../../example-snippets/01-What-is-TypeCzech.html">01</a>
<a title="02-Validate-Parameters-by-Value.html" href="../../example-snippets/02-Validate-Parameters-by-Value.html">02</a>
<a title="03-Turn-Off-Library-Not-Loaded.html" href="../../example-snippets/03-Turn-Off-Library-Not-Loaded.html">03</a>
<a title="04-Turn-Off-No-Check-Functions.html" href="../../example-snippets/04-Turn-Off-No-Check-Functions.html">04</a>
<a title="05-Verify-Return-Results-by-Value.html" href="../../example-snippets/05-Verify-Return-Results-by-Value.html">05</a>
<a title="06-Validate-Parameters-and-Results.html" href="../../example-snippets/06-Validate-Parameters-and-Results.html">06</a>
<a title="07-Mutated-Function-Parameters.html" href="../../example-snippets/07-Mutated-Function-Parameters.html">07</a>
<a title="08-Mutated-Recursive-Function-Parameters.html" href="../../example-snippets/08-Mutated-Recursive-Function-Parameters.html">08</a>
<a title="09-Closure-Parameters-Results-and-Methods.html" href="../../example-snippets/09-Closure-Parameters-Results-and-Methods.html">09</a>
<a title="10-Class-Parameters-Results-and-Methods.html" href="../../example-snippets/10-Class-Parameters-Results-and-Methods.html">10</a>
<a title="11-Object-Properties.html" href="../../example-snippets/11-Object-Properties.html">11</a>
<a title="12-Object-Interface.html" href="../../example-snippets/12-Object-Interface.html">12</a>
<a title="13-Parameter-and-Results-Multi-Types.html" href="../../example-snippets/13-Parameter-and-Results-Multi-Types.html">13</a>
<a title="14-Array-and-Object-Types.html" href="../../example-snippets/14-Array-and-Object-Types.html">14</a>
<a title="15-Lone-Single-Type-Parameter-Functions.html" href="../../example-snippets/15-Lone-Single-Type-Parameter-Functions.html">15</a>
<a title="16-Arrays-with-One-Type.html" href="../../example-snippets/16-Arrays-with-One-Type.html">16</a>
<a title="17-Variadic-Functions.html" href="../../example-snippets/17-Variadic-Functions.html">17</a>
<a title="18-Class-Type-Checks.html" href="../../example-snippets/18-Class-Type-Checks.html">18</a>
<a title="19-Lone-Empty-Param-and-Result.html" href="../../example-snippets/19-Lone-Empty-Param-and-Result.html">19</a>
<a title="20-Multiple-Empty-Params-and-Results.html" href="../../example-snippets/20-Multiple-Empty-Params-and-Results.html">20</a>
<a title="21-Type-Check-with-Extra-Optional-Params.html" href="../../example-snippets/21-Type-Check-with-Extra-Optional-Params.html">21</a>
<a title="22-Empty-Checks-with-Extra-Optional-Params.html" href="../../example-snippets/22-Empty-Checks-with-Extra-Optional-Params.html">22</a>
<a title="23-Typed-Either-Checks.html" href="../../example-snippets/23-Typed-Either-Checks.html">23</a>
<a title="24-Empty-Either-Checks.html" href="../../example-snippets/24-Empty-Either-Checks.html">24</a>
<a title="25-Default-Parameters.html" href="../../example-snippets/25-Default-Parameters.html">25</a>
<a title="26-Empty-Abbreviations.html" href="../../example-snippets/26-Empty-Abbreviations.html">26</a>
<a title="27-Type-and-Empty-Object-Extras.html" href="../../example-snippets/27-Type-and-Empty-Object-Extras.html">27</a>
<a title="28-Accept-Null-and-Undefined-Values.html" href="../../example-snippets/28-Accept-Null-and-Undefined-Values.html">28</a>
<a title="29-Class-Object-Type-Checks.html" href="../../example-snippets/29-Class-Object-Type-Checks.html">29</a>
<a title="30-HTML-Type-Checks.html" href="../../example-snippets/30-HTML-Type-Checks.html">30</a>
<a title="31-Extended-Class-Type-Checks.html" href="../../example-snippets/31-Extended-Class-Type-Checks.html">31</a>
<a title="32-Extended-Closure-Type-Checks-check.html" href="../../example-snippets/32-Extended-Closure-Type-Checks-check.html">32</a>
<a title="33-Count-Checks.html" href="../../example-snippets/33-Count-Checks.html">33</a>
<a title="34-Parameter-Check-Events.html" href="../../example-snippets/34-Parameter-Check-Events.html">34</a>
<a title="35-Throw-or-Log.html" href="../../example-snippets/35-Throw-or-Log.html">35</a>
<a title="36-Start-and-Stop.html" href="../../example-snippets/36-Start-and-Stop.html">36</a>
<a title="37-Readme-Example-Arrow-Functions.html" href="../../example-snippets/37-Readme-Example-Arrow-Functions.html">37</a>
<a title="38-Every-Check.html" href="../../example-snippets/38-Every-Check.html">38</a>
<a title="39-Assert-Checks.html" href="../../example-snippets/39-Assert-Checks.html">39</a>
<a title="40-Prescribed-Use.html" href="../../example-snippets/40-Prescribed-Use.html">40</a>
<a title="41-Lens-Example.html" href="../../example-snippets/41-Lens-Example.html">41</a>
<a title="42-Extended-Objects.html" href="../../example-snippets/42-Extended-Objects.html">42</a>
<a title="43-PHP-On-OFF-Extending-Classes.html" href="../../example-snippets/43-PHP-On-OFF-Extending-Classes.html">43</a>
<a title="101-Extending-Classes-Inline.html" href="../../examples-web/101-Extending-Classes-Inline.html">101</a>
<a title="102-Extending-Classes-Imports.html" href="../../examples-web/102-Extending-Classes-Imports/102-Extending-Classes-Imports.html">102</a>
<a title="103-Extending-Classes-Production.html" href="../../examples-web/103-Extending-Classes-Production/103-Extending-Classes-Production.html">103</a>
<a title="201-Extending-Closures-Inline.html" href="../../examples-web/201-Extending-Closures-Inline.html">201</a>
<a title="202-Extending-Closures-Imports.html" href="../../examples-web/202-Extending-Closures-Imports/202-Extending-Closures-Imports.html">202</a>
<a title="203-Extending-Closures-Production.html" href="../../examples-web/203-Extending-Closures-Production/203-Extending-Closures-Production.html"
>203</a
>
<a title="204-Extending-Closures-Single.html" href="../../examples-web/204-Extending-Closures-Single/204-Extending-Closures-Single.html">204</a>
<a title="301-Extending-IIFEs-Inline.html" href="../../examples-web/301-Extending-IIFEs-Inline.html">301</a>
<a title="302-Extending-IIFEs-Imports.html" href="../../examples-web/302-Extending-IIFEs-Imports/302-Extending-IIFEs-Imports.html">302</a>
<a title="303-Extending-IIFEs-Production.html" href="../../examples-web/303-Extending-IIFEs-Production/303-Extending-IIFEs-Production.html">303</a>
<a title="304-Extending-IIFEs-Single.html" href="../../examples-web/304-Extending-IIFEs-Single/304-Extending-IIFEs-Single.html">304</a>
<a title="401-Extending-ClassFree-Inline.html" href="../../examples-web/401-Extending-ClassFree-Inline.html">401</a>
<a title="402-Extending-ClassFree-Imports.html" href="../../examples-web/402-Extending-ClassFree-Imports/402-Extending-ClassFree-Imports.html">402</a>
<a title="403-Extending-ClassFree-Production.html" href="../../examples-web/403-Extending-ClassFree-Production/403-Extending-ClassFree-Production.html"
>403</a
>
<a title="404-Extending-ClassFree-Single.html" href="../../examples-web/404-Extending-ClassFree-Single/404-Extending-ClassFree-Single.html">404</a>
<a title="501-Extending-Prototypes-Inline.html" href="../../examples-web/501-Extending-Prototypes-Inline.html">501</a>
<a title="502-Extending-Prototypes-Imports.html" href="../../examples-web/502-Extending-Prototypes-Imports/502-Extending-Prototypes-Imports.html">502</a>
<a title="503-Extending-Prototypes-Production.html" href="../../examples-web/503-Extending-Prototypes-Production/503-Extending-Prototypes-Production.html"
>503</a
>
<a title="504-Extending-Prototypes-Single.html" href="../../examples-web/504-Extending-Prototypes-Single/504-Extending-Prototypes-Single.html">504</a>
<a title="601-Extending-OLOO-Inline.html" href="../../examples-web/601-Extending-OLOO-Inline.html">601</a>
<a title="602-Extending-OLOO-Imports.html" href="../../examples-web/602-Extending-OLOO-Imports/602-Extending-OLOO-Imports.html">602</a>
<a title="603-Extending-OLOO-Production.html" href="../../examples-web/603-Extending-OLOO-Production/603-Extending-OLOO-Production.html">603</a>
<a title="604-Extending-OLOO-Single.html" href="../../examples-web/604-Extending-OLOO-Single/604-Extending-OLOO-Single.html">604</a>
<a title="700-Simple-Example.html" href="../../example-snippets/700-Simple-Example.html">700</a>
<a title="701-Array-of-Objects.html" href="../../example-snippets/701-Array-of-Objects.html">701</a>
<a title="702-DeClassify.html" href="../../example-snippets/702-DeClassify.html">702</a>
<a title="703-Async-Await.html" href="../../example-snippets/703-Async-Await.html">703</a>
<a title="704-Ramda-Curry.html" href="../../example-snippets/704-Ramda-Curry.html">704</a>
<a title="705-Sensible-Switching.html" href="../../example-snippets/705-Sensible-Switching.html">705</a>
<a title="706-Elegant-On-Off" href="../../example-snippets/706-Elegant-On-Off.html">706</a>
<a title="707-React-JSX.html" href="../../example-snippets/707-React-JSX.html">707</a>
<a title="708-Monad-Type-Checking.html" href="../../example-snippets/708-Monad-Type-Checking.html">708</a>
<a title="709-Generators.html" href="../../example-snippets/709-Generators.html">709</a>
<a title="710-One-Check-Function.html" href="../../example-snippets/710-One-Check-Function.html">710</a>
© 2024 Steen Hansen
</div>
<!-- ----------------TYPE 3-------------------------- -->
</div>
<br />
</div>
<script>
log = captureConsole("log-text");
</script>
<script id="check-code">
/**/ //<script src="../TypeCzech.js">
/**/ //<script src="./404-classfree-external-checks.js">
First = function (spec) {
let {f_name} = spec
log(NL+`CONS-First :${f_name}`)
firstMethod = function(a_date) {
log(NL+`RUN -firstMethod :${f_name} `, a_date)
return a_date
}
first_object = {firstMethod}
return Object.freeze(first_object)
}
Last = function (spec) {
let {f_name, l_name} = spec
let {firstMethod} = First(spec)
log(NL+LEVEL_1+`CONS-Last :${f_name} ${l_name}`)
lastMethod = function (a_year) {
log(LEVEL_1+`RUN -lastMethod :${a_year} ${f_name} ${l_name}`)
return a_year
}
last_object = {firstMethod, lastMethod}
return Object.freeze(last_object)
}
Full = function (spec) {
let {f_name, l_name, salu} = spec
let {firstMethod, lastMethod} = Last(spec)
log(NL+LEVEL_2+`CONS-Full :${salu} ${f_name} ${l_name}`)
fullMethod = function (a_book) {
log(LEVEL_2+`RUN -fullMethod :${a_book} ${salu} ${l_name}`)
return a_book
}
function showName() {
return `${salu} ${f_name} ${l_name}`
}
full_object = {showName, firstMethod, lastMethod, fullMethod}
return Object.freeze(full_object)
}
/**/ if (typeof check_linkUp_first_last_full === 'function') {
/**/ check_linkUp_first_last_full()
/**/ }
const frank_herbert = Full({salu: 'Mr', f_name:'Frank', l_name:'Herbert'})
frank_herbert.firstMethod(new Date(1965,7,1))
frank_herbert.lastMethod(1966)
frank_herbert.fullMethod('Dune')
linesConsole(2)
/**/ function PRE_check_printFullFunc(a_person){
/**/ the_interface = {showName:'function', fullMethod:'function',
/**/ firstMethod:'function', lastMethod:'function'}
/**/ return type_czech.check_interface(a_person, the_interface)
/**/ }
/**/ printFullFunc = type_czech.linkUp(printFullFunc, PRE_check_printFullFunc)
function printFullFunc(a_person) {
log('From Checked Function : ', a_person.showName())
}
printFullFunc(frank_herbert)
</script>
<script>
jsToDiv("js-code", "check-code");
fromToBoldText(1234, 1263, "code", 1); //check_linkUp_first_last_full()
</script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Inconsolata" />