git.schokokeks.org
Repositories
Help
Report an Issue
fs-words.git
Code
Commits
Branches
Tags
Suche
Strukturansicht:
99941cf
Branches
Tags
develop-client_server
master
typescript
fs-words.git
server
lib
plankton
base
logic-impl.js
[upd] server:lib:plankton
Christian Fraß
commited
99941cf
at 2021-03-12 00:46:54
logic-impl.js
Blame
History
Raw
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); /* This file is part of »bacterio-plankton:base«. Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:base« 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:base« 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:base«. If not, see <http://www.gnu.org/licenses/>. */ // } /* This file is part of »bacterio-plankton:base«. Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:base« 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:base« 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:base«. If not, see <http://www.gnu.org/licenses/>. */ /** * @author fenris */ /*export*/ function pseudopointer_null() { return { "value": null }; } /** * @author fenris */ /*export*/ function pseudopointer_make(value) { return { "value": value }; } /** * @author fenris */ /*export*/ function pseudopointer_isset(pseudopointer) { return (pseudopointer.value != null); } /** * @author fenris */ /*export*/ function pseudopointer_read(pseudopointer) { if (pseudopointer.value != null) { return pseudopointer.value; } else { var message = "nullpointer dereferencation"; throw (new Error(message)); } } /** * @author fenris */ /*export*/ function pseudopointer_write(pseudopointer, value) { pseudopointer.value = value; } /* This file is part of »bacterio-plankton:base«. Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:base« 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:base« 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:base«. If not, see <http://www.gnu.org/licenses/>. */ ; var lib_base; (function (lib_base) { /** * @author fenris */ function environment() { var entries = [ { "id": "web", "name": "Web", "predicate": function () { return (typeof (document) !== "undefined"); }, }, { "id": "node", "name": "Node.js", "predicate": function () { return (typeof (process) !== "undefined"); }, }, { "id": "rhino", "name": "Rhino", "predicate": function () { return (typeof (java) !== "undefined"); }, }, { "id": "webworker", "name": "WebWorker", "predicate": function () { return (typeof (self["WorkerNavigator"]) !== "undefined"); } } ]; var id; var found = entries.some(function (entry) { if (entry.predicate()) { id = entry.id; return true; } else { return false; } }); if (found) { return id; } else { throw (new Error("unknown environment")); } } lib_base.environment = environment; })(lib_base || (lib_base = {})); /* This file is part of »bacterio-plankton:base«. Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:base« 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:base« 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:base«. If not, see <http://www.gnu.org/licenses/>. */ /** * @author fenris */ var instance_verbosity = 0; /** * @author fenris */ function instance_collate(value1, value2) { if (typeof (value1) === "object") { if (value1 == null) { return (value2 == null); } else { if ("_collate" in value1) { return value1["_collate"](value2); } else { throw (new Error("[collate]" + " " + "object has no such method")); } } } else { if (instance_verbosity >= 1) { lib_log.warn("[collate]" + " " + "primitive value; using default implementation"); } return (value1 === value2); } } /** * @author fenris */ function instance_compare(value1, value2) { if (typeof (value1) === "object") { if ("_compare" in value1) { return value1["_compare"](value2); } else { throw (new Error("[compare]" + " " + "object has no such method")); } } else { if (instance_verbosity >= 1) { lib_log.warn("[compare]" + " " + "primitive value; using default implementation"); } return (value1 <= value2); } } /** * @author fenris */ function instance_clone(value) { if (typeof (value) === "object") { if ("_clone" in value) { return value["_clone"](); } else { throw (new Error("[clone]" + " " + "object has no such method")); } } else { if (instance_verbosity >= 1) { lib_log.warn("[clone]" + " " + "primitive value; using default implementation"); } return value; } } /** * @desc the ability to generate a string out of the element, which identifies it to a high degree * @author fenris */ function instance_hash(value) { if (typeof (value) === "object") { if ("_hash" in value) { return value["_hash"](); } else { throw (new Error("[hash]" + " " + "object has no such method")); } } else { if (instance_verbosity >= 1) { lib_log.warn("[hash]" + " " + "primitive value; using default implementation"); } return String(value); } } /** * @desc the ability to map the element to a textual representation (most likely not injective) * @author fenris */ function instance_show(value) { if (typeof (value) === "object") { if (value == null) { return "NULL"; } else { if ("_show" in value) { return value["_show"](); } else { // throw (new Error("[show]" + " " + "object has no such method")); return JSON.stringify(value); } } } else { if (instance_verbosity >= 1) { lib_log.warn("[show]" + " " + "primitive value; using default implementation"); } return String(value); } } /* This file is part of »bacterio-plankton:base«. Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:base« 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:base« 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:base«. If not, see <http://www.gnu.org/licenses/>. */ /** * @todo outsource to dedicated plankton-lib */ var lib_log; (function (lib_log) { /** * @author fenris */ function log() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } /*window.*/ console.log.apply(console, args); } lib_log.log = log; /** * @author fenris */ function info() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } /*window.*/ console.info.apply(console, args); } lib_log.info = info; /** * @author fenris */ function warn() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } /*window.*/ console.warn.apply(console, args); } lib_log.warn = warn; /** * @author fenris */ function error() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } /*window.*/ console.error.apply(console, args); } lib_log.error = error; })(lib_log || (lib_log = {})); /* This file is part of »bacterio-plankton:base«. Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:base« 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:base« 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:base«. If not, see <http://www.gnu.org/licenses/>. */ /** * @author frac */ var class_observer = /** @class */ (function () { /** * @author frac */ function class_observer() { this.counter = 0; this.actions = {}; this.buffer = []; } /** * @author frac */ class_observer.prototype.empty = function () { return (Object.keys(this.actions).length == 0); }; /** * @author frac */ class_observer.prototype.flush = function () { this.actions = {}; }; /** * @author frac */ class_observer.prototype.set = function (id, action) { this.actions[id] = action; }; /** * @author frac */ class_observer.prototype.del = function (id) { delete this.actions[id]; }; /** * @author frac */ class_observer.prototype.add = function (action) { this.set((this.counter++).toString(), action); }; /** * @author frac */ class_observer.prototype.notify = function (information, delayed) { var _this = this; if (information === void 0) { information = {}; } if (delayed === void 0) { delayed = false; } if (delayed) { this.buffer.push(information); } else { Object.keys(this.actions).forEach(function (id) { return _this.actions[id](information); }); } }; /** * @author frac */ class_observer.prototype.rollout = function () { var _this = this; this.buffer.forEach(function (information) { return _this.notify(information, false); }); this.buffer = []; }; return class_observer; }()); /** * @author frac */ /* export interface interface_readable<type_value> { |** * @author frac *| read() : type_executor<type_value, Error>; } */ /** * @author frac */ /* export interface interface_writeable<type_value> { |** * @author frac *| write(value : type_value) : type_executor<void, Error>; } */ /* This file is part of »bacterio-plankton:base«. Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:base« 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:base« 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:base«. If not, see <http://www.gnu.org/licenses/>. */ var lib_maybe; (function (lib_maybe) { /** * @author fenris */ function make_nothing() { return { "kind": "nothing", "parameters": {} }; } lib_maybe.make_nothing = make_nothing; /** * @author fenris */ function make_just(value) { return { "kind": "just", "parameters": { "value": value } }; } lib_maybe.make_just = make_just; /** * @author fenris */ function is_nothing(maybe) { return (maybe.kind === "nothing"); } lib_maybe.is_nothing = is_nothing; /** * @author fenris */ function is_just(maybe) { return (maybe.kind === "just"); } lib_maybe.is_just = is_just; /** * @author fenris */ function cull(maybe) { if (!is_just(maybe)) { var message = "cull from nothing"; throw (new Error(message)); } else { var value = maybe.parameters["value"]; return value; } } lib_maybe.cull = cull; /** * @author fenris */ function propagate(maybe, function_) { if (!is_just(maybe)) { } else { var value = maybe.parameters["value"]; var maybe_ = function_(value); return maybe_; } } lib_maybe.propagate = propagate; })(lib_maybe || (lib_maybe = {})); /** * @author fenris */ /*export*/ var class_maybe = /** @class */ (function () { function class_maybe() { } /** * @desc whether the wrapper is nothing * @author fenris */ class_maybe.prototype.is_nothing = function () { throw (new Error("not implemented: class_maybe.is_nothing")); }; /** * @desc whether the wrapper is just * @author fenris */ class_maybe.prototype.is_just = function () { throw (new Error("not implemented: class_maybe.is_just")); }; /** * @desc return the value, stored in the maybe-wrapper * @author fenris */ class_maybe.prototype.cull = function () { throw (new Error("not implemented: class_maybe.cull")); }; /** * @author fenris */ class_maybe.prototype.toString = function () { throw (new Error("not implemented: class_maybe.cull")); }; /** * @author fenris */ class_maybe.prototype.distinguish = function (action_just, action_nothing) { if (action_nothing === void 0) { action_nothing = function () { }; } throw (new Error("not implemented: class_maybe.distinguish")); }; /** * @author fenris */ class_maybe.prototype.propagate = function (action) { throw (new Error("not implemented: class_maybe.propagate")); }; /** * @desc [implementation] * @author fenris */ class_maybe.prototype._show = function () { return this.toString(); }; return class_maybe; }()); /** * @author fenris */ /*export*/ var class_nothing = /** @class */ (function (_super) { __extends(class_nothing, _super); /** * @author fenris */ function class_nothing(reason) { if (reason === void 0) { reason = null; } var _this = _super.call(this) || this; _this.reason = reason; return _this; } /** * @author fenris */ class_nothing.prototype.is_nothing = function () { return true; }; /** * @author fenris */ class_nothing.prototype.is_just = function () { return false; }; /** * @author fenris */ class_nothing.prototype.cull = function () { var message = "you shouldn't cull a nothing-value …"; lib_log.warn(message); return null; }; /** * @author fenris */ class_nothing.prototype.toString = function () { return "<\u00B7>"; }; /** * @author fenris */ class_nothing.prototype.reason_get = function () { var content = ((this.reason == null) ? "·" : this.reason); return "<- " + content + " ->"; }; /** * @author fenris */ class_nothing.prototype.distinguish = function (action_just, action_nothing) { if (action_nothing === void 0) { action_nothing = function () { }; } action_nothing(this.reason); }; /** * @author fenris */ class_nothing.prototype.propagate = function (action) { return (new class_nothing(this.reason)); }; return class_nothing; }(class_maybe)); /** * @author fenris */ /*export*/ var class_just = /** @class */ (function (_super) { __extends(class_just, _super); /** * @author fenris */ function class_just(value) { var _this = _super.call(this) || this; _this.value = value; return _this; } /** * @author fenris */ class_just.prototype.is_nothing = function () { return false; }; /** * @author fenris */ class_just.prototype.is_just = function () { return true; }; /** * @author fenris */ class_just.prototype.cull = function () { return this.value; }; /** * @author fenris */ class_just.prototype.toString = function () { var content = instance_show(this.value); return "<+ " + content + " +>"; }; /** * @author fenris */ class_just.prototype.distinguish = function (action_just, action_nothing) { if (action_nothing === void 0) { action_nothing = function () { }; } action_just(this.value); }; /** * @author fenris */ class_just.prototype.propagate = function (action) { return action(this.value); }; return class_just; }(class_maybe)); /* This file is part of »bacterio-plankton:base«. Copyright 2016-2021 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' <info@greenscale.de> »bacterio-plankton:base« 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:base« 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:base«. If not, see <http://www.gnu.org/licenses/>. */ /** * @author frac */ var class_error = /** @class */ (function (_super) { __extends(class_error, _super); /** * @author frac */ function class_error(message, suberrors) { if (suberrors === void 0) { suberrors = []; } var _this = _super.call(this, message) || this; _this.suberrors = suberrors; _this.mess = message; return _this; } /** * @override * @author frac */ class_error.prototype.toString = function () { return ( /*super.toString()*/this.mess + " " + ("[" + this.suberrors.map(function (x) { return x.toString(); }).join(",") + "]")); }; return class_error; }(Error));