[upd] plankton
This commit is contained in:
parent
051ce5f76b
commit
2d19dd3d8a
333
lib/plankton/plankton.d.ts
vendored
333
lib/plankton/plankton.d.ts
vendored
|
|
@ -6,13 +6,28 @@ type int = number;
|
|||
* @author fenris
|
||||
*/
|
||||
type float = number;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
type type_date = {
|
||||
year: int;
|
||||
month: int;
|
||||
day: int;
|
||||
};
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
type type_time = {
|
||||
hours: int;
|
||||
minutes: int;
|
||||
seconds: int;
|
||||
hour: int;
|
||||
minute: int;
|
||||
second: int;
|
||||
};
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
type type_datetimeobject = {
|
||||
date: type_date;
|
||||
time: type_time;
|
||||
};
|
||||
declare var process: any;
|
||||
declare var require: any;
|
||||
|
|
@ -230,12 +245,12 @@ declare namespace lib_plankton.base {
|
|||
*
|
||||
* @author fenris
|
||||
*/
|
||||
function get_current_timestamp(rounded?: boolean): int;
|
||||
function get_current_timestamp(rounded?: boolean): float;
|
||||
/**
|
||||
*/
|
||||
function object_merge(core: Record<string, any>, mantle: Record<string, any>): Record<string, any>;
|
||||
}
|
||||
declare namespace lib_plankton.pod {
|
||||
declare module lib_plankton.pod {
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
|
|
@ -279,7 +294,7 @@ declare namespace lib_plankton.pod {
|
|||
show_value?: ((value: type_value) => string);
|
||||
}): string;
|
||||
}
|
||||
declare namespace lib_plankton.pod {
|
||||
declare module lib_plankton.pod {
|
||||
/**
|
||||
*/
|
||||
class class_pod<type_value> {
|
||||
|
|
@ -294,59 +309,9 @@ declare namespace lib_plankton.pod {
|
|||
distinguish<type_result>(function_empty: (() => type_result), function_filled: ((value: type_value) => type_result)): type_result;
|
||||
}
|
||||
}
|
||||
declare namespace lib_plankton.call {
|
||||
/**
|
||||
* @author fenris
|
||||
/**
|
||||
* might be completely obsolete
|
||||
*/
|
||||
type type_executor<type_result, type_reason> = ((resolve: (result?: type_result) => any, reject?: (reason?: type_reason) => void) => void);
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function executor_resolve<type_result, type_reason>(result: type_result): type_executor<type_result, type_reason>;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function executor_reject<type_result, type_reason>(reason: type_reason): type_executor<type_result, type_reason>;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function executor_transform<type_result_from, type_error_from, type_result_to, type_error_to>(executor: type_executor<type_result_from, type_error_from>, transform_result: (result_from: type_result_from) => type_result_to, transform_reason: (error_from: type_error_from) => type_error_to): type_executor<type_result_to, type_error_to>;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function executor_transform_default<type_result_from, type_result_to>(executor: type_executor<type_result_from, Error>, transform_result: (result_from: type_result_from) => type_result_to, wrap_string?: string): type_executor<type_result_to, Error>;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function executor_compose_sequential<type_result_first, type_result_second, type_reason>(first: type_executor<type_result_first, type_reason>, second: (result: type_result_first) => type_executor<type_result_second, type_reason>): type_executor<type_result_second, type_reason>;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function executor_chain<type_state, type_error>(state: type_state, executors: Array<(state: type_state) => type_executor<type_state, type_error>>): type_executor<type_state, type_error>;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function executor_first<type_result, type_reason>(executors: Array<type_executor<type_result, type_reason>>): type_executor<type_result, Array<type_reason>>;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function executor_condense<type_element>(executors: Array<type_executor<type_element, Error>>): type_executor<Array<type_element>, Error>;
|
||||
/**
|
||||
* @author fenris
|
||||
* @deprecated use condense
|
||||
*/
|
||||
function executor_filter<type_element>(executors: Array<type_executor<type_element, Error>>, predicate: (element: type_element) => boolean): type_executor<Array<type_element>, Error>;
|
||||
/**
|
||||
* @author fenris
|
||||
* @deprecated use condense
|
||||
*/
|
||||
function executor_map<type_element1, type_element2>(executors: Array<type_executor<type_element1, Error>>, transformator: (element1: type_element1) => type_element2): type_executor<Array<type_element2>, Error>;
|
||||
/**
|
||||
* @author fenris
|
||||
* @deprecated use condense
|
||||
*/
|
||||
function executor_reduce<type_element, type_result>(executors: Array<type_executor<type_element, Error>>, initial: type_result, accumulator: (result: type_result, element: type_element) => type_result): type_executor<type_result, Error>;
|
||||
}
|
||||
declare namespace lib_plankton.call {
|
||||
/**
|
||||
* @author fenris
|
||||
|
|
@ -363,15 +328,15 @@ declare namespace lib_plankton.call {
|
|||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function promise_make<type_result, type_reason>(executor: (resolve: (result?: type_result) => void, reject: (reason?: type_reason) => void) => void): type_promise<type_result, type_reason>;
|
||||
function promise_make<type_result, type_reason>(executor: (resolve: ((result?: type_result) => void), reject: ((reason?: type_reason) => void)) => void): type_promise<type_result, type_reason>;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function promise_then_close<type_result, type_reason>(promise: type_promise<type_result, type_reason>, resolver: (result: type_result) => void, rejector: (reason: type_reason) => void): void;
|
||||
function promise_then_close<type_result, type_reason>(promise: type_promise<type_result, type_reason>, resolver: ((result: type_result) => void), rejector: ((reason: type_reason) => void)): void;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function promise_then_append<type_result, type_reason, type_result_>(promise: type_promise<type_result, type_reason>, resolver: (result: type_result) => type_promise<type_result_, type_reason>, rejector?: (reason: type_reason) => type_promise<type_result_, type_reason>): type_promise<type_result_, type_result>;
|
||||
function promise_then_append<type_result, type_reason, type_result_>(promise: type_promise<type_result, type_reason>, resolver: ((result: type_result) => type_promise<type_result_, type_reason>), rejector?: ((reason: type_reason) => type_promise<type_result_, type_reason>)): type_promise<type_result_, type_result>;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
|
|
@ -379,7 +344,7 @@ declare namespace lib_plankton.call {
|
|||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function promise_chain<type_result, type_reason>(promises: Array<(input: type_result) => type_promise<type_result, type_reason>>, start?: type_result): type_promise<type_result, type_reason>;
|
||||
function promise_chain<type_result, type_reason>(promises: (Array<(input: type_result) => type_promise<type_result, type_reason>>), start?: type_result): type_promise<type_result, type_reason>;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
|
|
@ -387,15 +352,13 @@ declare namespace lib_plankton.call {
|
|||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function promise_group<type_reason>(promises: {
|
||||
[name: string]: () => type_promise<any, type_reason>;
|
||||
}, serial?: boolean): type_promise<{
|
||||
[name: string]: any;
|
||||
}, type_reason>;
|
||||
function promise_group<type_reason>(promises: Record<string, (() => type_promise<any, type_reason>)>, options?: {
|
||||
serial?: boolean;
|
||||
}): type_promise<Record<string, any>, type_reason>;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function promise_wrap<type_result_inner, type_result_outer, type_reason>(promise: type_promise<type_result_inner, type_reason>, transformator_result: (reason: type_result_inner) => type_result_outer, transformator_reason?: (reason: type_reason) => type_reason): type_promise<type_result_outer, type_reason>;
|
||||
function promise_wrap<type_result_inner, type_result_outer, type_reason>(promise: type_promise<type_result_inner, type_reason>, transformator_result: ((reason: type_result_inner) => type_result_outer), transformator_reason?: ((reason: type_reason) => type_reason)): type_promise<type_result_outer, type_reason>;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
|
|
@ -405,19 +368,11 @@ declare namespace lib_plankton.call {
|
|||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function promise_attach<type_reason>(state: {
|
||||
[name: string]: any;
|
||||
}, promise: type_promise<any, type_reason>, name: string): type_promise<{
|
||||
[name: string]: any;
|
||||
}, type_reason>;
|
||||
function promise_attach<type_reason>(state: Record<string, any>, promise: type_promise<any, type_reason>, name: string): type_promise<Record<string, any>, type_reason>;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function promise_delay<type_result, type_reason>(promise: type_promise<type_result, type_reason>, delay: int): type_promise<type_result, type_reason>;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function promise_to_executor<type_result, type_reason>(promise: type_promise<type_result, type_reason>): type_executor<type_result, type_reason>;
|
||||
}
|
||||
declare namespace lib_plankton.call {
|
||||
/**
|
||||
|
|
@ -449,6 +404,9 @@ declare namespace lib_plankton.call {
|
|||
cancel(): void;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* initializer might be obsolete, since promises are reusable after having been resolved or rejected
|
||||
*/
|
||||
declare namespace lib_plankton.call {
|
||||
/**
|
||||
* @author fenris
|
||||
|
|
@ -637,7 +595,7 @@ declare namespace lib_plankton.call {
|
|||
*/
|
||||
function compose<type_x, type_y, type_z>(function_f: ((type_x: any) => type_y), function_g: ((type_y: any) => type_z)): ((value: type_x) => type_z);
|
||||
/**
|
||||
* transforms a function with sequential input into a function with leveled input; example: add(2,3) = curryfy(add)(2)(3)
|
||||
* transforms a function with sequential input to a function with leveled input; example: add(2,3) = curryfy(add)(2)(3)
|
||||
*
|
||||
* @param {function} f
|
||||
* @return {function} the currified version of the in put function
|
||||
|
|
@ -651,7 +609,13 @@ declare namespace lib_plankton.call {
|
|||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function timeout(procedure: (() => void), delay: int): int;
|
||||
function timeout(procedure: (() => void), delay_in_seconds: float): int;
|
||||
/**
|
||||
* Promise version of "setTimeout"
|
||||
*
|
||||
* @author fenris
|
||||
*/
|
||||
function defer<type_result>(seconds: float, action: (() => type_result)): Promise<type_result>;
|
||||
/**
|
||||
* a definition for a value being "defined"
|
||||
*
|
||||
|
|
@ -698,12 +662,6 @@ declare namespace lib_plankton.call {
|
|||
function distinguish<type_output>(coproduct: type_coproduct, handlers: Record<string, ((data?: any) => type_output)>, options?: {
|
||||
fallback?: (null | ((coproduct?: type_coproduct) => type_output));
|
||||
}): type_output;
|
||||
/**
|
||||
* Promise version of "setTimeout"
|
||||
*
|
||||
* @author fenris
|
||||
*/
|
||||
function defer<type_result>(seconds: float, action: (() => type_result)): Promise<type_result>;
|
||||
/**
|
||||
* for rate_limit_check
|
||||
*
|
||||
|
|
@ -733,6 +691,207 @@ declare namespace lib_plankton.call {
|
|||
seconds: (null | float);
|
||||
}>;
|
||||
}
|
||||
declare namespace lib_plankton.list {
|
||||
/**
|
||||
* @desc returns a certain list of integer numbers
|
||||
* @param {int} from
|
||||
* @param {int} to
|
||||
* @param {int} step; default: 1
|
||||
* @author fenris
|
||||
*/
|
||||
function range(from: int, to: int, step?: int): Array<int>;
|
||||
/**
|
||||
* @desc returns a certain list of integer numbers
|
||||
* @param {int} length
|
||||
* @author fenris
|
||||
*/
|
||||
function sequence(length: int): Array<int>;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function from_structure<type_element>(structure: {
|
||||
length: int;
|
||||
}): Array<type_element>;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function from_iterator<type_element>(iterator: any): Array<type_element>;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function empty<type_element>(list: Array<type_element>): boolean;
|
||||
/**
|
||||
* @desc creates a list, which contains pairs of elements from the input lists (corresponding by index)
|
||||
* @param {boolean} [cut] whether the result list will be as long as the shortest input list or an exception is thrown if they have different lengths; default: true
|
||||
* @author fenris
|
||||
*/
|
||||
function zip<type_element1, type_element2>(list1: Array<type_element1>, list2: Array<type_element2>, cut?: boolean): Array<{
|
||||
first: type_element1;
|
||||
second: type_element2;
|
||||
}>;
|
||||
/**
|
||||
* @desc checks whether two lists are equal
|
||||
* @todo define common function "equals" and default predicate to
|
||||
* @author fenris
|
||||
*/
|
||||
function equals<type_element>(list1: Array<type_element>, list2: Array<type_element>, collate?: (element1: type_element, element2: type_element) => boolean): boolean;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function reversed<type_element>(list: Array<type_element>): Array<type_element>;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function sorted<type_element>(list: Array<type_element>, order: (element1: type_element, element2: type_element) => int): Array<type_element>;
|
||||
/**
|
||||
* @desc creates a list with the elements from the input list, which fulfil a certain predicate
|
||||
* @author fenris
|
||||
*/
|
||||
function keep<type_element>(list: Array<type_element>, predicate: (element: type_element, index?: int) => boolean): Array<type_element>;
|
||||
/**
|
||||
* @desc creates a list with the elements from the input list, which do not fulfil a certain predicate
|
||||
* @author fenris
|
||||
*/
|
||||
function drop<type_element>(list: Array<type_element>, predicate: (element: type_element, index?: int) => boolean): Array<type_element>;
|
||||
/**
|
||||
* @desc returns a list with no duplicates
|
||||
* @author fenris
|
||||
*/
|
||||
function clean<type_element>(list: Array<type_element>, collate?: (x: type_element, y: type_element) => boolean): Array<type_element>;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function clone<type_element>(list: Array<type_element>): Array<type_element>;
|
||||
/**
|
||||
* @desc creates a binary partition of the list according to a given predicate
|
||||
* @author fenris
|
||||
*/
|
||||
type type_separation<type_element> = {
|
||||
yes: Array<type_element>;
|
||||
no: Array<type_element>;
|
||||
};
|
||||
function separate<type_element>(list: Array<type_element>, predicate: (element: type_element) => boolean): type_separation<type_element>;
|
||||
/**
|
||||
* die Liste in gleich große Blöcke zerlegen
|
||||
*
|
||||
* @author fenris
|
||||
*/
|
||||
function split<type_element>(list: Array<type_element>, chunk_size: int): Array<Array<type_element>>;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function group<type_element>(list: Array<type_element>, collate?: (x: type_element, y: type_element) => boolean): Array<Array<type_element>>;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function groups_<type_element>(list: Array<type_element>, collate?: (x: type_element, y: type_element) => boolean): Array<Array<type_element>>;
|
||||
/**
|
||||
* @author fenris
|
||||
* @deprecated
|
||||
*/
|
||||
function groups<type_element, type_value>(list: Array<type_element>, sorting: (x: type_element, y: type_element) => int, hashing: (element: type_element) => type_value): Array<Array<type_element>>;
|
||||
/**
|
||||
* @desc searches for the first element in a list, that fulfils a given condition
|
||||
* @author fenris
|
||||
*/
|
||||
function find<type_element>(list: Array<type_element>, predicate: (element: type_element) => boolean, null_if_not_found?: boolean): type_element;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function has<type_element>(list: Array<type_element>, predicate: (element: type_element) => boolean): boolean;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function contains<type_element>(list: Array<type_element>, element: type_element, collation?: (element1: type_element, element2: type_element) => boolean): boolean;
|
||||
/**
|
||||
* @desc retrieves the element and its index of the list, which has the maximum value
|
||||
* @author fenris
|
||||
*/
|
||||
type type_result_max<type_element, type_value> = {
|
||||
index: int;
|
||||
element: type_element;
|
||||
value: type_value;
|
||||
};
|
||||
function max<type_element, type_value>(list: Array<type_element>, targetfunction: (element: type_element) => type_value, compare?: (value1: type_value, value2: type_value) => boolean): type_result_max<type_element, type_value>;
|
||||
/**
|
||||
* @desc retrieves the element and its index of the list, which has the mininum value
|
||||
* @author fenris
|
||||
*/
|
||||
function min<type_element, type_value>(list: Array<type_element>, targetfunction: (element: type_element) => type_value, compare?: (value1: type_value, value2: type_value) => boolean): type_result_max<type_element, type_value>;
|
||||
/**
|
||||
* @desc retrieves the element of the list, which has the maximum output for a given target-function
|
||||
* @author fenris
|
||||
*/
|
||||
function maxarg<type_element, type_value>(list: Array<type_element>, targetfunction: (element: type_element) => type_value, compare?: (value1: type_value, value2: type_value) => boolean): type_element;
|
||||
/**
|
||||
* @desc retrieves the element of the list, which has the minimum output for a given target-function
|
||||
* @author fenris
|
||||
*/
|
||||
function minarg<type_element, type_value>(list: Array<type_element>, targetfunction: (element: type_element) => type_value, compare?: (value1: type_value, value2: type_value) => boolean): type_element;
|
||||
/**
|
||||
* @desc implements the idea of arithmetic distribution like in "(a+b)·(c+d) = (a·c)+(a·d)+(b·c)+(b·d)"
|
||||
* example: distribute([[1,2],[3],[4,5,6]]) = [[1,3,4],[1,3,5],[1,3,6],[2,3,4],[2,3,5],[2,3,6]]
|
||||
* @author fenris
|
||||
*/
|
||||
function distribute<type_element>(lists: Array<Array<type_element>>): Array<Array<type_element>>;
|
||||
/**
|
||||
* @desc lexicographic order
|
||||
* @author fenris
|
||||
* @deprecated
|
||||
*/
|
||||
function lex<type_element>(list1: Array<type_element>, list2: Array<type_element>, order?: (element1: type_element, element2: type_element) => int): int;
|
||||
function lex_lt<type_element>(list1: Array<type_element>, list2: Array<type_element>): boolean;
|
||||
function lex_gt<type_element>(list1: Array<type_element>, list2: Array<type_element>): boolean;
|
||||
function lex_le<type_element>(list1: Array<type_element>, list2: Array<type_element>): boolean;
|
||||
function lex_ge<type_element>(list1: Array<type_element>, list2: Array<type_element>): boolean;
|
||||
function lex_eq<type_element>(list1: Array<type_element>, list2: Array<type_element>): boolean;
|
||||
function lex_ne<type_element>(list1: Array<type_element>, list2: Array<type_element>): boolean;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function filter_inplace<type_element>(list: Array<type_element>, predicate: (element: type_element, index?: int) => boolean): void;
|
||||
}
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
declare namespace lib_list {
|
||||
type type_separation<type_element> = lib_plankton.list.type_separation<type_element>;
|
||||
type type_result_max<type_element, type_value> = lib_plankton.list.type_result_max<type_element, type_value>;
|
||||
const range: typeof lib_plankton.list.range;
|
||||
const sequence: typeof lib_plankton.list.sequence;
|
||||
const from_structure: typeof lib_plankton.list.from_structure;
|
||||
const from_iterator: typeof lib_plankton.list.from_iterator;
|
||||
const empty: typeof lib_plankton.list.empty;
|
||||
const zip: typeof lib_plankton.list.zip;
|
||||
const equals: typeof lib_plankton.list.equals;
|
||||
const reversed: typeof lib_plankton.list.reversed;
|
||||
const sorted: typeof lib_plankton.list.sorted;
|
||||
const keep: typeof lib_plankton.list.keep;
|
||||
const drop: typeof lib_plankton.list.drop;
|
||||
const clean: typeof lib_plankton.list.clean;
|
||||
const clone: typeof lib_plankton.list.clone;
|
||||
const separate: typeof lib_plankton.list.separate;
|
||||
const split: typeof lib_plankton.list.split;
|
||||
const group: typeof lib_plankton.list.group;
|
||||
const groups_: typeof lib_plankton.list.groups_;
|
||||
const groups: typeof lib_plankton.list.groups;
|
||||
const find: typeof lib_plankton.list.find;
|
||||
const has: typeof lib_plankton.list.has;
|
||||
const contains: typeof lib_plankton.list.contains;
|
||||
const max: typeof lib_plankton.list.max;
|
||||
const min: typeof lib_plankton.list.min;
|
||||
const maxarg: typeof lib_plankton.list.maxarg;
|
||||
const minarg: typeof lib_plankton.list.minarg;
|
||||
const distribute: typeof lib_plankton.list.distribute;
|
||||
const lex: typeof lib_plankton.list.lex;
|
||||
const lex_lt: typeof lib_plankton.list.lex_lt;
|
||||
const lex_gt: typeof lib_plankton.list.lex_gt;
|
||||
const lex_le: typeof lib_plankton.list.lex_le;
|
||||
const lex_ge: typeof lib_plankton.list.lex_ge;
|
||||
const lex_eq: typeof lib_plankton.list.lex_eq;
|
||||
const lex_ne: typeof lib_plankton.list.lex_ne;
|
||||
const filter_inplace: typeof lib_plankton.list.filter_inplace;
|
||||
}
|
||||
declare namespace lib_plankton.code {
|
||||
/**
|
||||
* @author fenris
|
||||
|
|
@ -948,6 +1107,10 @@ declare namespace lib_plankton.json {
|
|||
}
|
||||
}
|
||||
declare namespace lib_plankton.file {
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
function exists(path: string): Promise<boolean>;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -10,6 +10,7 @@ dir="lib/plankton"
|
|||
modules=""
|
||||
modules="${modules} base"
|
||||
modules="${modules} call"
|
||||
modules="${modules} list"
|
||||
modules="${modules} json"
|
||||
modules="${modules} file"
|
||||
modules="${modules} args"
|
||||
|
|
|
|||
Loading…
Reference in a new issue