git.schokokeks.org
Repositories
Help
Report an Issue
fs-words.git
Code
Commits
Branches
Tags
Suche
Strukturansicht:
b10ca45
Branches
Tags
develop-client_server
master
typescript
fs-words.git
lib
plankton
code
logic-impl.js
[add] lib:plankton
Christian Fraß
commited
b10ca45
at 2021-03-08 23:02:57
logic-impl.js
Blame
History
Raw
/* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ lib_trait.define("code", { "from": null, "to": null }, { "encode": { "shape": { "name": "function", "parameters": { "shape_input": { "name": "variable", "parameters": { "name": "from" } }, "shape_output": { "name": "variable", "parameters": { "name": "to" } } } } }, "decode": { "shape": { "name": "function", "parameters": { "shape_input": { "name": "variable", "parameters": { "name": "to" } }, "shape_output": { "name": "variable", "parameters": { "name": "from" } } } } } }); })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author Christian Fraß <frass@greenscale.de> */ function custom_encode(function_, from) { return function_(from); } lib_code.custom_encode = custom_encode; /** * @author Christian Fraß <frass@greenscale.de> */ function custom_decode(function_, to) { return function_(to); } lib_code.custom_decode = custom_decode; })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ class class_code_custom { /** * @author fenris */ constructor(encodefunc, decodefunc) { this.encodefunc = encodefunc; this.decodefunc = decodefunc; } /** * @implementation * @author fenris */ encode(x) { return lib_code.custom_encode(this.encodefunc, x); } /** * @implementation * @author fenris */ decode(x) { return lib_code.custom_decode(this.decodefunc, x); } } lib_code.class_code_custom = class_code_custom; })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ function inverse_encode(decode, to) { return decode(to); } lib_code.inverse_encode = inverse_encode; /** * @author fenris */ function inverse_decode(encode, from) { return encode(from); } lib_code.inverse_decode = inverse_decode; })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ lib_trait.attend("code", "inverse", { "from": { "name": "any" }, "to": { "name": "any" } }, { "encode": (domain_parameters) => (x) => { return (lib_code.inverse_encode(y_ => lib_trait.call("code", "decode", domain_parameters.domain_subject)(y_), x)); }, "decode": (domain_parameters) => (y) => { return (lib_code.inverse_decode(x_ => lib_trait.call("code", "encode", domain_parameters.domain_subject)(x_), y)); } }); })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ class class_code_inverse { /** * @author fenris */ constructor(subject) { this.subject = subject; } /** * @implementation * @author fenris */ encode(to) { return lib_code.inverse_encode(x => this.subject.decode(x), to); } /** * @implementation * @author fenris */ decode(from) { return lib_code.inverse_decode(x => this.subject.encode(x), from); } } lib_code.class_code_inverse = class_code_inverse; })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ function pair_encode(encode_first, encode_second, from) { let between = encode_first(from); let to = encode_second(between); return to; } lib_code.pair_encode = pair_encode; /** * @author fenris */ function pair_decode(decode_first, decode_second, to) { let between = decode_second(to); let from = decode_first(between); return from; } lib_code.pair_decode = pair_decode; })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ lib_trait.attend("code", "pair", { "from": { "name": "any" }, "to": { "name": "any" } }, { "encode": (domain_parameters) => (x) => { 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)); }, "decode": (domain_parameters) => (y) => { 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)); } }); })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ class class_code_pair { /** * @author fenris */ constructor(first, second) { this.first = first; this.second = second; } /** * @implementation * @author fenris */ encode(from) { return lib_code.pair_encode(x => this.first.encode(x), x => this.second.encode(x), from); } /** * @implementation * @author fenris */ decode(to) { return lib_code.pair_decode(x => this.first.decode(x), x => this.second.decode(x), to); } } lib_code.class_code_pair = class_code_pair; })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ function chain_encode(encode_links, from) { let value = from; encode_links .forEach((link) => { value = link(value); }); return value; } lib_code.chain_encode = chain_encode; /** * @author fenris */ function chain_decode(decode_links, to) { let value = to; decode_links .reverse() .forEach((link) => { value = link(value); }); return value; } lib_code.chain_decode = chain_decode; })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ class class_code_chain { /** * @author fenris */ constructor(links) { this.links = links; } /** * @implementation * @author fenris */ encode(from) { return lib_code.chain_encode(this.links.map((link) => (x => link.encode(x))), from); } /** * @implementation * @author fenris */ decode(to) { return lib_code.chain_decode(this.links.map((link) => (x => link.decode(x))), to); } } lib_code.class_code_chain = class_code_chain; })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author Christian Fraß <frass@greenscale.de> */ function flatten_encode(from, keys = null) { if (keys === null) { if (from.length > 0) { keys = Object.keys(from[0]); } else { throw (new Error("encoding impossible")); } } return { "keys": keys, "data": from.map((line) => keys.map((name) => line[name])), }; } lib_code.flatten_encode = flatten_encode; /** * @author Christian Fraß <frass@greenscale.de> */ function flatten_decode(to) { return (to.data .map((dataset) => { let dataset_ = {}; dataset .forEach((value, index) => { const name = to.keys[index]; dataset_[name] = value; }); return dataset_; })); } lib_code.flatten_decode = flatten_decode; })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ class class_code_flatten { /** * @author fenris */ constructor() { } /** * @implementation * @author fenris */ encode(x) { return lib_code.flatten_encode(x); } /** * @implementation * @author fenris */ decode(x) { return lib_code.flatten_decode(x); } } lib_code.class_code_flatten = class_code_flatten; })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ const _prefix = "DATE:"; /** * @author fenris */ function jsdate_encode(date) { let isostring = date.toISOString(); let date_ = (_prefix + isostring); return date_; } lib_code.jsdate_encode = jsdate_encode; /** * @author fenris */ function jsdate_decode(date_) { if ((typeof (date_) === "string") && (date_.startsWith(_prefix))) { let isostring = date_.slice(_prefix.length); let timestamp = Date.parse(isostring); if (!isNaN(timestamp)) { let date = (new Date(timestamp)); return date; } else { let message = ("'" + isostring + "' does not seem to be an ISO-string of a date"); throw (new Error(message)); } } else { let message = ("expected an encoded date object to be a string starting with '" + _prefix + "'"); throw (new Error(message)); } } lib_code.jsdate_decode = jsdate_decode; })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ lib_trait.attend("code", "jsdate", { "from": { "name": "date" }, "to": { "name": "string" } }, { "encode": () => (x) => { return lib_code.jsdate_encode(x); }, "decode": () => (y) => { return lib_code.jsdate_decode(y); } }); })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ class class_code_jsdate { /** * @author fenris */ constructor() { } /** * @implementation * @author fenris */ encode(x) { return lib_code.jsdate_encode(x); } /** * @implementation * @author fenris */ decode(x) { return lib_code.jsdate_decode(x); } } lib_code.class_code_jsdate = class_code_jsdate; })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ function json_encode(x, formatted = false) { return JSON.stringify(x, undefined, formatted ? "\t" : undefined); } lib_code.json_encode = json_encode; /** * @author fenris */ function json_decode(x) { return JSON.parse(x); } lib_code.json_decode = json_decode; })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ lib_trait.attend("code", "json", { "from": { "name": "any" }, "to": { "name": "string" } }, { "encode": () => (x) => { return lib_code.json_encode(x); }, "decode": () => (y) => { return lib_code.json_decode(y); } }); })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ class class_code_json { /** * @author fenris */ constructor() { } /** * @implementation * @author fenris */ encode(x) { return lib_code.json_encode(x); } /** * @implementation * @author fenris */ decode(x) { return lib_code.json_decode(x); } } lib_code.class_code_json = class_code_json; })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author Christian Fraß <frass@greenscale.de> * @todo escaping */ function csv_encode(from, { "delimiter": delimiter = ",", "linebreak": linebreak = "\n", } = {}) { return (([] .concat((from.head !== null) ? [from.head] : []) .concat(from.data)) .map((dataset) => dataset.join(delimiter)) .join(linebreak)); } lib_code.csv_encode = csv_encode; /** * @author Christian Fraß <frass@greenscale.de> */ function csv_decode(to, { "delimiter": delimiter = ",", "linebreak": linebreak = "\n", "with_head": with_head = true, } = {}) { const array = (to.split(linebreak) .map((line) => line.split(delimiter))); return (with_head ? ({ "head": array[0], "data": array.slice(1), }) : ({ "head": null, "data": array, })); } lib_code.csv_decode = csv_decode; })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ class class_code_csv { /** * @author fenris */ constructor() { } /** * @implementation * @author fenris */ encode(x) { return lib_code.csv_encode(x); } /** * @implementation * @author fenris */ decode(x) { return lib_code.csv_decode(x); } } lib_code.class_code_csv = class_code_csv; })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ function uri_encode(x) { return encodeURIComponent(x); } lib_code.uri_encode = uri_encode; /** * @author fenris */ function uri_decode(x) { return decodeURIComponent(x); } lib_code.uri_decode = uri_decode; })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ lib_trait.attend("code", "uri", { "from": { "name": "string" }, "to": { "name": "string" } }, { "encode": () => (x) => { return lib_code.uri_encode(x); }, "decode": () => (y) => { return lib_code.uri_decode(y); } }); })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ class class_code_uri { /** * @author fenris */ constructor() { } /** * @implementation * @author fenris */ encode(x) { return lib_code.uri_encode(x); } /** * @implementation * @author fenris */ decode(x) { return lib_code.uri_decode(x); } } lib_code.class_code_uri = class_code_uri; })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ function base64_encode(x) { return (new Buffer(x)).toString("base64"); } lib_code.base64_encode = base64_encode; /** * @author fenris */ function base64_decode(x) { return (new Buffer(x, "base64")).toString(); } lib_code.base64_decode = base64_decode; })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ lib_trait.attend("code", "base64", { "from": { "name": "string" }, "to": { "name": "string" } }, { "encode": () => (x) => { return lib_code.base64_encode(x); }, "decode": () => (y) => { return lib_code.base64_decode(y); } }); })(lib_code || (lib_code = {})); /* This file is part of »bacterio-plankton:code«. Copyright 2016-2018 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:code« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »bacterio-plankton:code« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:code«. If not, see <http://www.gnu.org/licenses/>. */ var lib_code; (function (lib_code) { /** * @author fenris */ class class_code_base64 { /** * @author fenris */ constructor() { } /** * @implementation * @author fenris */ encode(x) { return lib_code.base64_encode(x); } /** * @implementation * @author fenris */ decode(x) { return lib_code.base64_decode(x); } } lib_code.class_code_base64 = class_code_base64; })(lib_code || (lib_code = {}));