Christian Fraß commited on 2021-03-08 23:52:24
Zeige 34 geänderte Dateien mit 25106 Einfügungen und 0 Löschungen.
... | ... |
@@ -0,0 +1,43 @@ |
1 |
+<!DOCTYPE HTML> |
|
2 |
+<html> |
|
3 |
+ <head> |
|
4 |
+ <meta charset="utf-8"/> |
|
5 |
+ <link rel="stylesheet" type="text/css" href="style.css"/> |
|
6 |
+ <script type="text/javascript" src="logic.js"></script> |
|
7 |
+ </head> |
|
8 |
+ <body> |
|
9 |
+ <select name="language_from"> |
|
10 |
+ <option value="_">*</option> |
|
11 |
+ <option value="afr">afr</option> |
|
12 |
+ <option value="dan">dan</option> |
|
13 |
+ <option value="deu">deu</option> |
|
14 |
+ <option value="eng">eng</option> |
|
15 |
+ <option value="flk">flk</option> |
|
16 |
+ <option value="gem">gem</option> |
|
17 |
+ <option value="isl">isl</option> |
|
18 |
+ <option value="nld">nld</option> |
|
19 |
+ <option value="nob">nob</option> |
|
20 |
+ <option value="swe">swe</option> |
|
21 |
+ <option value="yid">yid</option> |
|
22 |
+ </select> |
|
23 |
+ <select name="language_to"> |
|
24 |
+ <option value="_">*</option> |
|
25 |
+ <option value="afr">afr</option> |
|
26 |
+ <option value="dan">dan</option> |
|
27 |
+ <option value="deu">deu</option> |
|
28 |
+ <option value="eng">eng</option> |
|
29 |
+ <option value="flk">flk</option> |
|
30 |
+ <option value="gem">gem</option> |
|
31 |
+ <option value="isl">isl</option> |
|
32 |
+ <option value="nld">nld</option> |
|
33 |
+ <option value="nob">nob</option> |
|
34 |
+ <option value="swe">swe</option> |
|
35 |
+ <option value="yid">yid</option> |
|
36 |
+ </select> |
|
37 |
+ <input type="text" name="token"/> |
|
38 |
+ <button>query</button> |
|
39 |
+ <ul id="result"> |
|
40 |
+ </ul> |
|
41 |
+ </body> |
|
42 |
+</html> |
|
43 |
+ |
... | ... |
@@ -0,0 +1,8076 @@ |
1 |
+var __extends = (this && this.__extends) || (function () { |
|
2 |
+ var extendStatics = function (d, b) { |
|
3 |
+ extendStatics = Object.setPrototypeOf || |
|
4 |
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
|
5 |
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; |
|
6 |
+ return extendStatics(d, b); |
|
7 |
+ }; |
|
8 |
+ return function (d, b) { |
|
9 |
+ extendStatics(d, b); |
|
10 |
+ function __() { this.constructor = d; } |
|
11 |
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
|
12 |
+ }; |
|
13 |
+})(); |
|
14 |
+/* |
|
15 |
+This file is part of »bacterio-plankton:base«. |
|
16 |
+ |
|
17 |
+Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
18 |
+<info@greenscale.de> |
|
19 |
+ |
|
20 |
+»bacterio-plankton:base« is free software: you can redistribute it and/or modify |
|
21 |
+it under the terms of the GNU Lesser General Public License as published by |
|
22 |
+the Free Software Foundation, either version 3 of the License, or |
|
23 |
+(at your option) any later version. |
|
24 |
+ |
|
25 |
+»bacterio-plankton:base« is distributed in the hope that it will be useful, |
|
26 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
27 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
28 |
+GNU Lesser General Public License for more details. |
|
29 |
+ |
|
30 |
+You should have received a copy of the GNU Lesser General Public License |
|
31 |
+along with »bacterio-plankton:base«. If not, see <http://www.gnu.org/licenses/>. |
|
32 |
+ */ |
|
33 |
+// } |
|
34 |
+/* |
|
35 |
+This file is part of »bacterio-plankton:base«. |
|
36 |
+ |
|
37 |
+Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
38 |
+<info@greenscale.de> |
|
39 |
+ |
|
40 |
+»bacterio-plankton:base« is free software: you can redistribute it and/or modify |
|
41 |
+it under the terms of the GNU Lesser General Public License as published by |
|
42 |
+the Free Software Foundation, either version 3 of the License, or |
|
43 |
+(at your option) any later version. |
|
44 |
+ |
|
45 |
+»bacterio-plankton:base« is distributed in the hope that it will be useful, |
|
46 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
47 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
48 |
+GNU Lesser General Public License for more details. |
|
49 |
+ |
|
50 |
+You should have received a copy of the GNU Lesser General Public License |
|
51 |
+along with »bacterio-plankton:base«. If not, see <http://www.gnu.org/licenses/>. |
|
52 |
+ */ |
|
53 |
+/** |
|
54 |
+ * @author fenris |
|
55 |
+ */ |
|
56 |
+/*export*/ function pseudopointer_null() { |
|
57 |
+ return { |
|
58 |
+ "value": null |
|
59 |
+ }; |
|
60 |
+} |
|
61 |
+/** |
|
62 |
+ * @author fenris |
|
63 |
+ */ |
|
64 |
+/*export*/ function pseudopointer_make(value) { |
|
65 |
+ return { |
|
66 |
+ "value": value |
|
67 |
+ }; |
|
68 |
+} |
|
69 |
+/** |
|
70 |
+ * @author fenris |
|
71 |
+ */ |
|
72 |
+/*export*/ function pseudopointer_isset(pseudopointer) { |
|
73 |
+ return (pseudopointer.value != null); |
|
74 |
+} |
|
75 |
+/** |
|
76 |
+ * @author fenris |
|
77 |
+ */ |
|
78 |
+/*export*/ function pseudopointer_read(pseudopointer) { |
|
79 |
+ if (pseudopointer.value != null) { |
|
80 |
+ return pseudopointer.value; |
|
81 |
+ } |
|
82 |
+ else { |
|
83 |
+ var message = "nullpointer dereferencation"; |
|
84 |
+ throw (new Error(message)); |
|
85 |
+ } |
|
86 |
+} |
|
87 |
+/** |
|
88 |
+ * @author fenris |
|
89 |
+ */ |
|
90 |
+/*export*/ function pseudopointer_write(pseudopointer, value) { |
|
91 |
+ pseudopointer.value = value; |
|
92 |
+} |
|
93 |
+/* |
|
94 |
+This file is part of »bacterio-plankton:base«. |
|
95 |
+ |
|
96 |
+Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
97 |
+<info@greenscale.de> |
|
98 |
+ |
|
99 |
+»bacterio-plankton:base« is free software: you can redistribute it and/or modify |
|
100 |
+it under the terms of the GNU Lesser General Public License as published by |
|
101 |
+the Free Software Foundation, either version 3 of the License, or |
|
102 |
+(at your option) any later version. |
|
103 |
+ |
|
104 |
+»bacterio-plankton:base« is distributed in the hope that it will be useful, |
|
105 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
106 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
107 |
+GNU Lesser General Public License for more details. |
|
108 |
+ |
|
109 |
+You should have received a copy of the GNU Lesser General Public License |
|
110 |
+along with »bacterio-plankton:base«. If not, see <http://www.gnu.org/licenses/>. |
|
111 |
+ */ |
|
112 |
+; |
|
113 |
+var lib_base; |
|
114 |
+(function (lib_base) { |
|
115 |
+ /** |
|
116 |
+ * @author fenris |
|
117 |
+ */ |
|
118 |
+ function environment() { |
|
119 |
+ var entries = [ |
|
120 |
+ { |
|
121 |
+ "id": "web", |
|
122 |
+ "name": "Web", |
|
123 |
+ "predicate": function () { return (typeof (document) !== "undefined"); }, |
|
124 |
+ }, |
|
125 |
+ { |
|
126 |
+ "id": "node", |
|
127 |
+ "name": "Node.js", |
|
128 |
+ "predicate": function () { return (typeof (process) !== "undefined"); }, |
|
129 |
+ }, |
|
130 |
+ { |
|
131 |
+ "id": "rhino", |
|
132 |
+ "name": "Rhino", |
|
133 |
+ "predicate": function () { return (typeof (java) !== "undefined"); }, |
|
134 |
+ }, |
|
135 |
+ { |
|
136 |
+ "id": "webworker", |
|
137 |
+ "name": "WebWorker", |
|
138 |
+ "predicate": function () { return (typeof (self["WorkerNavigator"]) !== "undefined"); } |
|
139 |
+ } |
|
140 |
+ ]; |
|
141 |
+ var id; |
|
142 |
+ var found = entries.some(function (entry) { |
|
143 |
+ if (entry.predicate()) { |
|
144 |
+ id = entry.id; |
|
145 |
+ return true; |
|
146 |
+ } |
|
147 |
+ else { |
|
148 |
+ return false; |
|
149 |
+ } |
|
150 |
+ }); |
|
151 |
+ if (found) { |
|
152 |
+ return id; |
|
153 |
+ } |
|
154 |
+ else { |
|
155 |
+ throw (new Error("unknown environment")); |
|
156 |
+ } |
|
157 |
+ } |
|
158 |
+ lib_base.environment = environment; |
|
159 |
+})(lib_base || (lib_base = {})); |
|
160 |
+/* |
|
161 |
+This file is part of »bacterio-plankton:base«. |
|
162 |
+ |
|
163 |
+Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
164 |
+<info@greenscale.de> |
|
165 |
+ |
|
166 |
+»bacterio-plankton:base« is free software: you can redistribute it and/or modify |
|
167 |
+it under the terms of the GNU Lesser General Public License as published by |
|
168 |
+the Free Software Foundation, either version 3 of the License, or |
|
169 |
+(at your option) any later version. |
|
170 |
+ |
|
171 |
+»bacterio-plankton:base« is distributed in the hope that it will be useful, |
|
172 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
173 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
174 |
+GNU Lesser General Public License for more details. |
|
175 |
+ |
|
176 |
+You should have received a copy of the GNU Lesser General Public License |
|
177 |
+along with »bacterio-plankton:base«. If not, see <http://www.gnu.org/licenses/>. |
|
178 |
+ */ |
|
179 |
+/** |
|
180 |
+ * @author fenris |
|
181 |
+ */ |
|
182 |
+var instance_verbosity = 0; |
|
183 |
+/** |
|
184 |
+ * @author fenris |
|
185 |
+ */ |
|
186 |
+function instance_collate(value1, value2) { |
|
187 |
+ if (typeof (value1) === "object") { |
|
188 |
+ if (value1 == null) { |
|
189 |
+ return (value2 == null); |
|
190 |
+ } |
|
191 |
+ else { |
|
192 |
+ if ("_collate" in value1) { |
|
193 |
+ return value1["_collate"](value2); |
|
194 |
+ } |
|
195 |
+ else { |
|
196 |
+ throw (new Error("[collate]" + " " + "object has no such method")); |
|
197 |
+ } |
|
198 |
+ } |
|
199 |
+ } |
|
200 |
+ else { |
|
201 |
+ if (instance_verbosity >= 1) { |
|
202 |
+ lib_log.warn("[collate]" + " " + "primitive value; using default implementation"); |
|
203 |
+ } |
|
204 |
+ return (value1 === value2); |
|
205 |
+ } |
|
206 |
+} |
|
207 |
+/** |
|
208 |
+ * @author fenris |
|
209 |
+ */ |
|
210 |
+function instance_compare(value1, value2) { |
|
211 |
+ if (typeof (value1) === "object") { |
|
212 |
+ if ("_compare" in value1) { |
|
213 |
+ return value1["_compare"](value2); |
|
214 |
+ } |
|
215 |
+ else { |
|
216 |
+ throw (new Error("[compare]" + " " + "object has no such method")); |
|
217 |
+ } |
|
218 |
+ } |
|
219 |
+ else { |
|
220 |
+ if (instance_verbosity >= 1) { |
|
221 |
+ lib_log.warn("[compare]" + " " + "primitive value; using default implementation"); |
|
222 |
+ } |
|
223 |
+ return (value1 <= value2); |
|
224 |
+ } |
|
225 |
+} |
|
226 |
+/** |
|
227 |
+ * @author fenris |
|
228 |
+ */ |
|
229 |
+function instance_clone(value) { |
|
230 |
+ if (typeof (value) === "object") { |
|
231 |
+ if ("_clone" in value) { |
|
232 |
+ return value["_clone"](); |
|
233 |
+ } |
|
234 |
+ else { |
|
235 |
+ throw (new Error("[clone]" + " " + "object has no such method")); |
|
236 |
+ } |
|
237 |
+ } |
|
238 |
+ else { |
|
239 |
+ if (instance_verbosity >= 1) { |
|
240 |
+ lib_log.warn("[clone]" + " " + "primitive value; using default implementation"); |
|
241 |
+ } |
|
242 |
+ return value; |
|
243 |
+ } |
|
244 |
+} |
|
245 |
+/** |
|
246 |
+ * @desc the ability to generate a string out of the element, which identifies it to a high degree |
|
247 |
+ * @author fenris |
|
248 |
+ */ |
|
249 |
+function instance_hash(value) { |
|
250 |
+ if (typeof (value) === "object") { |
|
251 |
+ if ("_hash" in value) { |
|
252 |
+ return value["_hash"](); |
|
253 |
+ } |
|
254 |
+ else { |
|
255 |
+ throw (new Error("[hash]" + " " + "object has no such method")); |
|
256 |
+ } |
|
257 |
+ } |
|
258 |
+ else { |
|
259 |
+ if (instance_verbosity >= 1) { |
|
260 |
+ lib_log.warn("[hash]" + " " + "primitive value; using default implementation"); |
|
261 |
+ } |
|
262 |
+ return String(value); |
|
263 |
+ } |
|
264 |
+} |
|
265 |
+/** |
|
266 |
+ * @desc the ability to map the element to a textual representation (most likely not injective) |
|
267 |
+ * @author fenris |
|
268 |
+ */ |
|
269 |
+function instance_show(value) { |
|
270 |
+ if (typeof (value) === "object") { |
|
271 |
+ if (value == null) { |
|
272 |
+ return "NULL"; |
|
273 |
+ } |
|
274 |
+ else { |
|
275 |
+ if ("_show" in value) { |
|
276 |
+ return value["_show"](); |
|
277 |
+ } |
|
278 |
+ else { |
|
279 |
+ // throw (new Error("[show]" + " " + "object has no such method")); |
|
280 |
+ return JSON.stringify(value); |
|
281 |
+ } |
|
282 |
+ } |
|
283 |
+ } |
|
284 |
+ else { |
|
285 |
+ if (instance_verbosity >= 1) { |
|
286 |
+ lib_log.warn("[show]" + " " + "primitive value; using default implementation"); |
|
287 |
+ } |
|
288 |
+ return String(value); |
|
289 |
+ } |
|
290 |
+} |
|
291 |
+/* |
|
292 |
+This file is part of »bacterio-plankton:base«. |
|
293 |
+ |
|
294 |
+Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
295 |
+<info@greenscale.de> |
|
296 |
+ |
|
297 |
+»bacterio-plankton:base« is free software: you can redistribute it and/or modify |
|
298 |
+it under the terms of the GNU Lesser General Public License as published by |
|
299 |
+the Free Software Foundation, either version 3 of the License, or |
|
300 |
+(at your option) any later version. |
|
301 |
+ |
|
302 |
+»bacterio-plankton:base« is distributed in the hope that it will be useful, |
|
303 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
304 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
305 |
+GNU Lesser General Public License for more details. |
|
306 |
+ |
|
307 |
+You should have received a copy of the GNU Lesser General Public License |
|
308 |
+along with »bacterio-plankton:base«. If not, see <http://www.gnu.org/licenses/>. |
|
309 |
+ */ |
|
310 |
+/** |
|
311 |
+ * @todo outsource to dedicated plankton-lib |
|
312 |
+ */ |
|
313 |
+var lib_log; |
|
314 |
+(function (lib_log) { |
|
315 |
+ /** |
|
316 |
+ * @author fenris |
|
317 |
+ */ |
|
318 |
+ function log() { |
|
319 |
+ var args = []; |
|
320 |
+ for (var _i = 0; _i < arguments.length; _i++) { |
|
321 |
+ args[_i] = arguments[_i]; |
|
322 |
+ } |
|
323 |
+ /*window.*/ console.log.apply(console, args); |
|
324 |
+ } |
|
325 |
+ lib_log.log = log; |
|
326 |
+ /** |
|
327 |
+ * @author fenris |
|
328 |
+ */ |
|
329 |
+ function info() { |
|
330 |
+ var args = []; |
|
331 |
+ for (var _i = 0; _i < arguments.length; _i++) { |
|
332 |
+ args[_i] = arguments[_i]; |
|
333 |
+ } |
|
334 |
+ /*window.*/ console.info.apply(console, args); |
|
335 |
+ } |
|
336 |
+ lib_log.info = info; |
|
337 |
+ /** |
|
338 |
+ * @author fenris |
|
339 |
+ */ |
|
340 |
+ function warn() { |
|
341 |
+ var args = []; |
|
342 |
+ for (var _i = 0; _i < arguments.length; _i++) { |
|
343 |
+ args[_i] = arguments[_i]; |
|
344 |
+ } |
|
345 |
+ /*window.*/ console.warn.apply(console, args); |
|
346 |
+ } |
|
347 |
+ lib_log.warn = warn; |
|
348 |
+ /** |
|
349 |
+ * @author fenris |
|
350 |
+ */ |
|
351 |
+ function error() { |
|
352 |
+ var args = []; |
|
353 |
+ for (var _i = 0; _i < arguments.length; _i++) { |
|
354 |
+ args[_i] = arguments[_i]; |
|
355 |
+ } |
|
356 |
+ /*window.*/ console.error.apply(console, args); |
|
357 |
+ } |
|
358 |
+ lib_log.error = error; |
|
359 |
+})(lib_log || (lib_log = {})); |
|
360 |
+/* |
|
361 |
+This file is part of »bacterio-plankton:base«. |
|
362 |
+ |
|
363 |
+Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
364 |
+<info@greenscale.de> |
|
365 |
+ |
|
366 |
+»bacterio-plankton:base« is free software: you can redistribute it and/or modify |
|
367 |
+it under the terms of the GNU Lesser General Public License as published by |
|
368 |
+the Free Software Foundation, either version 3 of the License, or |
|
369 |
+(at your option) any later version. |
|
370 |
+ |
|
371 |
+»bacterio-plankton:base« is distributed in the hope that it will be useful, |
|
372 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
373 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
374 |
+GNU Lesser General Public License for more details. |
|
375 |
+ |
|
376 |
+You should have received a copy of the GNU Lesser General Public License |
|
377 |
+along with »bacterio-plankton:base«. If not, see <http://www.gnu.org/licenses/>. |
|
378 |
+ */ |
|
379 |
+/** |
|
380 |
+ * @author frac |
|
381 |
+ */ |
|
382 |
+var class_observer = /** @class */ (function () { |
|
383 |
+ /** |
|
384 |
+ * @author frac |
|
385 |
+ */ |
|
386 |
+ function class_observer() { |
|
387 |
+ this.counter = 0; |
|
388 |
+ this.actions = {}; |
|
389 |
+ this.buffer = []; |
|
390 |
+ } |
|
391 |
+ /** |
|
392 |
+ * @author frac |
|
393 |
+ */ |
|
394 |
+ class_observer.prototype.empty = function () { |
|
395 |
+ return (Object.keys(this.actions).length == 0); |
|
396 |
+ }; |
|
397 |
+ /** |
|
398 |
+ * @author frac |
|
399 |
+ */ |
|
400 |
+ class_observer.prototype.flush = function () { |
|
401 |
+ this.actions = {}; |
|
402 |
+ }; |
|
403 |
+ /** |
|
404 |
+ * @author frac |
|
405 |
+ */ |
|
406 |
+ class_observer.prototype.set = function (id, action) { |
|
407 |
+ this.actions[id] = action; |
|
408 |
+ }; |
|
409 |
+ /** |
|
410 |
+ * @author frac |
|
411 |
+ */ |
|
412 |
+ class_observer.prototype.del = function (id) { |
|
413 |
+ delete this.actions[id]; |
|
414 |
+ }; |
|
415 |
+ /** |
|
416 |
+ * @author frac |
|
417 |
+ */ |
|
418 |
+ class_observer.prototype.add = function (action) { |
|
419 |
+ this.set((this.counter++).toString(), action); |
|
420 |
+ }; |
|
421 |
+ /** |
|
422 |
+ * @author frac |
|
423 |
+ */ |
|
424 |
+ class_observer.prototype.notify = function (information, delayed) { |
|
425 |
+ var _this = this; |
|
426 |
+ if (information === void 0) { information = {}; } |
|
427 |
+ if (delayed === void 0) { delayed = false; } |
|
428 |
+ if (delayed) { |
|
429 |
+ this.buffer.push(information); |
|
430 |
+ } |
|
431 |
+ else { |
|
432 |
+ Object.keys(this.actions).forEach(function (id) { return _this.actions[id](information); }); |
|
433 |
+ } |
|
434 |
+ }; |
|
435 |
+ /** |
|
436 |
+ * @author frac |
|
437 |
+ */ |
|
438 |
+ class_observer.prototype.rollout = function () { |
|
439 |
+ var _this = this; |
|
440 |
+ this.buffer.forEach(function (information) { return _this.notify(information, false); }); |
|
441 |
+ this.buffer = []; |
|
442 |
+ }; |
|
443 |
+ return class_observer; |
|
444 |
+}()); |
|
445 |
+/** |
|
446 |
+ * @author frac |
|
447 |
+ */ |
|
448 |
+/* |
|
449 |
+export interface interface_readable<type_value> { |
|
450 |
+ |
|
451 |
+ |** |
|
452 |
+ * @author frac |
|
453 |
+ *| |
|
454 |
+ read() : type_executor<type_value, Error>; |
|
455 |
+ |
|
456 |
+} |
|
457 |
+ */ |
|
458 |
+/** |
|
459 |
+ * @author frac |
|
460 |
+ */ |
|
461 |
+/* |
|
462 |
+export interface interface_writeable<type_value> { |
|
463 |
+ |
|
464 |
+ |** |
|
465 |
+ * @author frac |
|
466 |
+ *| |
|
467 |
+ write(value : type_value) : type_executor<void, Error>; |
|
468 |
+ |
|
469 |
+} |
|
470 |
+ */ |
|
471 |
+/* |
|
472 |
+This file is part of »bacterio-plankton:base«. |
|
473 |
+ |
|
474 |
+Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
475 |
+<info@greenscale.de> |
|
476 |
+ |
|
477 |
+»bacterio-plankton:base« is free software: you can redistribute it and/or modify |
|
478 |
+it under the terms of the GNU Lesser General Public License as published by |
|
479 |
+the Free Software Foundation, either version 3 of the License, or |
|
480 |
+(at your option) any later version. |
|
481 |
+ |
|
482 |
+»bacterio-plankton:base« is distributed in the hope that it will be useful, |
|
483 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
484 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
485 |
+GNU Lesser General Public License for more details. |
|
486 |
+ |
|
487 |
+You should have received a copy of the GNU Lesser General Public License |
|
488 |
+along with »bacterio-plankton:base«. If not, see <http://www.gnu.org/licenses/>. |
|
489 |
+ */ |
|
490 |
+var lib_maybe; |
|
491 |
+(function (lib_maybe) { |
|
492 |
+ /** |
|
493 |
+ * @author fenris |
|
494 |
+ */ |
|
495 |
+ function make_nothing() { |
|
496 |
+ return { |
|
497 |
+ "kind": "nothing", |
|
498 |
+ "parameters": {} |
|
499 |
+ }; |
|
500 |
+ } |
|
501 |
+ lib_maybe.make_nothing = make_nothing; |
|
502 |
+ /** |
|
503 |
+ * @author fenris |
|
504 |
+ */ |
|
505 |
+ function make_just(value) { |
|
506 |
+ return { |
|
507 |
+ "kind": "just", |
|
508 |
+ "parameters": { |
|
509 |
+ "value": value |
|
510 |
+ } |
|
511 |
+ }; |
|
512 |
+ } |
|
513 |
+ lib_maybe.make_just = make_just; |
|
514 |
+ /** |
|
515 |
+ * @author fenris |
|
516 |
+ */ |
|
517 |
+ function is_nothing(maybe) { |
|
518 |
+ return (maybe.kind === "nothing"); |
|
519 |
+ } |
|
520 |
+ lib_maybe.is_nothing = is_nothing; |
|
521 |
+ /** |
|
522 |
+ * @author fenris |
|
523 |
+ */ |
|
524 |
+ function is_just(maybe) { |
|
525 |
+ return (maybe.kind === "just"); |
|
526 |
+ } |
|
527 |
+ lib_maybe.is_just = is_just; |
|
528 |
+ /** |
|
529 |
+ * @author fenris |
|
530 |
+ */ |
|
531 |
+ function cull(maybe) { |
|
532 |
+ if (!is_just(maybe)) { |
|
533 |
+ var message = "cull from nothing"; |
|
534 |
+ throw (new Error(message)); |
|
535 |
+ } |
|
536 |
+ else { |
|
537 |
+ var value = maybe.parameters["value"]; |
|
538 |
+ return value; |
|
539 |
+ } |
|
540 |
+ } |
|
541 |
+ lib_maybe.cull = cull; |
|
542 |
+ /** |
|
543 |
+ * @author fenris |
|
544 |
+ */ |
|
545 |
+ function propagate(maybe, function_) { |
|
546 |
+ if (!is_just(maybe)) { |
|
547 |
+ } |
|
548 |
+ else { |
|
549 |
+ var value = maybe.parameters["value"]; |
|
550 |
+ var maybe_ = function_(value); |
|
551 |
+ return maybe_; |
|
552 |
+ } |
|
553 |
+ } |
|
554 |
+ lib_maybe.propagate = propagate; |
|
555 |
+})(lib_maybe || (lib_maybe = {})); |
|
556 |
+/** |
|
557 |
+ * @author fenris |
|
558 |
+ */ |
|
559 |
+/*export*/ var class_maybe = /** @class */ (function () { |
|
560 |
+ function class_maybe() { |
|
561 |
+ } |
|
562 |
+ /** |
|
563 |
+ * @desc whether the wrapper is nothing |
|
564 |
+ * @author fenris |
|
565 |
+ */ |
|
566 |
+ class_maybe.prototype.is_nothing = function () { |
|
567 |
+ throw (new Error("not implemented: class_maybe.is_nothing")); |
|
568 |
+ }; |
|
569 |
+ /** |
|
570 |
+ * @desc whether the wrapper is just |
|
571 |
+ * @author fenris |
|
572 |
+ */ |
|
573 |
+ class_maybe.prototype.is_just = function () { |
|
574 |
+ throw (new Error("not implemented: class_maybe.is_just")); |
|
575 |
+ }; |
|
576 |
+ /** |
|
577 |
+ * @desc return the value, stored in the maybe-wrapper |
|
578 |
+ * @author fenris |
|
579 |
+ */ |
|
580 |
+ class_maybe.prototype.cull = function () { |
|
581 |
+ throw (new Error("not implemented: class_maybe.cull")); |
|
582 |
+ }; |
|
583 |
+ /** |
|
584 |
+ * @author fenris |
|
585 |
+ */ |
|
586 |
+ class_maybe.prototype.toString = function () { |
|
587 |
+ throw (new Error("not implemented: class_maybe.cull")); |
|
588 |
+ }; |
|
589 |
+ /** |
|
590 |
+ * @author fenris |
|
591 |
+ */ |
|
592 |
+ class_maybe.prototype.distinguish = function (action_just, action_nothing) { |
|
593 |
+ if (action_nothing === void 0) { action_nothing = function () { }; } |
|
594 |
+ throw (new Error("not implemented: class_maybe.distinguish")); |
|
595 |
+ }; |
|
596 |
+ /** |
|
597 |
+ * @author fenris |
|
598 |
+ */ |
|
599 |
+ class_maybe.prototype.propagate = function (action) { |
|
600 |
+ throw (new Error("not implemented: class_maybe.propagate")); |
|
601 |
+ }; |
|
602 |
+ /** |
|
603 |
+ * @desc [implementation] |
|
604 |
+ * @author fenris |
|
605 |
+ */ |
|
606 |
+ class_maybe.prototype._show = function () { |
|
607 |
+ return this.toString(); |
|
608 |
+ }; |
|
609 |
+ return class_maybe; |
|
610 |
+}()); |
|
611 |
+/** |
|
612 |
+ * @author fenris |
|
613 |
+ */ |
|
614 |
+/*export*/ var class_nothing = /** @class */ (function (_super) { |
|
615 |
+ __extends(class_nothing, _super); |
|
616 |
+ /** |
|
617 |
+ * @author fenris |
|
618 |
+ */ |
|
619 |
+ function class_nothing(reason) { |
|
620 |
+ if (reason === void 0) { reason = null; } |
|
621 |
+ var _this = _super.call(this) || this; |
|
622 |
+ _this.reason = reason; |
|
623 |
+ return _this; |
|
624 |
+ } |
|
625 |
+ /** |
|
626 |
+ * @author fenris |
|
627 |
+ */ |
|
628 |
+ class_nothing.prototype.is_nothing = function () { |
|
629 |
+ return true; |
|
630 |
+ }; |
|
631 |
+ /** |
|
632 |
+ * @author fenris |
|
633 |
+ */ |
|
634 |
+ class_nothing.prototype.is_just = function () { |
|
635 |
+ return false; |
|
636 |
+ }; |
|
637 |
+ /** |
|
638 |
+ * @author fenris |
|
639 |
+ */ |
|
640 |
+ class_nothing.prototype.cull = function () { |
|
641 |
+ var message = "you shouldn't cull a nothing-value …"; |
|
642 |
+ lib_log.warn(message); |
|
643 |
+ return null; |
|
644 |
+ }; |
|
645 |
+ /** |
|
646 |
+ * @author fenris |
|
647 |
+ */ |
|
648 |
+ class_nothing.prototype.toString = function () { |
|
649 |
+ return "<\u00B7>"; |
|
650 |
+ }; |
|
651 |
+ /** |
|
652 |
+ * @author fenris |
|
653 |
+ */ |
|
654 |
+ class_nothing.prototype.reason_get = function () { |
|
655 |
+ var content = ((this.reason == null) ? "·" : this.reason); |
|
656 |
+ return "<- " + content + " ->"; |
|
657 |
+ }; |
|
658 |
+ /** |
|
659 |
+ * @author fenris |
|
660 |
+ */ |
|
661 |
+ class_nothing.prototype.distinguish = function (action_just, action_nothing) { |
|
662 |
+ if (action_nothing === void 0) { action_nothing = function () { }; } |
|
663 |
+ action_nothing(this.reason); |
|
664 |
+ }; |
|
665 |
+ /** |
|
666 |
+ * @author fenris |
|
667 |
+ */ |
|
668 |
+ class_nothing.prototype.propagate = function (action) { |
|
669 |
+ return (new class_nothing(this.reason)); |
|
670 |
+ }; |
|
671 |
+ return class_nothing; |
|
672 |
+}(class_maybe)); |
|
673 |
+/** |
|
674 |
+ * @author fenris |
|
675 |
+ */ |
|
676 |
+/*export*/ var class_just = /** @class */ (function (_super) { |
|
677 |
+ __extends(class_just, _super); |
|
678 |
+ /** |
|
679 |
+ * @author fenris |
|
680 |
+ */ |
|
681 |
+ function class_just(value) { |
|
682 |
+ var _this = _super.call(this) || this; |
|
683 |
+ _this.value = value; |
|
684 |
+ return _this; |
|
685 |
+ } |
|
686 |
+ /** |
|
687 |
+ * @author fenris |
|
688 |
+ */ |
|
689 |
+ class_just.prototype.is_nothing = function () { |
|
690 |
+ return false; |
|
691 |
+ }; |
|
692 |
+ /** |
|
693 |
+ * @author fenris |
|
694 |
+ */ |
|
695 |
+ class_just.prototype.is_just = function () { |
|
696 |
+ return true; |
|
697 |
+ }; |
|
698 |
+ /** |
|
699 |
+ * @author fenris |
|
700 |
+ */ |
|
701 |
+ class_just.prototype.cull = function () { |
|
702 |
+ return this.value; |
|
703 |
+ }; |
|
704 |
+ /** |
|
705 |
+ * @author fenris |
|
706 |
+ */ |
|
707 |
+ class_just.prototype.toString = function () { |
|
708 |
+ var content = instance_show(this.value); |
|
709 |
+ return "<+ " + content + " +>"; |
|
710 |
+ }; |
|
711 |
+ /** |
|
712 |
+ * @author fenris |
|
713 |
+ */ |
|
714 |
+ class_just.prototype.distinguish = function (action_just, action_nothing) { |
|
715 |
+ if (action_nothing === void 0) { action_nothing = function () { }; } |
|
716 |
+ action_just(this.value); |
|
717 |
+ }; |
|
718 |
+ /** |
|
719 |
+ * @author fenris |
|
720 |
+ */ |
|
721 |
+ class_just.prototype.propagate = function (action) { |
|
722 |
+ return action(this.value); |
|
723 |
+ }; |
|
724 |
+ return class_just; |
|
725 |
+}(class_maybe)); |
|
726 |
+/* |
|
727 |
+This file is part of »bacterio-plankton:base«. |
|
728 |
+ |
|
729 |
+Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
730 |
+<info@greenscale.de> |
|
731 |
+ |
|
732 |
+»bacterio-plankton:base« is free software: you can redistribute it and/or modify |
|
733 |
+it under the terms of the GNU Lesser General Public License as published by |
|
734 |
+the Free Software Foundation, either version 3 of the License, or |
|
735 |
+(at your option) any later version. |
|
736 |
+ |
|
737 |
+»bacterio-plankton:base« is distributed in the hope that it will be useful, |
|
738 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
739 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
740 |
+GNU Lesser General Public License for more details. |
|
741 |
+ |
|
742 |
+You should have received a copy of the GNU Lesser General Public License |
|
743 |
+along with »bacterio-plankton:base«. If not, see <http://www.gnu.org/licenses/>. |
|
744 |
+ */ |
|
745 |
+/** |
|
746 |
+ * @author frac |
|
747 |
+ */ |
|
748 |
+var class_error = /** @class */ (function (_super) { |
|
749 |
+ __extends(class_error, _super); |
|
750 |
+ /** |
|
751 |
+ * @author frac |
|
752 |
+ */ |
|
753 |
+ function class_error(message, suberrors) { |
|
754 |
+ if (suberrors === void 0) { suberrors = []; } |
|
755 |
+ var _this = _super.call(this, message) || this; |
|
756 |
+ _this.suberrors = suberrors; |
|
757 |
+ _this.mess = message; |
|
758 |
+ return _this; |
|
759 |
+ } |
|
760 |
+ /** |
|
761 |
+ * @override |
|
762 |
+ * @author frac |
|
763 |
+ */ |
|
764 |
+ class_error.prototype.toString = function () { |
|
765 |
+ return ( /*super.toString()*/this.mess + " " + ("[" + this.suberrors.map(function (x) { return x.toString(); }).join(",") + "]")); |
|
766 |
+ }; |
|
767 |
+ return class_error; |
|
768 |
+}(Error)); |
|
769 |
+/* |
|
770 |
+This file is part of »bacterio-plankton:object«. |
|
771 |
+ |
|
772 |
+Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
773 |
+<info@greenscale.de> |
|
774 |
+ |
|
775 |
+»bacterio-plankton:object« is free software: you can redistribute it and/or modify |
|
776 |
+it under the terms of the GNU Lesser General Public License as published by |
|
777 |
+the Free Software Foundation, either version 3 of the License, or |
|
778 |
+(at your option) any later version. |
|
779 |
+ |
|
780 |
+»bacterio-plankton:object« is distributed in the hope that it will be useful, |
|
781 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
782 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
783 |
+GNU Lesser General Public License for more details. |
|
784 |
+ |
|
785 |
+You should have received a copy of the GNU Lesser General Public License |
|
786 |
+along with »bacterio-plankton:object«. If not, see <http://www.gnu.org/licenses/>. |
|
787 |
+ */ |
|
788 |
+var lib_object; |
|
789 |
+(function (lib_object) { |
|
790 |
+ /** |
|
791 |
+ * @author fenris |
|
792 |
+ */ |
|
793 |
+ function fetch(object, fieldname, fallback, escalation) { |
|
794 |
+ if (fallback === void 0) { fallback = null; } |
|
795 |
+ if (escalation === void 0) { escalation = 1; } |
|
796 |
+ if ((fieldname in object) && (object[fieldname] !== undefined)) { |
|
797 |
+ return object[fieldname]; |
|
798 |
+ } |
|
799 |
+ else { |
|
800 |
+ switch (escalation) { |
|
801 |
+ case 0: { |
|
802 |
+ return fallback; |
|
803 |
+ break; |
|
804 |
+ } |
|
805 |
+ case 1: { |
|
806 |
+ var message = ("field '" + fieldname + "' not in structure"); |
|
807 |
+ message += ("; using fallback value '" + String(fallback) + "'"); |
|
808 |
+ // console.warn(message); |
|
809 |
+ return fallback; |
|
810 |
+ break; |
|
811 |
+ } |
|
812 |
+ case 2: { |
|
813 |
+ var message = ("field '" + fieldname + "' not in structure"); |
|
814 |
+ throw (new Error(message)); |
|
815 |
+ break; |
|
816 |
+ } |
|
817 |
+ default: { |
|
818 |
+ throw (new Error("invalid escalation level " + escalation)); |
|
819 |
+ break; |
|
820 |
+ } |
|
821 |
+ } |
|
822 |
+ } |
|
823 |
+ } |
|
824 |
+ lib_object.fetch = fetch; |
|
825 |
+ /** |
|
826 |
+ * @author fenris |
|
827 |
+ */ |
|
828 |
+ function map(object_from, transformator) { |
|
829 |
+ var object_to = {}; |
|
830 |
+ Object.keys(object_from).forEach(function (key) { return (object_to[key] = transformator(object_from[key], key)); }); |
|
831 |
+ return object_to; |
|
832 |
+ } |
|
833 |
+ lib_object.map = map; |
|
834 |
+ /** |
|
835 |
+ * @desc gibt ein Objekt mit bestimmten Einträgen des Eingabe-Objekts zurück |
|
836 |
+ * @author fenris |
|
837 |
+ */ |
|
838 |
+ function filter(object_from, predicate) { |
|
839 |
+ var object_to = {}; |
|
840 |
+ Object.keys(object_from).forEach(function (key) { |
|
841 |
+ var value = object_from[key]; |
|
842 |
+ if (predicate(value, key)) { |
|
843 |
+ object_to[key] = value; |
|
844 |
+ } |
|
845 |
+ }); |
|
846 |
+ return object_to; |
|
847 |
+ } |
|
848 |
+ lib_object.filter = filter; |
|
849 |
+ /** |
|
850 |
+ * @desc wandelt ein Array mit Einträgen der Form {key,value} in ein entsprechendes Objekt um |
|
851 |
+ * @author fenris |
|
852 |
+ */ |
|
853 |
+ function from_array(array) { |
|
854 |
+ var object = {}; |
|
855 |
+ array.forEach(function (entry) { return (object[entry.key] = entry.value); }); |
|
856 |
+ return object; |
|
857 |
+ } |
|
858 |
+ lib_object.from_array = from_array; |
|
859 |
+ /** |
|
860 |
+ * @desc wandelt ein Objekt in ein entsprechendes Array mit Einträgen der Form {key,value} um |
|
861 |
+ * @author fenris |
|
862 |
+ */ |
|
863 |
+ function to_array(object) { |
|
864 |
+ var array = []; |
|
865 |
+ Object.keys(object).forEach(function (key) { return array.push({ "key": key, "value": object[key] }); }); |
|
866 |
+ return array; |
|
867 |
+ } |
|
868 |
+ lib_object.to_array = to_array; |
|
869 |
+ /** |
|
870 |
+ * @desc gibt eine Liste von Schlüsseln eines Objekts zurück |
|
871 |
+ * @author fenris |
|
872 |
+ */ |
|
873 |
+ function keys(object) { |
|
874 |
+ return Object.keys(object); |
|
875 |
+ } |
|
876 |
+ lib_object.keys = keys; |
|
877 |
+ /** |
|
878 |
+ * @desc gibt eine Liste von Werten eines Objekts zurück |
|
879 |
+ * @author fenris |
|
880 |
+ */ |
|
881 |
+ function values(object) { |
|
882 |
+ return to_array(object).map(function (entry) { return entry.value; }); |
|
883 |
+ } |
|
884 |
+ lib_object.values = values; |
|
885 |
+ /** |
|
886 |
+ * @desc liest ein Baum-artiges Objekt an einer bestimmten Stelle aus |
|
887 |
+ * @author fenris |
|
888 |
+ */ |
|
889 |
+ function path_read(object, path, fallback, escalation) { |
|
890 |
+ if (fallback === void 0) { fallback = null; } |
|
891 |
+ if (escalation === void 0) { escalation = 1; } |
|
892 |
+ var steps = ((path.length == 0) ? [] : path.split(".")); |
|
893 |
+ if (steps.length == 0) { |
|
894 |
+ throw (new Error("empty path")); |
|
895 |
+ } |
|
896 |
+ else { |
|
897 |
+ var position_1 = object; |
|
898 |
+ var reachable = (position_1 != null) && steps.slice(0, steps.length - 1).every(function (step) { |
|
899 |
+ position_1 = object_fetch(position_1, step, null, 0); |
|
900 |
+ return (position_1 != null); |
|
901 |
+ }); |
|
902 |
+ if (reachable) { |
|
903 |
+ return object_fetch(position_1, steps[steps.length - 1], fallback, escalation); |
|
904 |
+ } |
|
905 |
+ else { |
|
906 |
+ return object_fetch({}, "_dummy_", fallback, escalation); |
|
907 |
+ } |
|
908 |
+ } |
|
909 |
+ } |
|
910 |
+ lib_object.path_read = path_read; |
|
911 |
+ /** |
|
912 |
+ * @desc schreibt einen Wert an eine bestimmte Stelle in einem Baum-artigen Objekt |
|
913 |
+ * @author fenris |
|
914 |
+ */ |
|
915 |
+ function path_write(object, path, value, construct) { |
|
916 |
+ if (construct === void 0) { construct = true; } |
|
917 |
+ var steps = ((path.length == 0) ? [] : path.split(".")); |
|
918 |
+ if (steps.length == 0) { |
|
919 |
+ throw (new Error("empty path")); |
|
920 |
+ } |
|
921 |
+ else { |
|
922 |
+ var position_2 = object; |
|
923 |
+ var reachable = steps.slice(0, steps.length - 1).every(function (step) { |
|
924 |
+ var position_ = object_fetch(position_2, step, null, 0); |
|
925 |
+ if (position_ == null) { |
|
926 |
+ if (construct) { |
|
927 |
+ position_2[step] = {}; |
|
928 |
+ position_2 = position_2[step]; |
|
929 |
+ return true; |
|
930 |
+ } |
|
931 |
+ else { |
|
932 |
+ return false; |
|
933 |
+ } |
|
934 |
+ } |
|
935 |
+ else { |
|
936 |
+ position_2 = position_; |
|
937 |
+ return true; |
|
938 |
+ } |
|
939 |
+ }); |
|
940 |
+ if (reachable) { |
|
941 |
+ position_2[steps[steps.length - 1]] = value; |
|
942 |
+ } |
|
943 |
+ else { |
|
944 |
+ var message = ("path '" + path + "' does not exist and may not be constructed"); |
|
945 |
+ throw (new Error(message)); |
|
946 |
+ } |
|
947 |
+ } |
|
948 |
+ } |
|
949 |
+ lib_object.path_write = path_write; |
|
950 |
+ /** |
|
951 |
+ * @desc prüft ob ein Objekt einem bestimmten Muster entspricht |
|
952 |
+ * @param {Object} object das zu prüfende Objekt |
|
953 |
+ * @param {Object} pattern das einzuhaltende Muster |
|
954 |
+ * @param {Function} connlate eine Funktion zum Feststellen der Gleichheit von Einzelwerten |
|
955 |
+ * @author fenris |
|
956 |
+ */ |
|
957 |
+ function matches(object, pattern, collate) { |
|
958 |
+ if (collate === void 0) { collate = instance_collate; } |
|
959 |
+ return Object.keys(pattern).every(function (key) { return collate(pattern[key], object[key]); }); |
|
960 |
+ } |
|
961 |
+ lib_object.matches = matches; |
|
962 |
+ /** |
|
963 |
+ * @desc erzeugt eine Projektion eines Baum-artigen Objekts in ein Listen-artiges Objekt |
|
964 |
+ * @param {string} [separator] welches Zeichen als Trenner zwischen zwei Pfad-Schritten verwendet werden soll |
|
965 |
+ * @author fenris |
|
966 |
+ */ |
|
967 |
+ function flatten(value, separator, key_for_element) { |
|
968 |
+ if (separator === void 0) { separator = "."; } |
|
969 |
+ if (key_for_element === void 0) { key_for_element = (function (index) { return ("element_" + index.toFixed(0)); }); } |
|
970 |
+ var integrate = function (result, key_, value_) { |
|
971 |
+ if (value_ == null) { |
|
972 |
+ result[key_] = value_; |
|
973 |
+ } |
|
974 |
+ else { |
|
975 |
+ // primitive Werte direkt übernehmen |
|
976 |
+ if (typeof (value_) != "object") { |
|
977 |
+ result[key_] = value_; |
|
978 |
+ } |
|
979 |
+ // sonst durch rekursiven Aufruf die flache Variante des Wertes ermitteln und einarbeiten |
|
980 |
+ else { |
|
981 |
+ var result_1 = flatten(value_); |
|
982 |
+ Object.keys(result_1) |
|
983 |
+ .forEach(function (key__) { |
|
984 |
+ var value__ = result_1[key__]; |
|
985 |
+ var key_new = (key_ + separator + key__); |
|
986 |
+ result[key_new] = value__; |
|
987 |
+ }); |
|
988 |
+ } |
|
989 |
+ } |
|
990 |
+ }; |
|
991 |
+ if ((value === null) || (value === undefined)) { |
|
992 |
+ return null; |
|
993 |
+ } |
|
994 |
+ else { |
|
995 |
+ var result_2 = {}; |
|
996 |
+ if (typeof (value) != "object") { |
|
997 |
+ result_2["value"] = value; |
|
998 |
+ } |
|
999 |
+ else { |
|
1000 |
+ if (value instanceof Array) { |
|
1001 |
+ var array = (value); |
|
1002 |
+ array |
|
1003 |
+ .forEach(function (element, index) { |
|
1004 |
+ integrate(result_2, key_for_element(index), element); |
|
1005 |
+ }); |
|
1006 |
+ } |
|
1007 |
+ else { |
|
1008 |
+ var object_1 = (value); |
|
1009 |
+ Object.keys(object_1) |
|
1010 |
+ .forEach(function (key) { |
|
1011 |
+ integrate(result_2, key, object_1[key]); |
|
1012 |
+ }); |
|
1013 |
+ } |
|
1014 |
+ } |
|
1015 |
+ return result_2; |
|
1016 |
+ } |
|
1017 |
+ } |
|
1018 |
+ lib_object.flatten = flatten; |
|
1019 |
+ /** |
|
1020 |
+ * @author fenris |
|
1021 |
+ */ |
|
1022 |
+ function clash(x, y, _a) { |
|
1023 |
+ var _b = _a === void 0 ? {} : _a, _c = _b["overwrite"], overwrite = _c === void 0 ? true : _c, _d = _b["hooks"], _e = (_d === void 0 ? {} : _d)["existing"], hook_existing = _e === void 0 ? null : _e; |
|
1024 |
+ if (hook_existing == null) { |
|
1025 |
+ (function (key, value_old, value_new) { return console.warn("field " + key + " already defined"); }); |
|
1026 |
+ } |
|
1027 |
+ var z = {}; |
|
1028 |
+ Object.keys(x).forEach(function (key) { |
|
1029 |
+ z[key] = x[key]; |
|
1030 |
+ }); |
|
1031 |
+ Object.keys(y).forEach(function (key) { |
|
1032 |
+ if (key in z) { |
|
1033 |
+ if (hook_existing != null) { |
|
1034 |
+ hook_existing(key, z[key], y[key]); |
|
1035 |
+ } |
|
1036 |
+ if (overwrite) { |
|
1037 |
+ z[key] = y[key]; |
|
1038 |
+ } |
|
1039 |
+ } |
|
1040 |
+ else { |
|
1041 |
+ z[key] = y[key]; |
|
1042 |
+ } |
|
1043 |
+ }); |
|
1044 |
+ return z; |
|
1045 |
+ } |
|
1046 |
+ lib_object.clash = clash; |
|
1047 |
+ /** |
|
1048 |
+ * @author fenris |
|
1049 |
+ */ |
|
1050 |
+ function patch(core, mantle, deep, path) { |
|
1051 |
+ if (deep === void 0) { deep = true; } |
|
1052 |
+ if (path === void 0) { path = null; } |
|
1053 |
+ if (mantle == null) { |
|
1054 |
+ console.warn("mantle is null; core was", core); |
|
1055 |
+ } |
|
1056 |
+ else { |
|
1057 |
+ Object.keys(mantle).forEach(function (key) { |
|
1058 |
+ var path_ = ((path == null) ? key : path + "." + key); |
|
1059 |
+ var value_mantle = mantle[key]; |
|
1060 |
+ if (!(key in core)) { |
|
1061 |
+ if ((typeof (value_mantle) == "object") && (value_mantle != null) && deep) { |
|
1062 |
+ if (value_mantle instanceof Array) { |
|
1063 |
+ core[key] = []; |
|
1064 |
+ value_mantle.forEach(function (element) { |
|
1065 |
+ if ((typeof (element) == "object") && (element != null)) { |
|
1066 |
+ var element_ = {}; |
|
1067 |
+ patch(element_, element); |
|
1068 |
+ core[key].push(element_); |
|
1069 |
+ } |
|
1070 |
+ else { |
|
1071 |
+ core[key].push(element); |
|
1072 |
+ } |
|
1073 |
+ }); |
|
1074 |
+ } |
|
1075 |
+ else { |
|
1076 |
+ core[key] = {}; |
|
1077 |
+ patch(core[key], value_mantle, deep, path_); |
|
1078 |
+ } |
|
1079 |
+ } |
|
1080 |
+ else { |
|
1081 |
+ core[key] = value_mantle; |
|
1082 |
+ } |
|
1083 |
+ } |
|
1084 |
+ else { |
|
1085 |
+ var value_core = core[key]; |
|
1086 |
+ if (typeof (value_core) == typeof (value_mantle)) { |
|
1087 |
+ if ((typeof (value_mantle) == "object") && (value_mantle != null) && deep) { |
|
1088 |
+ patch(core[key], value_mantle, deep, path_); |
|
1089 |
+ } |
|
1090 |
+ else { |
|
1091 |
+ core[key] = value_mantle; |
|
1092 |
+ } |
|
1093 |
+ } |
|
1094 |
+ else { |
|
1095 |
+ if ((value_core != null) && (value_mantle != null)) { |
|
1096 |
+ var message = "objects have different shapes at path '" + path_ + "'; core has type '" + typeof (value_core) + "' and mantle has type '" + typeof (value_mantle) + "'"; |
|
1097 |
+ console.warn(message); |
|
1098 |
+ } |
|
1099 |
+ core[key] = value_mantle; |
|
1100 |
+ // throw (new Error(message)); |
|
1101 |
+ } |
|
1102 |
+ } |
|
1103 |
+ }); |
|
1104 |
+ } |
|
1105 |
+ } |
|
1106 |
+ lib_object.patch = patch; |
|
1107 |
+ /** |
|
1108 |
+ * @author fenris |
|
1109 |
+ */ |
|
1110 |
+ function patched(core, mantle, deep) { |
|
1111 |
+ if (deep === void 0) { deep = undefined; } |
|
1112 |
+ var result = {}; |
|
1113 |
+ patch(result, core, deep); |
|
1114 |
+ patch(result, mantle, deep); |
|
1115 |
+ return result; |
|
1116 |
+ } |
|
1117 |
+ lib_object.patched = patched; |
|
1118 |
+ /** |
|
1119 |
+ * @author fenris |
|
1120 |
+ */ |
|
1121 |
+ function attached(object, key, value) { |
|
1122 |
+ var mantle = {}; |
|
1123 |
+ mantle[key] = value; |
|
1124 |
+ return patched(object, mantle, false); |
|
1125 |
+ } |
|
1126 |
+ lib_object.attached = attached; |
|
1127 |
+ /** |
|
1128 |
+ * @author fenris |
|
1129 |
+ */ |
|
1130 |
+ function copy(object) { |
|
1131 |
+ return patched({}, object); |
|
1132 |
+ } |
|
1133 |
+ lib_object.copy = copy; |
|
1134 |
+})(lib_object || (lib_object = {})); |
|
1135 |
+/** |
|
1136 |
+ * @desc adapters for old syntax |
|
1137 |
+ * @author fenris |
|
1138 |
+ */ |
|
1139 |
+var object_fetch = lib_object.fetch; |
|
1140 |
+var object_map = lib_object.map; |
|
1141 |
+var object_a2o = lib_object.from_array; |
|
1142 |
+var object_o2a = lib_object.to_array; |
|
1143 |
+var object_matches = lib_object.matches; |
|
1144 |
+var object_clash = lib_object.clash; |
|
1145 |
+/* |
|
1146 |
+This file is part of »bacterio-plankton:shape«. |
|
1147 |
+ |
|
1148 |
+Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
1149 |
+<info@greenscale.de> |
|
1150 |
+ |
|
1151 |
+»bacterio-plankton:shape« is free software: you can redistribute it and/or modify |
|
1152 |
+it under the terms of the GNU Lesser General Public License as published by |
|
1153 |
+the Free Software Foundation, either version 3 of the License, or |
|
1154 |
+(at your option) any later version. |
|
1155 |
+ |
|
1156 |
+»bacterio-plankton:shape« is distributed in the hope that it will be useful, |
|
1157 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
1158 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
1159 |
+GNU Lesser General Public License for more details. |
|
1160 |
+ |
|
1161 |
+You should have received a copy of the GNU Lesser General Public License |
|
1162 |
+along with »bacterio-plankton:shape«. If not, see <http://www.gnu.org/licenses/>. |
|
1163 |
+ */ |
|
1164 |
+var lib_shape; |
|
1165 |
+(function (lib_shape) { |
|
1166 |
+ /** |
|
1167 |
+ * @author fenris |
|
1168 |
+ */ |
|
1169 |
+ var _pool = {}; |
|
1170 |
+ /** |
|
1171 |
+ * @author fenris |
|
1172 |
+ */ |
|
1173 |
+ var _aliases = {}; |
|
1174 |
+ /** |
|
1175 |
+ * @author fenris |
|
1176 |
+ */ |
|
1177 |
+ function list() { |
|
1178 |
+ return [].concat(Object.keys(_pool)).concat(Object.keys(_aliases)); |
|
1179 |
+ } |
|
1180 |
+ lib_shape.list = list; |
|
1181 |
+ /** |
|
1182 |
+ * @author fenris |
|
1183 |
+ */ |
|
1184 |
+ function inspection_create() { |
|
1185 |
+ return { |
|
1186 |
+ "messages": [] |
|
1187 |
+ }; |
|
1188 |
+ } |
|
1189 |
+ lib_shape.inspection_create = inspection_create; |
|
1190 |
+ /** |
|
1191 |
+ * @author fenris |
|
1192 |
+ */ |
|
1193 |
+ function inspection_add(main, message) { |
|
1194 |
+ main.messages.push(message); |
|
1195 |
+ } |
|
1196 |
+ lib_shape.inspection_add = inspection_add; |
|
1197 |
+ /** |
|
1198 |
+ * @author fenris |
|
1199 |
+ */ |
|
1200 |
+ function inspection_extend(main, prefix, sub) { |
|
1201 |
+ main.messages = main.messages.concat(sub.messages.map(message => `${prefix}: ${message}`)); |
|
1202 |
+ } |
|
1203 |
+ lib_shape.inspection_extend = inspection_extend; |
|
1204 |
+ /** |
|
1205 |
+ * @author fenris |
|
1206 |
+ * @todo check for existing |
|
1207 |
+ */ |
|
1208 |
+ function register({ "name": name, "make": make, "inspect": _inspect, "stance": _stance, "show": _show, }) { |
|
1209 |
+ const entry = { |
|
1210 |
+ "name": name, |
|
1211 |
+ "make": make, |
|
1212 |
+ "inspect": _inspect, |
|
1213 |
+ "stance": _stance, |
|
1214 |
+ "show": _show, |
|
1215 |
+ }; |
|
1216 |
+ _pool[name] = entry; |
|
1217 |
+ } |
|
1218 |
+ lib_shape.register = register; |
|
1219 |
+ /** |
|
1220 |
+ * @author fenris |
|
1221 |
+ * @todo check for existing |
|
1222 |
+ */ |
|
1223 |
+ function define_alias({ "name": name, "target": target, }) { |
|
1224 |
+ const entry = { |
|
1225 |
+ "name": "alias", |
|
1226 |
+ "target": target, |
|
1227 |
+ }; |
|
1228 |
+ _aliases[name] = entry; |
|
1229 |
+ } |
|
1230 |
+ lib_shape.define_alias = define_alias; |
|
1231 |
+ /** |
|
1232 |
+ * @author fenris |
|
1233 |
+ * @todo check for existing |
|
1234 |
+ */ |
|
1235 |
+ /* |
|
1236 |
+ export function inspect_jstype( |
|
1237 |
+ inspection, |
|
1238 |
+ jstype_expected : string, |
|
1239 |
+ value : any |
|
1240 |
+ ) : void { |
|
1241 |
+ let jstype_actual : string = typeof(value); |
|
1242 |
+ if (jstype_actual === jstype_expected) { |
|
1243 |
+ // all good |
|
1244 |
+ } |
|
1245 |
+ else { |
|
1246 |
+ inspection_add(inspection, `expected JS-type '${jstype_expected}' but got '${jstype_actual}'`); |
|
1247 |
+ } |
|
1248 |
+ } |
|
1249 |
+ */ |
|
1250 |
+ /** |
|
1251 |
+ * @author fenris |
|
1252 |
+ */ |
|
1253 |
+ function make(raw) { |
|
1254 |
+ const name = raw["name"]; |
|
1255 |
+ if (_aliases.hasOwnProperty(name)) { |
|
1256 |
+ const alias = _aliases[name]; |
|
1257 |
+ return alias.target; |
|
1258 |
+ } |
|
1259 |
+ else { |
|
1260 |
+ if (_pool.hasOwnProperty(name)) { |
|
1261 |
+ const entry = _pool[name]; |
|
1262 |
+ const parameters = entry.make(raw["parameters"] || {}, make); |
|
1263 |
+ return { |
|
1264 |
+ "name": name, |
|
1265 |
+ "parameters": parameters, |
|
1266 |
+ }; |
|
1267 |
+ } |
|
1268 |
+ else { |
|
1269 |
+ const message = `no shape registered with name '${name}'`; |
|
1270 |
+ throw (new Error(message)); |
|
1271 |
+ } |
|
1272 |
+ } |
|
1273 |
+ } |
|
1274 |
+ lib_shape.make = make; |
|
1275 |
+ /** |
|
1276 |
+ * @author fenris |
|
1277 |
+ */ |
|
1278 |
+ function inspect(shape, value) { |
|
1279 |
+ if (_pool.hasOwnProperty(shape.name)) { |
|
1280 |
+ const entry = _pool[shape.name]; |
|
1281 |
+ return entry.inspect(shape.parameters, value, inspect); |
|
1282 |
+ } |
|
1283 |
+ else { |
|
1284 |
+ const message = `no shape registered with name '${shape.name}'`; |
|
1285 |
+ throw (new Error(message)); |
|
1286 |
+ } |
|
1287 |
+ } |
|
1288 |
+ lib_shape.inspect = inspect; |
|
1289 |
+ /** |
|
1290 |
+ * @author fenris |
|
1291 |
+ */ |
|
1292 |
+ function check(shape, value) { |
|
1293 |
+ if (_pool.hasOwnProperty(shape.name)) { |
|
1294 |
+ const entry = _pool[shape.name]; |
|
1295 |
+ const inspection = inspect(shape, value); |
|
1296 |
+ inspection.messages |
|
1297 |
+ .forEach((message) => { console.warn(message); }); |
|
1298 |
+ return (inspection.messages.length === 0); |
|
1299 |
+ } |
|
1300 |
+ else { |
|
1301 |
+ const message = `no shape registered with name '${shape.name}'`; |
|
1302 |
+ throw (new Error(message)); |
|
1303 |
+ } |
|
1304 |
+ } |
|
1305 |
+ lib_shape.check = check; |
|
1306 |
+ /** |
|
1307 |
+ * @author fenris |
|
1308 |
+ */ |
|
1309 |
+ function stance(shape, bindings) { |
|
1310 |
+ if (_pool.hasOwnProperty(shape.name)) { |
|
1311 |
+ const entry = _pool[shape.name]; |
|
1312 |
+ return entry.stance(shape.parameters, bindings, stance); |
|
1313 |
+ } |
|
1314 |
+ else { |
|
1315 |
+ const message = `no shape registered with name '${shape.name}'`; |
|
1316 |
+ throw (new Error(message)); |
|
1317 |
+ } |
|
1318 |
+ } |
|
1319 |
+ lib_shape.stance = stance; |
|
1320 |
+ /** |
|
1321 |
+ * @author fenris |
|
1322 |
+ */ |
|
1323 |
+ function show(shape) { |
|
1324 |
+ if (_pool.hasOwnProperty(shape.name)) { |
|
1325 |
+ const entry = _pool[shape.name]; |
|
1326 |
+ return entry.show(shape.parameters, show); |
|
1327 |
+ } |
|
1328 |
+ else { |
|
1329 |
+ const message = `no shape registered with name '${shape.name}'`; |
|
1330 |
+ throw (new Error(message)); |
|
1331 |
+ } |
|
1332 |
+ } |
|
1333 |
+ lib_shape.show = show; |
|
1334 |
+})(lib_shape || (lib_shape = {})); |
|
1335 |
+/* |
|
1336 |
+This file is part of »bacterio-plankton:shape«. |
|
1337 |
+ |
|
1338 |
+Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
1339 |
+<info@greenscale.de> |
|
1340 |
+ |
|
1341 |
+»bacterio-plankton:shape« is free software: you can redistribute it and/or modify |
|
1342 |
+it under the terms of the GNU Lesser General Public License as published by |
|
1343 |
+the Free Software Foundation, either version 3 of the License, or |
|
1344 |
+(at your option) any later version. |
|
1345 |
+ |
|
1346 |
+»bacterio-plankton:shape« is distributed in the hope that it will be useful, |
|
1347 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
1348 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
1349 |
+GNU Lesser General Public License for more details. |
|
1350 |
+ |
|
1351 |
+You should have received a copy of the GNU Lesser General Public License |
|
1352 |
+along with »bacterio-plankton:shape«. If not, see <http://www.gnu.org/licenses/>. |
|
1353 |
+ */ |
|
1354 |
+var lib_shape; |
|
1355 |
+(function (lib_shape) { |
|
1356 |
+ /** |
|
1357 |
+ * @author fenris |
|
1358 |
+ */ |
|
1359 |
+ function variable_make({ "name": name }) { |
|
1360 |
+ if (name == undefined) { |
|
1361 |
+ let message = `mandatory parameter 'name' missing`; |
|
1362 |
+ throw (new Error(message)); |
|
1363 |
+ } |
|
1364 |
+ else { |
|
1365 |
+ return { |
|
1366 |
+ "name": name, |
|
1367 |
+ }; |
|
1368 |
+ } |
|
1369 |
+ } |
|
1370 |
+ /** |
|
1371 |
+ * @author fenris |
|
1372 |
+ */ |
|
1373 |
+ function variable_inspect(parameters, value, _inspect) { |
|
1374 |
+ let inspection = lib_shape.inspection_create(); |
|
1375 |
+ let message = "cannot inspect a value against a type variable"; |
|
1376 |
+ console.warn(message + "; will just pass ..."); |
|
1377 |
+ // throw (new Error(message)); |
|
1378 |
+ return inspection; |
|
1379 |
+ } |
|
1380 |
+ /** |
|
1381 |
+ * @author fenris |
|
1382 |
+ */ |
|
1383 |
+ function variable_stance(parameters, bindings, _stance) { |
|
1384 |
+ if (parameters.name in bindings) { |
|
1385 |
+ return bindings[parameters.name]; |
|
1386 |
+ } |
|
1387 |
+ else { |
|
1388 |
+ return { |
|
1389 |
+ "name": "variable", |
|
1390 |
+ "parameters": parameters |
|
1391 |
+ }; |
|
1392 |
+ } |
|
1393 |
+ } |
|
1394 |
+ /** |
|
1395 |
+ * @author fenris |
|
1396 |
+ */ |
|
1397 |
+ function variable_show(parameters, _show) { |
|
1398 |
+ let str; |
|
1399 |
+ // core |
|
1400 |
+ { |
|
1401 |
+ str = ("$" + parameters.name); |
|
1402 |
+ } |
|
1403 |
+ return str; |
|
1404 |
+ } |
|
1405 |
+ /** |
|
1406 |
+ * @author fenris |
|
1407 |
+ */ |
|
1408 |
+ lib_shape.register({ |
|
1409 |
+ "name": "variable", |
|
1410 |
+ "make": variable_make, |
|
1411 |
+ "inspect": variable_inspect, |
|
1412 |
+ "stance": variable_stance, |
|
1413 |
+ "show": variable_show, |
|
1414 |
+ }); |
|
1415 |
+})(lib_shape || (lib_shape = {})); |
|
1416 |
+/* |
|
1417 |
+This file is part of »bacterio-plankton:shape«. |
|
1418 |
+ |
|
1419 |
+Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
1420 |
+<info@greenscale.de> |
|
1421 |
+ |
|
1422 |
+»bacterio-plankton:shape« is free software: you can redistribute it and/or modify |
|
1423 |
+it under the terms of the GNU Lesser General Public License as published by |
|
1424 |
+the Free Software Foundation, either version 3 of the License, or |
|
1425 |
+(at your option) any later version. |
|
1426 |
+ |
|
1427 |
+»bacterio-plankton:shape« is distributed in the hope that it will be useful, |
|
1428 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
1429 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
1430 |
+GNU Lesser General Public License for more details. |
|
1431 |
+ |
|
1432 |
+You should have received a copy of the GNU Lesser General Public License |
|
1433 |
+along with »bacterio-plankton:shape«. If not, see <http://www.gnu.org/licenses/>. |
|
1434 |
+ */ |
|
1435 |
+var lib_shape; |
|
1436 |
+(function (lib_shape) { |
|
1437 |
+ /** |
|
1438 |
+ * @author fenris |
|
1439 |
+ */ |
|
1440 |
+ function function_make({ "soft": soft = false, "shape_input": shape_input, "shape_output": shape_output, "defaultvalue": defaultvalue = undefined, }, _make) { |
|
1441 |
+ if (shape_input === undefined) { |
|
1442 |
+ let message = `mandatory parameter 'shape_input' missing`; |
|
1443 |
+ throw (new Error(message)); |
|
1444 |
+ } |
|
1445 |
+ if (shape_output === undefined) { |
|
1446 |
+ let message = `mandatory parameter 'shape_output' missing`; |
|
1447 |
+ throw (new Error(message)); |
|
1448 |
+ } |
|
1449 |
+ if (defaultvalue === undefined) { |
|
1450 |
+ defaultvalue = (soft ? null : (x => x)); |
|
1451 |
+ } |
|
1452 |
+ return { |
|
1453 |
+ "soft": soft, |
|
1454 |
+ "shape_input": _make(shape_input), |
|
1455 |
+ "shape_output": _make(shape_output), |
|
1456 |
+ "defaultvalue": defaultvalue, |
|
1457 |
+ }; |
|
1458 |
+ } |
|
1459 |
+ /** |
|
1460 |
+ * @author fenris |
|
1461 |
+ */ |
|
1462 |
+ function function_stance(parameters, bindings, _stance) { |
|
1463 |
+ return { |
|
1464 |
+ "name": "function", |
|
1465 |
+ "parameters": { |
|
1466 |
+ "soft": parameters.soft, |
|
1467 |
+ "shape_input": _stance(parameters.shape_input, bindings), |
|
1468 |
+ "shape_output": _stance(parameters.shape_output, bindings) |
|
1469 |
+ } |
|
1470 |
+ }; |
|
1471 |
+ } |
|
1472 |
+ /** |
|
1473 |
+ * @author fenris |
|
1474 |
+ * @todo closer look not possible? |
|
1475 |
+ */ |
|
1476 |
+ function function_inspect(parameters, value, _inspect) { |
|
1477 |
+ let inspection = lib_shape.inspection_create(); |
|
1478 |
+ if (value == undefined) { |
|
1479 |
+ if (parameters.soft) { |
|
1480 |
+ // all good |
|
1481 |
+ } |
|
1482 |
+ else { |
|
1483 |
+ lib_shape.inspection_add(inspection, "null is not allowed"); |
|
1484 |
+ } |
|
1485 |
+ } |
|
1486 |
+ else { |
|
1487 |
+ let jstype_actual = typeof (value); |
|
1488 |
+ let jstype_expected = "function"; |
|
1489 |
+ if (jstype_actual === jstype_expected) { |
|
1490 |
+ // all good? |
|
1491 |
+ } |
|
1492 |
+ else { |
|
1493 |
+ lib_shape.inspection_add(inspection, `expected JS-type '${jstype_expected}' but got '${jstype_actual}'`); |
|
1494 |
+ } |
|
1495 |
+ } |
|
1496 |
+ return inspection; |
|
1497 |
+ } |
|
1498 |
+ /** |
|
1499 |
+ * @author fenris |
|
1500 |
+ */ |
|
1501 |
+ function function_show(parameters, _show) { |
|
1502 |
+ let str; |
|
1503 |
+ /* |
|
1504 |
+ // core |
|
1505 |
+ { |
|
1506 |
+ str = "function"; |
|
1507 |
+ } |
|
1508 |
+ // in/out |
|
1509 |
+ { |
|
1510 |
+ str += ( |
|
1511 |
+ "<" |
|
1512 |
+ + |
|
1513 |
+ [ |
|
1514 |
+ _show(parameters.shape_input), |
|
1515 |
+ _show(parameters.shape_output), |
|
1516 |
+ ].join(",") |
|
1517 |
+ + |
|
1518 |
+ ">" |
|
1519 |
+ ); |
|
1520 |
+ } |
|
1521 |
+ */ |
|
1522 |
+ str = ""; |
|
1523 |
+ str += ("(" + _show(parameters.shape_input) + " => " + _show(parameters.shape_output) + ")"); |
|
1524 |
+ // soft |
|
1525 |
+ { |
|
1526 |
+ if (parameters.soft) { |
|
1527 |
+ str = `~${str}`; |
|
1528 |
+ } |
|
1529 |
+ } |
|
1530 |
+ return str; |
|
1531 |
+ } |
|
1532 |
+ /** |
|
1533 |
+ * @author fenris |
|
1534 |
+ */ |
|
1535 |
+ lib_shape.register({ |
|
1536 |
+ "name": "function", |
|
1537 |
+ "make": function_make, |
|
1538 |
+ "inspect": function_inspect, |
|
1539 |
+ "stance": function_stance, |
|
1540 |
+ "show": function_show, |
|
1541 |
+ }); |
|
1542 |
+})(lib_shape || (lib_shape = {})); |
|
1543 |
+/* |
|
1544 |
+This file is part of »bacterio-plankton:shape«. |
|
1545 |
+ |
|
1546 |
+Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
1547 |
+<info@greenscale.de> |
|
1548 |
+ |
|
1549 |
+»bacterio-plankton:shape« is free software: you can redistribute it and/or modify |
|
1550 |
+it under the terms of the GNU Lesser General Public License as published by |
|
1551 |
+the Free Software Foundation, either version 3 of the License, or |
|
1552 |
+(at your option) any later version. |
|
1553 |
+ |
|
1554 |
+»bacterio-plankton:shape« is distributed in the hope that it will be useful, |
|
1555 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
1556 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
1557 |
+GNU Lesser General Public License for more details. |
|
1558 |
+ |
|
1559 |
+You should have received a copy of the GNU Lesser General Public License |
|
1560 |
+along with »bacterio-plankton:shape«. If not, see <http://www.gnu.org/licenses/>. |
|
1561 |
+ */ |
|
1562 |
+var lib_shape; |
|
1563 |
+(function (lib_shape) { |
|
1564 |
+ /** |
|
1565 |
+ * @author fenris |
|
1566 |
+ */ |
|
1567 |
+ function void_make({ "soft": soft = true, }) { |
|
1568 |
+ return { |
|
1569 |
+ "soft": soft, |
|
1570 |
+ }; |
|
1571 |
+ } |
|
1572 |
+ /** |
|
1573 |
+ * @author fenris |
|
1574 |
+ */ |
|
1575 |
+ function void_inspect(parameters, value, _inspect) { |
|
1576 |
+ let inspection = lib_shape.inspection_create(); |
|
1577 |
+ if (value == undefined) { |
|
1578 |
+ if (parameters.soft) { |
|
1579 |
+ // all good |
|
1580 |
+ } |
|
1581 |
+ else { |
|
1582 |
+ lib_shape.inspection_add(inspection, "null is not allowed"); |
|
1583 |
+ } |
|
1584 |
+ } |
|
1585 |
+ else { |
|
1586 |
+ // all good |
|
1587 |
+ } |
|
1588 |
+ return inspection; |
|
1589 |
+ } |
|
1590 |
+ /** |
|
1591 |
+ * @author fenris |
|
1592 |
+ */ |
|
1593 |
+ function void_stance(parameters, bindings, _stance) { |
|
1594 |
+ return { |
|
1595 |
+ "name": "void", |
|
1596 |
+ "parameters": parameters |
|
1597 |
+ }; |
|
1598 |
+ } |
|
1599 |
+ /** |
|
1600 |
+ * @author fenris |
|
1601 |
+ */ |
|
1602 |
+ function void_show(parameters, _show) { |
|
1603 |
+ let str; |
|
1604 |
+ // core |
|
1605 |
+ { |
|
1606 |
+ str = "void"; |
|
1607 |
+ } |
|
1608 |
+ // soft |
|
1609 |
+ { |
|
1610 |
+ if (parameters.soft) { |
|
1611 |
+ str = `~${str}`; |
|
1612 |
+ } |
|
1613 |
+ } |
|
1614 |
+ return str; |
|
1615 |
+ } |
|
1616 |
+ /** |
|
1617 |
+ * @author fenris |
|
1618 |
+ */ |
|
1619 |
+ lib_shape.register({ |
|
1620 |
+ "name": "void", |
|
1621 |
+ "make": void_make, |
|
1622 |
+ "inspect": void_inspect, |
|
1623 |
+ "stance": void_stance, |
|
1624 |
+ "show": void_show, |
|
1625 |
+ }); |
|
1626 |
+})(lib_shape || (lib_shape = {})); |
|
1627 |
+/* |
|
1628 |
+This file is part of »bacterio-plankton:shape«. |
|
1629 |
+ |
|
1630 |
+Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
1631 |
+<info@greenscale.de> |
|
1632 |
+ |
|
1633 |
+»bacterio-plankton:shape« is free software: you can redistribute it and/or modify |
|
1634 |
+it under the terms of the GNU Lesser General Public License as published by |
|
1635 |
+the Free Software Foundation, either version 3 of the License, or |
|
1636 |
+(at your option) any later version. |
|
1637 |
+ |
|
1638 |
+»bacterio-plankton:shape« is distributed in the hope that it will be useful, |
|
1639 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
1640 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
1641 |
+GNU Lesser General Public License for more details. |
|
1642 |
+ |
|
1643 |
+You should have received a copy of the GNU Lesser General Public License |
|
1644 |
+along with »bacterio-plankton:shape«. If not, see <http://www.gnu.org/licenses/>. |
|
1645 |
+ */ |
|
1646 |
+var lib_shape; |
|
1647 |
+(function (lib_shape) { |
|
1648 |
+ /** |
|
1649 |
+ * @author fenris |
|
1650 |
+ */ |
|
1651 |
+ function any_make({ "soft": soft = true, "mutable": mutable = true, "defaultvalue": defaultvalue = null, }) { |
|
1652 |
+ return { |
|
1653 |
+ "soft": soft, |
|
1654 |
+ "mutable": mutable, |
|
1655 |
+ "defaultvalue": defaultvalue, |
|
1656 |
+ }; |
|
1657 |
+ } |
|
1658 |
+ /** |
|
1659 |
+ * @author fenris |
|
1660 |
+ */ |
|
1661 |
+ function any_inspect(parameters, value, _inspect) { |
|
1662 |
+ let inspection = lib_shape.inspection_create(); |
|
1663 |
+ if (value == undefined) { |
|
1664 |
+ if (parameters.soft) { |
|
1665 |
+ // all good |
|
1666 |
+ } |
|
1667 |
+ else { |
|
1668 |
+ lib_shape.inspection_add(inspection, "null is not allowed"); |
|
1669 |
+ } |
|
1670 |
+ } |
|
1671 |
+ else { |
|
1672 |
+ // all good |
|
1673 |
+ } |
|
1674 |
+ return inspection; |
|
1675 |
+ } |
|
1676 |
+ /** |
|
1677 |
+ * @author fenris |
|
1678 |
+ */ |
|
1679 |
+ function any_stance(parameters, bindings, _stance) { |
|
1680 |
+ return { |
|
1681 |
+ "name": "any", |
|
1682 |
+ "parameters": parameters |
|
1683 |
+ }; |
|
1684 |
+ } |
|
1685 |
+ /** |
|
1686 |
+ * @author fenris |
|
1687 |
+ */ |
|
1688 |
+ function any_show(parameters, _show) { |
|
1689 |
+ let str; |
|
1690 |
+ // core |
|
1691 |
+ { |
|
1692 |
+ str = "any"; |
|
1693 |
+ } |
|
1694 |
+ // soft |
|
1695 |
+ { |
|
1696 |
+ if (parameters.soft) { |
|
1697 |
+ str = `~${str}`; |
|
1698 |
+ } |
|
1699 |
+ } |
|
1700 |
+ return str; |
|
1701 |
+ } |
|
1702 |
+ /** |
|
1703 |
+ * @author fenris |
|
1704 |
+ */ |
|
1705 |
+ lib_shape.register({ |
|
1706 |
+ "name": "any", |
|
1707 |
+ "make": any_make, |
|
1708 |
+ "inspect": any_inspect, |
|
1709 |
+ "stance": any_stance, |
|
1710 |
+ "show": any_show, |
|
1711 |
+ }); |
|
1712 |
+})(lib_shape || (lib_shape = {})); |
|
1713 |
+/* |
|
1714 |
+This file is part of »bacterio-plankton:shape«. |
|
1715 |
+ |
|
1716 |
+Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
1717 |
+<info@greenscale.de> |
|
1718 |
+ |
|
1719 |
+»bacterio-plankton:shape« is free software: you can redistribute it and/or modify |
|
1720 |
+it under the terms of the GNU Lesser General Public License as published by |
|
1721 |
+the Free Software Foundation, either version 3 of the License, or |
|
1722 |
+(at your option) any later version. |
|
1723 |
+ |
|
1724 |
+»bacterio-plankton:shape« is distributed in the hope that it will be useful, |
|
1725 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
1726 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
1727 |
+GNU Lesser General Public License for more details. |
|
1728 |
+ |
|
1729 |
+You should have received a copy of the GNU Lesser General Public License |
|
1730 |
+along with »bacterio-plankton:shape«. If not, see <http://www.gnu.org/licenses/>. |
|
1731 |
+ */ |
|
1732 |
+var lib_shape; |
|
1733 |
+(function (lib_shape) { |
|
1734 |
+ /** |
|
1735 |
+ * @author fenris |
|
1736 |
+ */ |
|
1737 |
+ function boolean_make({ "soft": soft = false, "mutable": mutable = true, "defaultvalue": defaultvalue = undefined, }) { |
|
1738 |
+ if (defaultvalue === undefined) { |
|
1739 |
+ defaultvalue = (soft ? null : false); |
|
1740 |
+ } |
|
1741 |
+ return { |
|
1742 |
+ "soft": soft, |
|
1743 |
+ "mutable": mutable, |
|
1744 |
+ "defaultvalue": defaultvalue, |
|
1745 |
+ }; |
|
1746 |
+ } |
|
1747 |
+ /** |
|
1748 |
+ * @author fenris |
|
1749 |
+ */ |
|
1750 |
+ function boolean_inspect(parameters, value, _inspect) { |
|
1751 |
+ let inspection = lib_shape.inspection_create(); |
|
1752 |
+ if (value == undefined) { |
|
1753 |
+ if (parameters.soft) { |
|
1754 |
+ // all good |
|
1755 |
+ } |
|
1756 |
+ else { |
|
1757 |
+ lib_shape.inspection_add(inspection, "null is not allowed"); |
|
1758 |
+ } |
|
1759 |
+ } |
|
1760 |
+ else { |
|
1761 |
+ let jstype_actual = typeof (value); |
|
1762 |
+ let jstype_expected = "boolean"; |
|
1763 |
+ if (jstype_actual === jstype_expected) { |
|
1764 |
+ // all good |
|
1765 |
+ } |
|
1766 |
+ else { |
|
1767 |
+ lib_shape.inspection_add(inspection, `expected JS-type '${jstype_expected}' but got '${jstype_actual}'`); |
|
1768 |
+ } |
|
1769 |
+ } |
|
1770 |
+ return inspection; |
|
1771 |
+ } |
|
1772 |
+ /** |
|
1773 |
+ * @author fenris |
|
1774 |
+ */ |
|
1775 |
+ function boolean_stance(parameters, bindings, _stance) { |
|
1776 |
+ return { |
|
1777 |
+ "name": "boolean", |
|
1778 |
+ "parameters": parameters |
|
1779 |
+ }; |
|
1780 |
+ } |
|
1781 |
+ /** |
|
1782 |
+ * @author fenris |
|
1783 |
+ */ |
|
1784 |
+ function boolean_show(parameters, _show) { |
|
1785 |
+ let str; |
|
1786 |
+ // core |
|
1787 |
+ { |
|
1788 |
+ str = "boolean"; |
|
1789 |
+ } |
|
1790 |
+ // soft |
|
1791 |
+ { |
|
1792 |
+ if (parameters.soft) { |
|
1793 |
+ str = `~${str}`; |
|
1794 |
+ } |
|
1795 |
+ } |
|
1796 |
+ return str; |
|
1797 |
+ } |
|
1798 |
+ /** |
|
1799 |
+ * @author fenris |
|
1800 |
+ */ |
|
1801 |
+ lib_shape.register({ |
|
1802 |
+ "name": "boolean", |
|
1803 |
+ "make": boolean_make, |
|
1804 |
+ "inspect": boolean_inspect, |
|
1805 |
+ "stance": boolean_stance, |
|
1806 |
+ "show": boolean_show, |
|
1807 |
+ }); |
|
1808 |
+})(lib_shape || (lib_shape = {})); |
|
1809 |
+/* |
|
1810 |
+This file is part of »bacterio-plankton:shape«. |
|
1811 |
+ |
|
1812 |
+Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' |
|
1813 |
+<info@greenscale.de> |
|
1814 |
+ |
|
1815 |
+»bacterio-plankton:shape« is free software: you can redistribute it and/or modify |
|
1816 |
+it under the terms of the GNU Lesser General Public License as published by |
|
1817 |
+the Free Software Foundation, either version 3 of the License, or |
|
1818 |
+(at your option) any later version. |
|
1819 |
+ |
|
1820 |
+»bacterio-plankton:shape« is distributed in the hope that it will be useful, |
|