[upd] plankton
This commit is contained in:
parent
d980e25156
commit
7d8a4de1ab
3 changed files with 631 additions and 630 deletions
298
lib/plankton/plankton.d.ts
vendored
298
lib/plankton/plankton.d.ts
vendored
|
@ -1916,6 +1916,155 @@ declare namespace lib_plankton.storage.localstorage {
|
||||||
}[]>;
|
}[]>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
declare namespace lib_plankton.map {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
type type_pair<type_key, type_value> = {
|
||||||
|
key: type_key;
|
||||||
|
value: type_value;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* @author fenris
|
||||||
|
*/
|
||||||
|
type type_map<type_key, type_value> = {
|
||||||
|
size: (() => int);
|
||||||
|
has: ((key: type_key) => boolean);
|
||||||
|
get: ((key: type_key, fallback?: lib_plankton.pod.type_pod<type_value>) => 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<type_key, type_value>(map: type_map<type_key, type_value>): void;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function keys<type_key, type_value>(map: type_map<type_key, type_value>): Array<type_key>;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function values<type_key, type_value>(map: type_map<type_key, type_value>): Array<type_value>;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function dump<type_key, type_value>(map: type_map<type_key, type_value>): Array<type_pair<type_key, type_value>>;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function show<type_key, type_value>(map: type_map<type_key, type_value>, options?: {
|
||||||
|
show_key?: ((key: type_key) => string);
|
||||||
|
show_value?: ((value: type_value) => string);
|
||||||
|
}): string;
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.map.simplemap {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
type type_subject<type_value> = {
|
||||||
|
data: Record<string, type_value>;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function make<type_value>(options?: {
|
||||||
|
data?: Record<string, type_value>;
|
||||||
|
}): type_subject<type_value>;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function size<type_value>(subject: type_subject<type_value>): int;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function has<type_value>(subject: type_subject<type_value>, key: string): boolean;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function get_safe<type_value>(subject: type_subject<type_value>, key: string): lib_plankton.pod.type_pod<type_value>;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function get<type_value>(subject: type_subject<type_value>, key: string, fallback?: lib_plankton.pod.type_pod<type_value>): type_value;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function set<type_value>(subject: type_subject<type_value>, key: string, value: type_value): void;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function delete_<type_value>(subject: type_subject<type_value>, key: string): void;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function iterate<type_value>(subject: type_subject<type_value>, procedure: ((value?: type_value, key?: string) => void)): void;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function implementation_map<type_value>(subject: type_subject<type_value>): type_map<string, type_value>;
|
||||||
|
}
|
||||||
|
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<type_key, type_value> = {
|
||||||
|
hashing: ((key: type_key) => string);
|
||||||
|
core: lib_plankton.map.simplemap.type_subject<type_pair<type_key, type_value>>;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function make<type_key, type_value>(hashing: ((key: type_key) => string), options?: {
|
||||||
|
pairs?: Array<type_pair<type_key, type_value>>;
|
||||||
|
}): type_subject<type_key, type_value>;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function size<type_key, type_value>(subject: type_subject<type_key, type_value>): int;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function has<type_key, type_value>(subject: type_subject<type_key, type_value>, key: type_key): boolean;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function get<type_key, type_value>(subject: type_subject<type_key, type_value>, key: type_key, fallback?: lib_plankton.pod.type_pod<type_value>): type_value;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function set<type_key, type_value>(subject: type_subject<type_key, type_value>, key: type_key, value: type_value): void;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function delete_<type_key, type_value>(subject: type_subject<type_key, type_value>, key: type_key): void;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function iterate<type_key, type_value>(subject: type_subject<type_key, type_value>, procedure: ((value?: type_value, key?: type_key) => void)): void;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function implementation_map<type_key, type_value>(subject: type_subject<type_key, type_value>): type_map<type_key, type_value>;
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.map.collatemap {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
type type_collation<type_key> = ((key1: type_key, key2: type_key) => boolean);
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
export type type_subject<type_key, type_value> = {
|
||||||
|
collation: type_collation<type_key>;
|
||||||
|
pairs: Array<type_pair<type_key, type_value>>;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
export function make<type_key, type_value>(collation: type_collation<type_key>, options?: {
|
||||||
|
pairs?: Array<type_pair<type_key, type_value>>;
|
||||||
|
}): type_subject<type_key, type_value>;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
export function size<type_key, type_value>(subject: type_subject<type_key, type_value>): int;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
export function has<type_key, type_value>(subject: type_subject<type_key, type_value>, key: type_key): boolean;
|
||||||
|
/**
|
||||||
|
* @todo use .find
|
||||||
|
*/
|
||||||
|
export function get<type_key, type_value>(subject: type_subject<type_key, type_value>, key: type_key, fallback?: lib_plankton.pod.type_pod<type_value>): type_value;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
export function set<type_key, type_value>(subject: type_subject<type_key, type_value>, key: type_key, value: type_value): void;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
export function delete_<type_key, type_value>(subject: type_subject<type_key, type_value>, key: type_key): void;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
export function iterate<type_key, type_value>(subject: type_subject<type_key, type_value>, function_: ((value?: type_value, key?: type_key) => void)): void;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
export function implementation_map<type_key, type_value>(subject: type_subject<type_key, type_value>): type_map<type_key, type_value>;
|
||||||
|
export {};
|
||||||
|
}
|
||||||
declare namespace lib_plankton.complex {
|
declare namespace lib_plankton.complex {
|
||||||
/**
|
/**
|
||||||
* @author fenris
|
* @author fenris
|
||||||
|
@ -2676,155 +2825,6 @@ declare namespace lib_plankton.xml {
|
||||||
compile(depth?: int): string;
|
compile(depth?: int): string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare namespace lib_plankton.map {
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
type type_pair<type_key, type_value> = {
|
|
||||||
key: type_key;
|
|
||||||
value: type_value;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
type type_map<type_key, type_value> = {
|
|
||||||
size: (() => int);
|
|
||||||
has: ((key: type_key) => boolean);
|
|
||||||
get: ((key: type_key, fallback?: lib_plankton.pod.type_pod<type_value>) => 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<type_key, type_value>(map: type_map<type_key, type_value>): void;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function keys<type_key, type_value>(map: type_map<type_key, type_value>): Array<type_key>;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function values<type_key, type_value>(map: type_map<type_key, type_value>): Array<type_value>;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function dump<type_key, type_value>(map: type_map<type_key, type_value>): Array<type_pair<type_key, type_value>>;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function show<type_key, type_value>(map: type_map<type_key, type_value>, options?: {
|
|
||||||
show_key?: ((key: type_key) => string);
|
|
||||||
show_value?: ((value: type_value) => string);
|
|
||||||
}): string;
|
|
||||||
}
|
|
||||||
declare namespace lib_plankton.map.simplemap {
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
type type_subject<type_value> = {
|
|
||||||
data: Record<string, type_value>;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function make<type_value>(options?: {
|
|
||||||
data?: Record<string, type_value>;
|
|
||||||
}): type_subject<type_value>;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function size<type_value>(subject: type_subject<type_value>): int;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function has<type_value>(subject: type_subject<type_value>, key: string): boolean;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function get_safe<type_value>(subject: type_subject<type_value>, key: string): lib_plankton.pod.type_pod<type_value>;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function get<type_value>(subject: type_subject<type_value>, key: string, fallback?: lib_plankton.pod.type_pod<type_value>): type_value;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function set<type_value>(subject: type_subject<type_value>, key: string, value: type_value): void;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function delete_<type_value>(subject: type_subject<type_value>, key: string): void;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function iterate<type_value>(subject: type_subject<type_value>, procedure: ((value?: type_value, key?: string) => void)): void;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function implementation_map<type_value>(subject: type_subject<type_value>): type_map<string, type_value>;
|
|
||||||
}
|
|
||||||
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<type_key, type_value> = {
|
|
||||||
hashing: ((key: type_key) => string);
|
|
||||||
core: lib_plankton.map.simplemap.type_subject<type_pair<type_key, type_value>>;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function make<type_key, type_value>(hashing: ((key: type_key) => string), options?: {
|
|
||||||
pairs?: Array<type_pair<type_key, type_value>>;
|
|
||||||
}): type_subject<type_key, type_value>;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function size<type_key, type_value>(subject: type_subject<type_key, type_value>): int;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function has<type_key, type_value>(subject: type_subject<type_key, type_value>, key: type_key): boolean;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function get<type_key, type_value>(subject: type_subject<type_key, type_value>, key: type_key, fallback?: lib_plankton.pod.type_pod<type_value>): type_value;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function set<type_key, type_value>(subject: type_subject<type_key, type_value>, key: type_key, value: type_value): void;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function delete_<type_key, type_value>(subject: type_subject<type_key, type_value>, key: type_key): void;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function iterate<type_key, type_value>(subject: type_subject<type_key, type_value>, procedure: ((value?: type_value, key?: type_key) => void)): void;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function implementation_map<type_key, type_value>(subject: type_subject<type_key, type_value>): type_map<type_key, type_value>;
|
|
||||||
}
|
|
||||||
declare namespace lib_plankton.map.collatemap {
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
type type_collation<type_key> = ((key1: type_key, key2: type_key) => boolean);
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
export type type_subject<type_key, type_value> = {
|
|
||||||
collation: type_collation<type_key>;
|
|
||||||
pairs: Array<type_pair<type_key, type_value>>;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
export function make<type_key, type_value>(collation: type_collation<type_key>, options?: {
|
|
||||||
pairs?: Array<type_pair<type_key, type_value>>;
|
|
||||||
}): type_subject<type_key, type_value>;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
export function size<type_key, type_value>(subject: type_subject<type_key, type_value>): int;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
export function has<type_key, type_value>(subject: type_subject<type_key, type_value>, key: type_key): boolean;
|
|
||||||
/**
|
|
||||||
* @todo use .find
|
|
||||||
*/
|
|
||||||
export function get<type_key, type_value>(subject: type_subject<type_key, type_value>, key: type_key, fallback?: lib_plankton.pod.type_pod<type_value>): type_value;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
export function set<type_key, type_value>(subject: type_subject<type_key, type_value>, key: type_key, value: type_value): void;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
export function delete_<type_key, type_value>(subject: type_subject<type_key, type_value>, key: type_key): void;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
export function iterate<type_key, type_value>(subject: type_subject<type_key, type_value>, function_: ((value?: type_value, key?: type_key) => void)): void;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
export function implementation_map<type_key, type_value>(subject: type_subject<type_key, type_value>): type_map<type_key, type_value>;
|
|
||||||
export {};
|
|
||||||
}
|
|
||||||
declare namespace lib_plankton.http {
|
declare namespace lib_plankton.http {
|
||||||
/**
|
/**
|
||||||
* @author fenris <frass@greenscale.de>
|
* @author fenris <frass@greenscale.de>
|
||||||
|
|
|
@ -5514,6 +5514,486 @@ var lib_plankton;
|
||||||
})(storage = lib_plankton.storage || (lib_plankton.storage = {}));
|
})(storage = lib_plankton.storage || (lib_plankton.storage = {}));
|
||||||
})(lib_plankton || (lib_plankton = {}));
|
})(lib_plankton || (lib_plankton = {}));
|
||||||
/*
|
/*
|
||||||
|
This file is part of »bacterio-plankton:map«.
|
||||||
|
|
||||||
|
Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
|
||||||
|
<info@greenscale.de>
|
||||||
|
|
||||||
|
»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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
This file is part of »bacterio-plankton:map«.
|
||||||
|
|
||||||
|
Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
|
||||||
|
<info@greenscale.de>
|
||||||
|
|
||||||
|
»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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
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'
|
||||||
|
<info@greenscale.de>
|
||||||
|
|
||||||
|
»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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
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'
|
||||||
|
<info@greenscale.de>
|
||||||
|
|
||||||
|
»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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
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'
|
||||||
|
<info@greenscale.de>
|
||||||
|
|
||||||
|
»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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
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«.
|
This file is part of »bacterio-plankton:complex«.
|
||||||
|
|
||||||
Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
|
Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
|
||||||
|
@ -7095,486 +7575,6 @@ var lib_plankton;
|
||||||
})(xml = lib_plankton.xml || (lib_plankton.xml = {}));
|
})(xml = lib_plankton.xml || (lib_plankton.xml = {}));
|
||||||
})(lib_plankton || (lib_plankton = {}));
|
})(lib_plankton || (lib_plankton = {}));
|
||||||
/*
|
/*
|
||||||
This file is part of »bacterio-plankton:map«.
|
|
||||||
|
|
||||||
Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
|
|
||||||
<info@greenscale.de>
|
|
||||||
|
|
||||||
»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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
This file is part of »bacterio-plankton:map«.
|
|
||||||
|
|
||||||
Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
|
|
||||||
<info@greenscale.de>
|
|
||||||
|
|
||||||
»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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
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'
|
|
||||||
<info@greenscale.de>
|
|
||||||
|
|
||||||
»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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
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'
|
|
||||||
<info@greenscale.de>
|
|
||||||
|
|
||||||
»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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
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'
|
|
||||||
<info@greenscale.de>
|
|
||||||
|
|
||||||
»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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
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«.
|
This file is part of »bacterio-plankton:http«.
|
||||||
|
|
||||||
Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
|
Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
|
||||||
|
@ -8207,7 +8207,7 @@ var lib_plankton;
|
||||||
// query
|
// query
|
||||||
{
|
{
|
||||||
if (url.query !== null) {
|
if (url.query !== null) {
|
||||||
result += ("?" + encodeURI(url.query));
|
result += ("?" + url.query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// hash
|
// hash
|
||||||
|
|
|
@ -12,6 +12,7 @@ modules="${modules} storage"
|
||||||
modules="${modules} file"
|
modules="${modules} file"
|
||||||
modules="${modules} json"
|
modules="${modules} json"
|
||||||
modules="${modules} string"
|
modules="${modules} string"
|
||||||
|
modules="${modules} map"
|
||||||
modules="${modules} color"
|
modules="${modules} color"
|
||||||
modules="${modules} xml"
|
modules="${modules} xml"
|
||||||
modules="${modules} map"
|
modules="${modules} map"
|
||||||
|
|
Loading…
Add table
Reference in a new issue