565e59b15de1b2a7cd53e52e63c9d8acd2f84281
Christian Fraß [add] client

Christian Fraß authored 3 years ago

1) /*
2) This file is part of »bacterio-plankton:code«.
3) 
Christian Fraß [upd] client:lib:plankton

Christian Fraß authored 3 years ago

4) Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
Christian Fraß [add] client

Christian Fraß authored 3 years ago

5) <info@greenscale.de>
6) 
7) »bacterio-plankton:code« is free software: you can redistribute it and/or modify
8) it under the terms of the GNU Lesser General Public License as published by
9) the Free Software Foundation, either version 3 of the License, or
10) (at your option) any later version.
11) 
12) »bacterio-plankton:code« is distributed in the hope that it will be useful,
13) but WITHOUT ANY WARRANTY; without even the implied warranty of
14) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15) GNU Lesser General Public License for more details.
16) 
17) You should have received a copy of the GNU Lesser General Public License
18) along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>.
19)  */
20) /*
21) This file is part of »bacterio-plankton:code«.
22) 
Christian Fraß [upd] client:lib:plankton

Christian Fraß authored 3 years ago

23) Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
Christian Fraß [add] client

Christian Fraß authored 3 years ago

24) <info@greenscale.de>
25) 
26) »bacterio-plankton:code« is free software: you can redistribute it and/or modify
27) it under the terms of the GNU Lesser General Public License as published by
28) the Free Software Foundation, either version 3 of the License, or
29) (at your option) any later version.
30) 
31) »bacterio-plankton:code« is distributed in the hope that it will be useful,
32) but WITHOUT ANY WARRANTY; without even the implied warranty of
33) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34) GNU Lesser General Public License for more details.
35) 
36) You should have received a copy of the GNU Lesser General Public License
37) along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>.
38)  */
39) var lib_code;
40) (function (lib_code) {
41)     /**
42)      * @author fenris
43)      */
44)     lib_trait.define("code", {
45)         "from": null,
46)         "to": null
47)     }, {
48)         "encode": {
49)             "shape": {
50)                 "name": "function",
51)                 "parameters": {
52)                     "shape_input": {
53)                         "name": "variable",
54)                         "parameters": {
55)                             "name": "from"
56)                         }
57)                     },
58)                     "shape_output": {
59)                         "name": "variable",
60)                         "parameters": {
61)                             "name": "to"
62)                         }
63)                     }
64)                 }
65)             }
66)         },
67)         "decode": {
68)             "shape": {
69)                 "name": "function",
70)                 "parameters": {
71)                     "shape_input": {
72)                         "name": "variable",
73)                         "parameters": {
74)                             "name": "to"
75)                         }
76)                     },
77)                     "shape_output": {
78)                         "name": "variable",
79)                         "parameters": {
80)                             "name": "from"
81)                         }
82)                     }
83)                 }
84)             }
85)         }
86)     });
87) })(lib_code || (lib_code = {}));
88) /*
89) This file is part of »bacterio-plankton:code«.
90) 
Christian Fraß [upd] client:lib:plankton

Christian Fraß authored 3 years ago

91) Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
Christian Fraß [add] client

Christian Fraß authored 3 years ago

92) <info@greenscale.de>
93) 
94) »bacterio-plankton:code« is free software: you can redistribute it and/or modify
95) it under the terms of the GNU Lesser General Public License as published by
96) the Free Software Foundation, either version 3 of the License, or
97) (at your option) any later version.
98) 
99) »bacterio-plankton:code« is distributed in the hope that it will be useful,
100) but WITHOUT ANY WARRANTY; without even the implied warranty of
101) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
102) GNU Lesser General Public License for more details.
103) 
104) You should have received a copy of the GNU Lesser General Public License
105) along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>.
106)  */
107) var lib_code;
108) (function (lib_code) {
109)     /**
110)      * @author Christian Fraß <frass@greenscale.de>
111)      */
112)     function custom_encode(function_, from) {
113)         return function_(from);
114)     }
115)     lib_code.custom_encode = custom_encode;
116)     /**
117)      * @author Christian Fraß <frass@greenscale.de>
118)      */
119)     function custom_decode(function_, to) {
120)         return function_(to);
121)     }
122)     lib_code.custom_decode = custom_decode;
123) })(lib_code || (lib_code = {}));
124) /*
125) This file is part of »bacterio-plankton:code«.
126) 
Christian Fraß [upd] client:lib:plankton

Christian Fraß authored 3 years ago

127) Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
Christian Fraß [add] client

Christian Fraß authored 3 years ago

128) <info@greenscale.de>
129) 
130) »bacterio-plankton:code« is free software: you can redistribute it and/or modify
131) it under the terms of the GNU Lesser General Public License as published by
132) the Free Software Foundation, either version 3 of the License, or
133) (at your option) any later version.
134) 
135) »bacterio-plankton:code« is distributed in the hope that it will be useful,
136) but WITHOUT ANY WARRANTY; without even the implied warranty of
137) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
138) GNU Lesser General Public License for more details.
139) 
140) You should have received a copy of the GNU Lesser General Public License
141) along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>.
142)  */
143) var lib_code;
144) (function (lib_code) {
145)     /**
146)      * @author fenris
147)      */
148)     class class_code_custom {
149)         /**
150)          * @author fenris
151)          */
152)         constructor(encodefunc, decodefunc) {
153)             this.encodefunc = encodefunc;
154)             this.decodefunc = decodefunc;
155)         }
156)         /**
157)          * @implementation
158)          * @author fenris
159)          */
160)         encode(x) {
161)             return lib_code.custom_encode(this.encodefunc, x);
162)         }
163)         /**
164)          * @implementation
165)          * @author fenris
166)          */
167)         decode(x) {
168)             return lib_code.custom_decode(this.decodefunc, x);
169)         }
170)     }
171)     lib_code.class_code_custom = class_code_custom;
172) })(lib_code || (lib_code = {}));
173) /*
174) This file is part of »bacterio-plankton:code«.
175) 
Christian Fraß [upd] client:lib:plankton

Christian Fraß authored 3 years ago

176) Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
Christian Fraß [add] client

Christian Fraß authored 3 years ago

177) <info@greenscale.de>
178) 
179) »bacterio-plankton:code« is free software: you can redistribute it and/or modify
180) it under the terms of the GNU Lesser General Public License as published by
181) the Free Software Foundation, either version 3 of the License, or
182) (at your option) any later version.
183) 
184) »bacterio-plankton:code« is distributed in the hope that it will be useful,
185) but WITHOUT ANY WARRANTY; without even the implied warranty of
186) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
187) GNU Lesser General Public License for more details.
188) 
189) You should have received a copy of the GNU Lesser General Public License
190) along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>.
191)  */
192) var lib_code;
193) (function (lib_code) {
194)     /**
195)      * @author fenris
196)      */
197)     function inverse_encode(decode, to) {
198)         return decode(to);
199)     }
200)     lib_code.inverse_encode = inverse_encode;
201)     /**
202)      * @author fenris
203)      */
204)     function inverse_decode(encode, from) {
205)         return encode(from);
206)     }
207)     lib_code.inverse_decode = inverse_decode;
208) })(lib_code || (lib_code = {}));
209) /*
210) This file is part of »bacterio-plankton:code«.
211) 
Christian Fraß [upd] client:lib:plankton

Christian Fraß authored 3 years ago

212) Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
Christian Fraß [add] client

Christian Fraß authored 3 years ago

213) <info@greenscale.de>
214) 
215) »bacterio-plankton:code« is free software: you can redistribute it and/or modify
216) it under the terms of the GNU Lesser General Public License as published by
217) the Free Software Foundation, either version 3 of the License, or
218) (at your option) any later version.
219) 
220) »bacterio-plankton:code« is distributed in the hope that it will be useful,
221) but WITHOUT ANY WARRANTY; without even the implied warranty of
222) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
223) GNU Lesser General Public License for more details.
224) 
225) You should have received a copy of the GNU Lesser General Public License
226) along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>.
227)  */
228) var lib_code;
229) (function (lib_code) {
230)     /**
231)      * @author fenris
232)      */
233)     lib_trait.attend("code", "inverse", {
234)         "from": {
235)             "name": "any"
236)         },
237)         "to": {
238)             "name": "any"
239)         }
240)     }, {
241)         "encode": (domain_parameters) => (x) => {
242)             return (lib_code.inverse_encode(y_ => lib_trait.call("code", "decode", domain_parameters.domain_subject)(y_), x));
243)         },
244)         "decode": (domain_parameters) => (y) => {
245)             return (lib_code.inverse_decode(x_ => lib_trait.call("code", "encode", domain_parameters.domain_subject)(x_), y));
246)         }
247)     });
248) })(lib_code || (lib_code = {}));
249) /*
250) This file is part of »bacterio-plankton:code«.
251) 
Christian Fraß [upd] client:lib:plankton

Christian Fraß authored 3 years ago

252) Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
Christian Fraß [add] client

Christian Fraß authored 3 years ago

253) <info@greenscale.de>
254) 
255) »bacterio-plankton:code« is free software: you can redistribute it and/or modify
256) it under the terms of the GNU Lesser General Public License as published by
257) the Free Software Foundation, either version 3 of the License, or
258) (at your option) any later version.
259) 
260) »bacterio-plankton:code« is distributed in the hope that it will be useful,
261) but WITHOUT ANY WARRANTY; without even the implied warranty of
262) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
263) GNU Lesser General Public License for more details.
264) 
265) You should have received a copy of the GNU Lesser General Public License
266) along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>.
267)  */
268) var lib_code;
269) (function (lib_code) {
270)     /**
271)      * @author fenris
272)      */
273)     class class_code_inverse {
274)         /**
275)          * @author fenris
276)          */
277)         constructor(subject) {
278)             this.subject = subject;
279)         }
280)         /**
281)          * @implementation
282)          * @author fenris
283)          */
284)         encode(to) {
285)             return lib_code.inverse_encode(x => this.subject.decode(x), to);
286)         }
287)         /**
288)          * @implementation
289)          * @author fenris
290)          */
291)         decode(from) {
292)             return lib_code.inverse_decode(x => this.subject.encode(x), from);
293)         }
294)     }
295)     lib_code.class_code_inverse = class_code_inverse;
296) })(lib_code || (lib_code = {}));
297) /*
298) This file is part of »bacterio-plankton:code«.
299) 
Christian Fraß [upd] client:lib:plankton

Christian Fraß authored 3 years ago

300) Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
Christian Fraß [add] client

Christian Fraß authored 3 years ago

301) <info@greenscale.de>
302) 
303) »bacterio-plankton:code« is free software: you can redistribute it and/or modify
304) it under the terms of the GNU Lesser General Public License as published by
305) the Free Software Foundation, either version 3 of the License, or
306) (at your option) any later version.
307) 
308) »bacterio-plankton:code« is distributed in the hope that it will be useful,
309) but WITHOUT ANY WARRANTY; without even the implied warranty of
310) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
311) GNU Lesser General Public License for more details.
312) 
313) You should have received a copy of the GNU Lesser General Public License
314) along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>.
315)  */
316) var lib_code;
317) (function (lib_code) {
318)     /**
319)      * @author fenris
320)      */
321)     function pair_encode(encode_first, encode_second, from) {
322)         let between = encode_first(from);
323)         let to = encode_second(between);
324)         return to;
325)     }
326)     lib_code.pair_encode = pair_encode;
327)     /**
328)      * @author fenris
329)      */
330)     function pair_decode(decode_first, decode_second, to) {
331)         let between = decode_second(to);
332)         let from = decode_first(between);
333)         return from;
334)     }
335)     lib_code.pair_decode = pair_decode;
336) })(lib_code || (lib_code = {}));
337) /*
338) This file is part of »bacterio-plankton:code«.
339) 
Christian Fraß [upd] client:lib:plankton

Christian Fraß authored 3 years ago

340) Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
Christian Fraß [add] client

Christian Fraß authored 3 years ago

341) <info@greenscale.de>
342) 
343) »bacterio-plankton:code« is free software: you can redistribute it and/or modify
344) it under the terms of the GNU Lesser General Public License as published by
345) the Free Software Foundation, either version 3 of the License, or
346) (at your option) any later version.
347) 
348) »bacterio-plankton:code« is distributed in the hope that it will be useful,
349) but WITHOUT ANY WARRANTY; without even the implied warranty of
350) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
351) GNU Lesser General Public License for more details.
352) 
353) You should have received a copy of the GNU Lesser General Public License
354) along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>.
355)  */
356) var lib_code;
357) (function (lib_code) {
358)     /**
359)      * @author fenris
360)      */
361)     lib_trait.attend("code", "pair", {
362)         "from": {
363)             "name": "any"
364)         },
365)         "to": {
366)             "name": "any"
367)         }
368)     }, {
369)         "encode": (domain_parameters) => (x) => {
370)             return (lib_code.pair_encode(x_ => lib_trait.call("code", "encode", domain_parameters.domain_first)(x_), x_ => lib_trait.call("code", "encode", domain_parameters.domain_second)(x_), x));
371)         },
372)         "decode": (domain_parameters) => (y) => {
373)             return (lib_code.pair_decode(y_ => lib_trait.call("code", "decode", domain_parameters.domain_first)(y_), y_ => lib_trait.call("code", "decode", domain_parameters.domain_second)(y_), y));
374)         }
375)     });
376) })(lib_code || (lib_code = {}));
377) /*
378) This file is part of »bacterio-plankton:code«.
379) 
Christian Fraß [upd] client:lib:plankton

Christian Fraß authored 3 years ago

380) Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
Christian Fraß [add] client

Christian Fraß authored 3 years ago

381) <info@greenscale.de>
382) 
383) »bacterio-plankton:code« is free software: you can redistribute it and/or modify
384) it under the terms of the GNU Lesser General Public License as published by
385) the Free Software Foundation, either version 3 of the License, or
386) (at your option) any later version.
387) 
388) »bacterio-plankton:code« is distributed in the hope that it will be useful,
389) but WITHOUT ANY WARRANTY; without even the implied warranty of
390) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
391) GNU Lesser General Public License for more details.
392) 
393) You should have received a copy of the GNU Lesser General Public License
394) along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>.
395)  */
396) var lib_code;
397) (function (lib_code) {
398)     /**
399)      * @author fenris
400)      */
401)     class class_code_pair {
402)         /**
403)          * @author fenris
404)          */
405)         constructor(first, second) {
406)             this.first = first;
407)             this.second = second;
408)         }
409)         /**
410)          * @implementation
411)          * @author fenris
412)          */
413)         encode(from) {
414)             return lib_code.pair_encode(x => this.first.encode(x), x => this.second.encode(x), from);
415)         }
416)         /**
417)          * @implementation
418)          * @author fenris
419)          */
420)         decode(to) {
421)             return lib_code.pair_decode(x => this.first.decode(x), x => this.second.decode(x), to);
422)         }
423)     }
424)     lib_code.class_code_pair = class_code_pair;
425) })(lib_code || (lib_code = {}));
426) /*
427) This file is part of »bacterio-plankton:code«.
428) 
Christian Fraß [upd] client:lib:plankton

Christian Fraß authored 3 years ago

429) Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
Christian Fraß [add] client

Christian Fraß authored 3 years ago

430) <info@greenscale.de>
431) 
432) »bacterio-plankton:code« is free software: you can redistribute it and/or modify
433) it under the terms of the GNU Lesser General Public License as published by
434) the Free Software Foundation, either version 3 of the License, or
435) (at your option) any later version.
436) 
437) »bacterio-plankton:code« is distributed in the hope that it will be useful,
438) but WITHOUT ANY WARRANTY; without even the implied warranty of
439) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
440) GNU Lesser General Public License for more details.
441) 
442) You should have received a copy of the GNU Lesser General Public License
443) along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>.
444)  */
445) var lib_code;
446) (function (lib_code) {
447)     /**
448)      * @author fenris
449)      */
450)     function chain_encode(encode_links, from) {
451)         let value = from;
452)         encode_links
453)             .forEach((link) => {
454)             value = link(value);
455)         });
456)         return value;
457)     }
458)     lib_code.chain_encode = chain_encode;
459)     /**
460)      * @author fenris
461)      */
462)     function chain_decode(decode_links, to) {
463)         let value = to;
464)         decode_links
465)             .reverse()
466)             .forEach((link) => {
467)             value = link(value);
468)         });
469)         return value;
470)     }
471)     lib_code.chain_decode = chain_decode;
472) })(lib_code || (lib_code = {}));
473) /*
474) This file is part of »bacterio-plankton:code«.
475) 
Christian Fraß [upd] client:lib:plankton

Christian Fraß authored 3 years ago

476) Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
Christian Fraß [add] client

Christian Fraß authored 3 years ago

477) <info@greenscale.de>
478) 
479) »bacterio-plankton:code« is free software: you can redistribute it and/or modify
480) it under the terms of the GNU Lesser General Public License as published by
481) the Free Software Foundation, either version 3 of the License, or
482) (at your option) any later version.
483) 
484) »bacterio-plankton:code« is distributed in the hope that it will be useful,
485) but WITHOUT ANY WARRANTY; without even the implied warranty of
486) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
487) GNU Lesser General Public License for more details.
488) 
489) You should have received a copy of the GNU Lesser General Public License
490) along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>.
491)  */
492) var lib_code;
493) (function (lib_code) {
494)     /**
495)      * @author fenris
496)      */
497)     class class_code_chain {
498)         /**
499)          * @author fenris
500)          */
501)         constructor(links) {
502)             this.links = links;
503)         }
504)         /**
505)          * @implementation
506)          * @author fenris
507)          */
508)         encode(from) {
509)             return lib_code.chain_encode(this.links.map((link) => (x => link.encode(x))), from);
510)         }
511)         /**
512)          * @implementation
513)          * @author fenris
514)          */
515)         decode(to) {
516)             return lib_code.chain_decode(this.links.map((link) => (x => link.decode(x))), to);
517)         }
518)     }
519)     lib_code.class_code_chain = class_code_chain;
520) })(lib_code || (lib_code = {}));
521) /*
522) This file is part of »bacterio-plankton:code«.
523) 
Christian Fraß [upd] client:lib:plankton

Christian Fraß authored 3 years ago

524) Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
Christian Fraß [add] client

Christian Fraß authored 3 years ago

525) <info@greenscale.de>
526) 
527) »bacterio-plankton:code« is free software: you can redistribute it and/or modify
528) it under the terms of the GNU Lesser General Public License as published by
529) the Free Software Foundation, either version 3 of the License, or
530) (at your option) any later version.
531) 
532) »bacterio-plankton:code« is distributed in the hope that it will be useful,
533) but WITHOUT ANY WARRANTY; without even the implied warranty of
534) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
535) GNU Lesser General Public License for more details.
536) 
537) You should have received a copy of the GNU Lesser General Public License
538) along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>.
539)  */
540) var lib_code;
541) (function (lib_code) {
542)     /**
543)      * @author Christian Fraß <frass@greenscale.de>
544)      */
545)     function flatten_encode(from, keys = null) {
546)         if (keys === null) {
547)             if (from.length > 0) {
548)                 keys = Object.keys(from[0]);
549)             }
550)             else {
551)                 throw (new Error("encoding impossible"));
552)             }
553)         }
554)         return {
555)             "keys": keys,
556)             "data": from.map((line) => keys.map((name) => line[name])),
557)         };
558)     }
559)     lib_code.flatten_encode = flatten_encode;
560)     /**
561)      * @author Christian Fraß <frass@greenscale.de>
562)      */
563)     function flatten_decode(to) {
564)         return (to.data
565)             .map((dataset) => {
566)             let dataset_ = {};
567)             dataset
568)                 .forEach((value, index) => {
569)                 const name = to.keys[index];
570)                 dataset_[name] = value;
571)             });
572)             return dataset_;
573)         }));
574)     }
575)     lib_code.flatten_decode = flatten_decode;
576) })(lib_code || (lib_code = {}));
577) /*
578) This file is part of »bacterio-plankton:code«.
579) 
Christian Fraß [upd] client:lib:plankton

Christian Fraß authored 3 years ago

580) Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
Christian Fraß [add] client

Christian Fraß authored 3 years ago

581) <info@greenscale.de>
582) 
583) »bacterio-plankton:code« is free software: you can redistribute it and/or modify
584) it under the terms of the GNU Lesser General Public License as published by
585) the Free Software Foundation, either version 3 of the License, or
586) (at your option) any later version.
587) 
588) »bacterio-plankton:code« is distributed in the hope that it will be useful,
589) but WITHOUT ANY WARRANTY; without even the implied warranty of
590) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
591) GNU Lesser General Public License for more details.
592) 
593) You should have received a copy of the GNU Lesser General Public License
594) along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>.
595)  */
596) var lib_code;
597) (function (lib_code) {
598)     /**
599)      * @author fenris
600)      */
601)     class class_code_flatten {
602)         /**
603)          * @author fenris
604)          */
605)         constructor() {
606)         }
607)         /**
608)          * @implementation
609)          * @author fenris
610)          */
611)         encode(x) {
612)             return lib_code.flatten_encode(x);
613)         }
614)         /**
615)          * @implementation
616)          * @author fenris
617)          */
618)         decode(x) {
619)             return lib_code.flatten_decode(x);
620)         }
621)     }
622)     lib_code.class_code_flatten = class_code_flatten;
623) })(lib_code || (lib_code = {}));
624) /*
625) This file is part of »bacterio-plankton:code«.
626) 
Christian Fraß [upd] client:lib:plankton

Christian Fraß authored 3 years ago

627) Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
Christian Fraß [add] client

Christian Fraß authored 3 years ago

628) <info@greenscale.de>
629) 
630) »bacterio-plankton:code« is free software: you can redistribute it and/or modify
631) it under the terms of the GNU Lesser General Public License as published by
632) the Free Software Foundation, either version 3 of the License, or
633) (at your option) any later version.
634) 
635) »bacterio-plankton:code« is distributed in the hope that it will be useful,
636) but WITHOUT ANY WARRANTY; without even the implied warranty of
637) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
638) GNU Lesser General Public License for more details.
639) 
640) You should have received a copy of the GNU Lesser General Public License
641) along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>.
642)  */
643) var lib_code;
644) (function (lib_code) {
645)     /**
646)      * @author fenris
647)      */
648)     const _prefix = "DATE:";
649)     /**
650)      * @author fenris
651)      */
652)     function jsdate_encode(date) {
653)         let isostring = date.toISOString();
654)         let date_ = (_prefix + isostring);
655)         return date_;
656)     }
657)     lib_code.jsdate_encode = jsdate_encode;
658)     /**
659)      * @author fenris
660)      */
661)     function jsdate_decode(date_) {
662)         if ((typeof (date_) === "string") && (date_.startsWith(_prefix))) {
663)             let isostring = date_.slice(_prefix.length);
664)             let timestamp = Date.parse(isostring);
665)             if (!isNaN(timestamp)) {
666)                 let date = (new Date(timestamp));
667)                 return date;
668)             }
669)             else {
670)                 let message = ("'" + isostring + "' does not seem to be an ISO-string of a date");
671)                 throw (new Error(message));
672)             }
673)         }
674)         else {
675)             let message = ("expected an encoded date object to be a string starting with '" + _prefix + "'");
676)             throw (new Error(message));
677)         }
678)     }
679)     lib_code.jsdate_decode = jsdate_decode;
680) })(lib_code || (lib_code = {}));
681) /*
682) This file is part of »bacterio-plankton:code«.
683) 
Christian Fraß [upd] client:lib:plankton

Christian Fraß authored 3 years ago

684) Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
Christian Fraß [add] client

Christian Fraß authored 3 years ago

685) <info@greenscale.de>
686) 
687) »bacterio-plankton:code« is free software: you can redistribute it and/or modify
688) it under the terms of the GNU Lesser General Public License as published by
689) the Free Software Foundation, either version 3 of the License, or
690) (at your option) any later version.
691) 
692) »bacterio-plankton:code« is distributed in the hope that it will be useful,
693) but WITHOUT ANY WARRANTY; without even the implied warranty of
694) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
695) GNU Lesser General Public License for more details.
696) 
697) You should have received a copy of the GNU Lesser General Public License
698) along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>.
699)  */
700) var lib_code;
701) (function (lib_code) {
702)     /**
703)      * @author fenris
704)      */
705)     lib_trait.attend("code", "jsdate", {
706)         "from": {
707)             "name": "date"
708)         },
709)         "to": {
710)             "name": "string"
711)         }
712)     }, {
713)         "encode": () => (x) => {
714)             return lib_code.jsdate_encode(x);
715)         },
716)         "decode": () => (y) => {
717)             return lib_code.jsdate_decode(y);
718)         }
719)     });
720) })(lib_code || (lib_code = {}));
721) /*
722) This file is part of »bacterio-plankton:code«.
723) 
Christian Fraß [upd] client:lib:plankton

Christian Fraß authored 3 years ago

724) Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
Christian Fraß [add] client

Christian Fraß authored 3 years ago

725) <info@greenscale.de>
726) 
727) »bacterio-plankton:code« is free software: you can redistribute it and/or modify
728) it under the terms of the GNU Lesser General Public License as published by
729) the Free Software Foundation, either version 3 of the License, or
730) (at your option) any later version.
731) 
732) »bacterio-plankton:code« is distributed in the hope that it will be useful,
733) but WITHOUT ANY WARRANTY; without even the implied warranty of
734) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
735) GNU Lesser General Public License for more details.
736) 
737) You should have received a copy of the GNU Lesser General Public License
738) along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>.
739)  */
740) var lib_code;
741) (function (lib_code) {
742)     /**
743)      * @author fenris
744)      */
745)     class class_code_jsdate {
746)         /**
747)          * @author fenris
748)          */
749)         constructor() {
750)         }
751)         /**
752)          * @implementation
753)          * @author fenris
754)          */
755)         encode(x) {
756)             return lib_code.jsdate_encode(x);
757)         }
758)         /**
759)          * @implementation
760)          * @author fenris
761)          */
762)         decode(x) {
763)             return lib_code.jsdate_decode(x);
764)         }
765)     }
766)     lib_code.class_code_jsdate = class_code_jsdate;
767) })(lib_code || (lib_code = {}));
768) /*
769) This file is part of »bacterio-plankton:code«.
770) 
Christian Fraß [upd] client:lib:plankton

Christian Fraß authored 3 years ago

771) Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
Christian Fraß [add] client

Christian Fraß authored 3 years ago

772) <info@greenscale.de>
773) 
774) »bacterio-plankton:code« is free software: you can redistribute it and/or modify
775) it under the terms of the GNU Lesser General Public License as published by
776) the Free Software Foundation, either version 3 of the License, or
777) (at your option) any later version.
778) 
779) »bacterio-plankton:code« is distributed in the hope that it will be useful,
780) but WITHOUT ANY WARRANTY; without even the implied warranty of
781) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
782) GNU Lesser General Public License for more details.
783) 
784) You should have received a copy of the GNU Lesser General Public License
785) along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>.
786)  */
787) var lib_code;
788) (function (lib_code) {
789)     /**
790)      * @author Christian Fraß <frass@greenscale.de>
791)      * @todo escaping
792)      */
793)     function csv_encode(from, { "delimiter": delimiter = ",", "linebreak": linebreak = "\n", } = {}) {
794)         return (([]
795)             .concat((from.head !== null)
796)             ? [from.head]
797)             : [])
798)             .concat(from.data))
799)             .map((dataset) => dataset.join(delimiter))
800)             .join(linebreak));
801)     }
802)     lib_code.csv_encode = csv_encode;
803)     /**
804)      * @author Christian Fraß <frass@greenscale.de>
805)      */
806)     function csv_decode(to, { "delimiter": delimiter = ",", "linebreak": linebreak = "\n", "with_head": with_head = true, } = {}) {
807)         const array = (to.split(linebreak)
808)             .map((line) => line.split(delimiter)));
809)         return (with_head
810)             ? ({
811)                 "head": array[0],
812)                 "data": array.slice(1),
813)             })
814)             : ({
815)                 "head": null,
816)                 "data": array,
817)             }));
818)     }
819)     lib_code.csv_decode = csv_decode;
820) })(lib_code || (lib_code = {}));
821) /*
822) This file is part of »bacterio-plankton:code«.
823) 
Christian Fraß [upd] client:lib:plankton

Christian Fraß authored 3 years ago

824) Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'