From 7d8a4de1abe5cfdc93e42e658061d49de0df3f8d Mon Sep 17 00:00:00 2001 From: Fenris Wolf Date: Thu, 26 Sep 2024 10:52:11 +0200 Subject: [PATCH] [upd] plankton --- lib/plankton/plankton.d.ts | 298 ++++++------ lib/plankton/plankton.js | 962 ++++++++++++++++++------------------- tools/update-plankton | 1 + 3 files changed, 631 insertions(+), 630 deletions(-) diff --git a/lib/plankton/plankton.d.ts b/lib/plankton/plankton.d.ts index ed0937f..da526cf 100644 --- a/lib/plankton/plankton.d.ts +++ b/lib/plankton/plankton.d.ts @@ -1916,6 +1916,155 @@ declare namespace lib_plankton.storage.localstorage { }[]>; } } +declare namespace lib_plankton.map { + /** + */ + type type_pair = { + key: type_key; + value: type_value; + }; + /** + * @author fenris + */ + type type_map = { + size: (() => int); + has: ((key: type_key) => boolean); + get: ((key: type_key, fallback?: lib_plankton.pod.type_pod) => type_value); + set: ((key: type_key, value: type_value) => void); + delete: ((key: type_key) => void); + iterate: ((procedure: ((value: type_value, key?: type_key) => void)) => void); + }; +} +declare namespace lib_plankton.map { + /** + */ + function clear(map: type_map): void; + /** + */ + function keys(map: type_map): Array; + /** + */ + function values(map: type_map): Array; + /** + */ + function dump(map: type_map): Array>; + /** + */ + function show(map: type_map, options?: { + show_key?: ((key: type_key) => string); + show_value?: ((value: type_value) => string); + }): string; +} +declare namespace lib_plankton.map.simplemap { + /** + */ + type type_subject = { + data: Record; + }; + /** + */ + function make(options?: { + data?: Record; + }): type_subject; + /** + */ + function size(subject: type_subject): int; + /** + */ + function has(subject: type_subject, key: string): boolean; + /** + */ + function get_safe(subject: type_subject, key: string): lib_plankton.pod.type_pod; + /** + */ + function get(subject: type_subject, key: string, fallback?: lib_plankton.pod.type_pod): type_value; + /** + */ + function set(subject: type_subject, key: string, value: type_value): void; + /** + */ + function delete_(subject: type_subject, key: string): void; + /** + */ + function iterate(subject: type_subject, procedure: ((value?: type_value, key?: string) => void)): void; + /** + */ + function implementation_map(subject: type_subject): type_map; +} +declare namespace lib_plankton.map.hashmap { + /** + * we base the hashmap on a simplemap, whos keys are the hashes and whos values are the key/value-pairs + */ + type type_subject = { + hashing: ((key: type_key) => string); + core: lib_plankton.map.simplemap.type_subject>; + }; + /** + */ + function make(hashing: ((key: type_key) => string), options?: { + pairs?: Array>; + }): type_subject; + /** + */ + function size(subject: type_subject): int; + /** + */ + function has(subject: type_subject, key: type_key): boolean; + /** + */ + function get(subject: type_subject, key: type_key, fallback?: lib_plankton.pod.type_pod): type_value; + /** + */ + function set(subject: type_subject, key: type_key, value: type_value): void; + /** + */ + function delete_(subject: type_subject, key: type_key): void; + /** + */ + function iterate(subject: type_subject, procedure: ((value?: type_value, key?: type_key) => void)): void; + /** + */ + function implementation_map(subject: type_subject): type_map; +} +declare namespace lib_plankton.map.collatemap { + /** + */ + type type_collation = ((key1: type_key, key2: type_key) => boolean); + /** + */ + export type type_subject = { + collation: type_collation; + pairs: Array>; + }; + /** + */ + export function make(collation: type_collation, options?: { + pairs?: Array>; + }): type_subject; + /** + */ + export function size(subject: type_subject): int; + /** + */ + export function has(subject: type_subject, key: type_key): boolean; + /** + * @todo use .find + */ + export function get(subject: type_subject, key: type_key, fallback?: lib_plankton.pod.type_pod): type_value; + /** + */ + export function set(subject: type_subject, key: type_key, value: type_value): void; + /** + */ + export function delete_(subject: type_subject, key: type_key): void; + /** + */ + export function iterate(subject: type_subject, function_: ((value?: type_value, key?: type_key) => void)): void; + /** + */ + export function implementation_map(subject: type_subject): type_map; + export {}; +} declare namespace lib_plankton.complex { /** * @author fenris @@ -2676,155 +2825,6 @@ declare namespace lib_plankton.xml { compile(depth?: int): string; } } -declare namespace lib_plankton.map { - /** - */ - type type_pair = { - key: type_key; - value: type_value; - }; - /** - * @author fenris - */ - type type_map = { - size: (() => int); - has: ((key: type_key) => boolean); - get: ((key: type_key, fallback?: lib_plankton.pod.type_pod) => type_value); - set: ((key: type_key, value: type_value) => void); - delete: ((key: type_key) => void); - iterate: ((procedure: ((value: type_value, key?: type_key) => void)) => void); - }; -} -declare namespace lib_plankton.map { - /** - */ - function clear(map: type_map): void; - /** - */ - function keys(map: type_map): Array; - /** - */ - function values(map: type_map): Array; - /** - */ - function dump(map: type_map): Array>; - /** - */ - function show(map: type_map, options?: { - show_key?: ((key: type_key) => string); - show_value?: ((value: type_value) => string); - }): string; -} -declare namespace lib_plankton.map.simplemap { - /** - */ - type type_subject = { - data: Record; - }; - /** - */ - function make(options?: { - data?: Record; - }): type_subject; - /** - */ - function size(subject: type_subject): int; - /** - */ - function has(subject: type_subject, key: string): boolean; - /** - */ - function get_safe(subject: type_subject, key: string): lib_plankton.pod.type_pod; - /** - */ - function get(subject: type_subject, key: string, fallback?: lib_plankton.pod.type_pod): type_value; - /** - */ - function set(subject: type_subject, key: string, value: type_value): void; - /** - */ - function delete_(subject: type_subject, key: string): void; - /** - */ - function iterate(subject: type_subject, procedure: ((value?: type_value, key?: string) => void)): void; - /** - */ - function implementation_map(subject: type_subject): type_map; -} -declare namespace lib_plankton.map.hashmap { - /** - * we base the hashmap on a simplemap, whos keys are the hashes and whos values are the key/value-pairs - */ - type type_subject = { - hashing: ((key: type_key) => string); - core: lib_plankton.map.simplemap.type_subject>; - }; - /** - */ - function make(hashing: ((key: type_key) => string), options?: { - pairs?: Array>; - }): type_subject; - /** - */ - function size(subject: type_subject): int; - /** - */ - function has(subject: type_subject, key: type_key): boolean; - /** - */ - function get(subject: type_subject, key: type_key, fallback?: lib_plankton.pod.type_pod): type_value; - /** - */ - function set(subject: type_subject, key: type_key, value: type_value): void; - /** - */ - function delete_(subject: type_subject, key: type_key): void; - /** - */ - function iterate(subject: type_subject, procedure: ((value?: type_value, key?: type_key) => void)): void; - /** - */ - function implementation_map(subject: type_subject): type_map; -} -declare namespace lib_plankton.map.collatemap { - /** - */ - type type_collation = ((key1: type_key, key2: type_key) => boolean); - /** - */ - export type type_subject = { - collation: type_collation; - pairs: Array>; - }; - /** - */ - export function make(collation: type_collation, options?: { - pairs?: Array>; - }): type_subject; - /** - */ - export function size(subject: type_subject): int; - /** - */ - export function has(subject: type_subject, key: type_key): boolean; - /** - * @todo use .find - */ - export function get(subject: type_subject, key: type_key, fallback?: lib_plankton.pod.type_pod): type_value; - /** - */ - export function set(subject: type_subject, key: type_key, value: type_value): void; - /** - */ - export function delete_(subject: type_subject, key: type_key): void; - /** - */ - export function iterate(subject: type_subject, function_: ((value?: type_value, key?: type_key) => void)): void; - /** - */ - export function implementation_map(subject: type_subject): type_map; - export {}; -} declare namespace lib_plankton.http { /** * @author fenris diff --git a/lib/plankton/plankton.js b/lib/plankton/plankton.js index f314f8c..a6cbda5 100644 --- a/lib/plankton/plankton.js +++ b/lib/plankton/plankton.js @@ -5514,6 +5514,486 @@ var lib_plankton; })(storage = lib_plankton.storage || (lib_plankton.storage = {})); })(lib_plankton || (lib_plankton = {})); /* +This file is part of »bacterio-plankton:map«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:map« 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:map« 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:map«. If not, see . + */ +/* +This file is part of »bacterio-plankton:map«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:map« 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:map« 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:map«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var map; + (function (map_1) { + /** + */ + function clear(map) { + map.iterate(function (value, key) { + map["delete"](key); + }); + } + map_1.clear = clear; + /** + */ + function keys(map) { + var keys = []; + map.iterate(function (value, key) { + keys.push(key); + }); + return keys; + } + map_1.keys = keys; + /** + */ + function values(map) { + var values = []; + map.iterate(function (value, key) { + values.push(value); + }); + return values; + } + map_1.values = values; + /** + */ + function dump(map) { + var pairs = []; + map.iterate(function (value, key) { + pairs.push({ "key": key, "value": value }); + }); + return pairs; + } + map_1.dump = dump; + /** + */ + function show(map, options) { + if (options === void 0) { options = {}; } + options = Object.assign({ + "show_key": instance_show, + "show_value": instance_show + }, options); + return ("[" + + + (dump(map) + .map(function (_a) { + var key = _a["key"], value = _a["value"]; + return (options.show_key(key) + + + " -> " + + + options.show_value(value)); + }) + .join(", ")) + + + "]"); + } + map_1.show = show; + })(map = lib_plankton.map || (lib_plankton.map = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:map«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:map« 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:map« 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:map«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var map; + (function (map) { + var simplemap; + (function (simplemap) { + /** + */ + function make(options) { + if (options === void 0) { options = {}; } + options = Object.assign({ + "data": {} + }, options); + return { + "data": options.data + }; + } + simplemap.make = make; + /** + */ + function size(subject) { + return Object.keys(subject.data).length; + } + simplemap.size = size; + /** + */ + function has(subject, key) { + return (key in subject.data); + } + simplemap.has = has; + /** + */ + function get_safe(subject, key) { + if (key in subject.data) { + return lib_plankton.pod.make_filled(subject.data[key]); + } + else { + return lib_plankton.pod.make_empty(); + } + } + simplemap.get_safe = get_safe; + /** + */ + function get(subject, key, fallback) { + if (fallback === void 0) { fallback = lib_plankton.pod.make_empty(); } + if (key in subject.data) { + return subject.data[key]; + } + else { + if (!lib_plankton.pod.is_filled(fallback)) { + throw (new Error("key not found")); + } + else { + return lib_plankton.pod.cull(fallback); + } + } + } + simplemap.get = get; + /** + */ + function set(subject, key, value) { + subject.data[key] = value; + } + simplemap.set = set; + /** + */ + function delete_(subject, key) { + delete subject.data[key]; + } + simplemap.delete_ = delete_; + /** + */ + function iterate(subject, procedure) { + Object.entries(subject.data).forEach(function (_a) { + var key = _a[0], value = _a[1]; + procedure(value, key); + }); + } + simplemap.iterate = iterate; + /** + */ + function implementation_map(subject) { + return { + "size": function () { return size(subject); }, + "has": function (key) { return has(subject, key); }, + "get": function (key, fallback) { return get(subject, key, fallback); }, + "set": function (key, value) { return set(subject, key, value); }, + "delete": function (key) { return delete_(subject, key); }, + "iterate": function (function_) { return iterate(subject, function_); } + }; + } + simplemap.implementation_map = implementation_map; + })(simplemap = map.simplemap || (map.simplemap = {})); + })(map = lib_plankton.map || (lib_plankton.map = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:map«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:map« 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:map« 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:map«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var map; + (function (map) { + var hashmap; + (function (hashmap) { + /** + */ + function make(hashing, options) { + if (options === void 0) { options = {}; } + options = Object.assign({ + "pairs": [] + }, options); + var subject = { + "hashing": hashing, + "core": lib_plankton.map.simplemap.make({}) + }; + options.pairs.forEach(function (pair) { + set(subject, pair.key, pair.value); + }); + return subject; + } + hashmap.make = make; + /** + */ + function size(subject) { + return lib_plankton.map.simplemap.size(subject.core); + } + hashmap.size = size; + /** + */ + function has(subject, key) { + return lib_plankton.map.simplemap.has(subject.core, subject.hashing(key)); + } + hashmap.has = has; + /** + */ + function get(subject, key, fallback) { + if (fallback === void 0) { fallback = lib_plankton.pod.make_empty(); } + /* + we have to adjust the fallback argument, so that it can be used in our underlying simplemap core + therefore we pack the value together with any key as dummy + */ + return (lib_plankton.map.simplemap.get(subject.core, subject.hashing(key), lib_plankton.pod.propagate(fallback, function (value) { return ({ + "key": key, + "value": value + }); })) + .value); + } + hashmap.get = get; + /** + */ + function set(subject, key, value) { + var key_ = subject.hashing(key); + return (lib_plankton.map.simplemap.set(subject.core, key_, { "key": key, "value": value })); + } + hashmap.set = set; + /** + */ + function delete_(subject, key) { + return (lib_plankton.map.simplemap.delete_(subject.core, subject.hashing(key))); + } + hashmap.delete_ = delete_; + /** + */ + function iterate(subject, procedure) { + return (lib_plankton.map.simplemap.iterate(subject.core, function (_a, key_) { + var key = _a["key"], value = _a["value"]; + procedure(value, key); + })); + } + hashmap.iterate = iterate; + /** + */ + function implementation_map(subject) { + return { + "size": function () { return size(subject); }, + "has": function (key) { return has(subject, key); }, + "get": function (key, fallback) { return get(subject, key, fallback); }, + "set": function (key, value) { return set(subject, key, value); }, + "delete": function (key) { return delete_(subject, key); }, + "iterate": function (procedure) { return iterate(subject, procedure); } + }; + } + hashmap.implementation_map = implementation_map; + })(hashmap = map.hashmap || (map.hashmap = {})); + })(map = lib_plankton.map || (lib_plankton.map = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:map«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:map« 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:map« 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 +3GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:map«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var map; + (function (map) { + var collatemap; + (function (collatemap) { + /** + */ + function make(collation, options) { + if (options === void 0) { options = {}; } + options = Object.assign({ + "pairs": [] + }, options); + var subject = { + "collation": collation, + "pairs": [] + }; + options.pairs.forEach(function (pair) { + set(subject, pair.key, pair.value); + }); + return subject; + } + collatemap.make = make; + /** + */ + function size(subject) { + return subject.pairs.length; + } + collatemap.size = size; + /** + */ + function has(subject, key) { + return (subject.pairs.some(function (pair) { return subject.collation(key, pair.key); })); + } + collatemap.has = has; + /** + * @todo use .find + */ + function get(subject, key, fallback) { + var value; + var found = (subject.pairs + .some(function (pair) { + if (subject.collation(key, pair.key)) { + value = pair.value; + return true; + } + else { + return false; + } + })); + if (found) { + return value; + } + else { + if (!lib_plankton.pod.is_filled(fallback)) { + throw (new Error("key not found")); + } + else { + return lib_plankton.pod.cull(fallback); + } + } + } + collatemap.get = get; + /** + */ + function set(subject, key, value) { + var found = (subject.pairs + .some(function (pair) { + if (subject.collation(key, pair.key)) { + // pair.value = value; + return true; + } + else { + return false; + } + })); + if (found) { + // nothing + } + else { + subject.pairs.push({ + "key": key, + "value": value + }); + } + } + collatemap.set = set; + /** + */ + function delete_(subject, key) { + var index; + var found = (subject.pairs + .some(function (pair, index_) { + if (subject.collation(key, pair.key)) { + index = index_; + return true; + } + else { + return false; + } + })); + if (found) { + subject.pairs.splice(index, 1); + } + else { + // do nothing + } + } + collatemap.delete_ = delete_; + /** + */ + function iterate(subject, function_) { + subject.pairs + .forEach(function (pair) { + function_(pair.value, pair.key); + }); + } + collatemap.iterate = iterate; + /** + */ + function implementation_map(subject) { + return { + "size": function () { return size(subject); }, + "has": function (key) { return has(subject, key); }, + "get": function (key, fallback) { return get(subject, key, fallback); }, + "set": function (key, value) { return set(subject, key, value); }, + "delete": function (key) { return delete_(subject, key); }, + "iterate": function (function_) { return iterate(subject, function_); } + }; + } + collatemap.implementation_map = implementation_map; + })(collatemap = map.collatemap || (map.collatemap = {})); + })(map = lib_plankton.map || (lib_plankton.map = {})); +})(lib_plankton || (lib_plankton = {})); +/* This file is part of »bacterio-plankton:complex«. Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' @@ -7095,486 +7575,6 @@ var lib_plankton; })(xml = lib_plankton.xml || (lib_plankton.xml = {})); })(lib_plankton || (lib_plankton = {})); /* -This file is part of »bacterio-plankton:map«. - -Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:map« 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:map« 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:map«. If not, see . - */ -/* -This file is part of »bacterio-plankton:map«. - -Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:map« 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:map« 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:map«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var map; - (function (map_1) { - /** - */ - function clear(map) { - map.iterate(function (value, key) { - map["delete"](key); - }); - } - map_1.clear = clear; - /** - */ - function keys(map) { - var keys = []; - map.iterate(function (value, key) { - keys.push(key); - }); - return keys; - } - map_1.keys = keys; - /** - */ - function values(map) { - var values = []; - map.iterate(function (value, key) { - values.push(value); - }); - return values; - } - map_1.values = values; - /** - */ - function dump(map) { - var pairs = []; - map.iterate(function (value, key) { - pairs.push({ "key": key, "value": value }); - }); - return pairs; - } - map_1.dump = dump; - /** - */ - function show(map, options) { - if (options === void 0) { options = {}; } - options = Object.assign({ - "show_key": instance_show, - "show_value": instance_show - }, options); - return ("[" - + - (dump(map) - .map(function (_a) { - var key = _a["key"], value = _a["value"]; - return (options.show_key(key) - + - " -> " - + - options.show_value(value)); - }) - .join(", ")) - + - "]"); - } - map_1.show = show; - })(map = lib_plankton.map || (lib_plankton.map = {})); -})(lib_plankton || (lib_plankton = {})); -/* -This file is part of »bacterio-plankton:map«. - -Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:map« 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:map« 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:map«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var map; - (function (map) { - var simplemap; - (function (simplemap) { - /** - */ - function make(options) { - if (options === void 0) { options = {}; } - options = Object.assign({ - "data": {} - }, options); - return { - "data": options.data - }; - } - simplemap.make = make; - /** - */ - function size(subject) { - return Object.keys(subject.data).length; - } - simplemap.size = size; - /** - */ - function has(subject, key) { - return (key in subject.data); - } - simplemap.has = has; - /** - */ - function get_safe(subject, key) { - if (key in subject.data) { - return lib_plankton.pod.make_filled(subject.data[key]); - } - else { - return lib_plankton.pod.make_empty(); - } - } - simplemap.get_safe = get_safe; - /** - */ - function get(subject, key, fallback) { - if (fallback === void 0) { fallback = lib_plankton.pod.make_empty(); } - if (key in subject.data) { - return subject.data[key]; - } - else { - if (!lib_plankton.pod.is_filled(fallback)) { - throw (new Error("key not found")); - } - else { - return lib_plankton.pod.cull(fallback); - } - } - } - simplemap.get = get; - /** - */ - function set(subject, key, value) { - subject.data[key] = value; - } - simplemap.set = set; - /** - */ - function delete_(subject, key) { - delete subject.data[key]; - } - simplemap.delete_ = delete_; - /** - */ - function iterate(subject, procedure) { - Object.entries(subject.data).forEach(function (_a) { - var key = _a[0], value = _a[1]; - procedure(value, key); - }); - } - simplemap.iterate = iterate; - /** - */ - function implementation_map(subject) { - return { - "size": function () { return size(subject); }, - "has": function (key) { return has(subject, key); }, - "get": function (key, fallback) { return get(subject, key, fallback); }, - "set": function (key, value) { return set(subject, key, value); }, - "delete": function (key) { return delete_(subject, key); }, - "iterate": function (function_) { return iterate(subject, function_); } - }; - } - simplemap.implementation_map = implementation_map; - })(simplemap = map.simplemap || (map.simplemap = {})); - })(map = lib_plankton.map || (lib_plankton.map = {})); -})(lib_plankton || (lib_plankton = {})); -/* -This file is part of »bacterio-plankton:map«. - -Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:map« 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:map« 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:map«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var map; - (function (map) { - var hashmap; - (function (hashmap) { - /** - */ - function make(hashing, options) { - if (options === void 0) { options = {}; } - options = Object.assign({ - "pairs": [] - }, options); - var subject = { - "hashing": hashing, - "core": lib_plankton.map.simplemap.make({}) - }; - options.pairs.forEach(function (pair) { - set(subject, pair.key, pair.value); - }); - return subject; - } - hashmap.make = make; - /** - */ - function size(subject) { - return lib_plankton.map.simplemap.size(subject.core); - } - hashmap.size = size; - /** - */ - function has(subject, key) { - return lib_plankton.map.simplemap.has(subject.core, subject.hashing(key)); - } - hashmap.has = has; - /** - */ - function get(subject, key, fallback) { - if (fallback === void 0) { fallback = lib_plankton.pod.make_empty(); } - /* - we have to adjust the fallback argument, so that it can be used in our underlying simplemap core - therefore we pack the value together with any key as dummy - */ - return (lib_plankton.map.simplemap.get(subject.core, subject.hashing(key), lib_plankton.pod.propagate(fallback, function (value) { return ({ - "key": key, - "value": value - }); })) - .value); - } - hashmap.get = get; - /** - */ - function set(subject, key, value) { - var key_ = subject.hashing(key); - return (lib_plankton.map.simplemap.set(subject.core, key_, { "key": key, "value": value })); - } - hashmap.set = set; - /** - */ - function delete_(subject, key) { - return (lib_plankton.map.simplemap.delete_(subject.core, subject.hashing(key))); - } - hashmap.delete_ = delete_; - /** - */ - function iterate(subject, procedure) { - return (lib_plankton.map.simplemap.iterate(subject.core, function (_a, key_) { - var key = _a["key"], value = _a["value"]; - procedure(value, key); - })); - } - hashmap.iterate = iterate; - /** - */ - function implementation_map(subject) { - return { - "size": function () { return size(subject); }, - "has": function (key) { return has(subject, key); }, - "get": function (key, fallback) { return get(subject, key, fallback); }, - "set": function (key, value) { return set(subject, key, value); }, - "delete": function (key) { return delete_(subject, key); }, - "iterate": function (procedure) { return iterate(subject, procedure); } - }; - } - hashmap.implementation_map = implementation_map; - })(hashmap = map.hashmap || (map.hashmap = {})); - })(map = lib_plankton.map || (lib_plankton.map = {})); -})(lib_plankton || (lib_plankton = {})); -/* -This file is part of »bacterio-plankton:map«. - -Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:map« 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:map« 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 -3GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with »bacterio-plankton:map«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var map; - (function (map) { - var collatemap; - (function (collatemap) { - /** - */ - function make(collation, options) { - if (options === void 0) { options = {}; } - options = Object.assign({ - "pairs": [] - }, options); - var subject = { - "collation": collation, - "pairs": [] - }; - options.pairs.forEach(function (pair) { - set(subject, pair.key, pair.value); - }); - return subject; - } - collatemap.make = make; - /** - */ - function size(subject) { - return subject.pairs.length; - } - collatemap.size = size; - /** - */ - function has(subject, key) { - return (subject.pairs.some(function (pair) { return subject.collation(key, pair.key); })); - } - collatemap.has = has; - /** - * @todo use .find - */ - function get(subject, key, fallback) { - var value; - var found = (subject.pairs - .some(function (pair) { - if (subject.collation(key, pair.key)) { - value = pair.value; - return true; - } - else { - return false; - } - })); - if (found) { - return value; - } - else { - if (!lib_plankton.pod.is_filled(fallback)) { - throw (new Error("key not found")); - } - else { - return lib_plankton.pod.cull(fallback); - } - } - } - collatemap.get = get; - /** - */ - function set(subject, key, value) { - var found = (subject.pairs - .some(function (pair) { - if (subject.collation(key, pair.key)) { - // pair.value = value; - return true; - } - else { - return false; - } - })); - if (found) { - // nothing - } - else { - subject.pairs.push({ - "key": key, - "value": value - }); - } - } - collatemap.set = set; - /** - */ - function delete_(subject, key) { - var index; - var found = (subject.pairs - .some(function (pair, index_) { - if (subject.collation(key, pair.key)) { - index = index_; - return true; - } - else { - return false; - } - })); - if (found) { - subject.pairs.splice(index, 1); - } - else { - // do nothing - } - } - collatemap.delete_ = delete_; - /** - */ - function iterate(subject, function_) { - subject.pairs - .forEach(function (pair) { - function_(pair.value, pair.key); - }); - } - collatemap.iterate = iterate; - /** - */ - function implementation_map(subject) { - return { - "size": function () { return size(subject); }, - "has": function (key) { return has(subject, key); }, - "get": function (key, fallback) { return get(subject, key, fallback); }, - "set": function (key, value) { return set(subject, key, value); }, - "delete": function (key) { return delete_(subject, key); }, - "iterate": function (function_) { return iterate(subject, function_); } - }; - } - collatemap.implementation_map = implementation_map; - })(collatemap = map.collatemap || (map.collatemap = {})); - })(map = lib_plankton.map || (lib_plankton.map = {})); -})(lib_plankton || (lib_plankton = {})); -/* This file is part of »bacterio-plankton:http«. Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' @@ -8207,7 +8207,7 @@ var lib_plankton; // query { if (url.query !== null) { - result += ("?" + encodeURI(url.query)); + result += ("?" + url.query); } } // hash diff --git a/tools/update-plankton b/tools/update-plankton index e9b5412..fc6c0bf 100755 --- a/tools/update-plankton +++ b/tools/update-plankton @@ -12,6 +12,7 @@ modules="${modules} storage" modules="${modules} file" modules="${modules} json" modules="${modules} string" +modules="${modules} map" modules="${modules} color" modules="${modules} xml" modules="${modules} map"