import * as p_di from "../../../interface/data.js"; import * as p_ti from "../../../interface/transformer.js"; import { type Abort } from "../../../interface/__internal/Abort.js"; /** * Wraps a boolean value, providing a `decide` method that branches into one of two callbacks based on the value. */ export declare const boolean: (boolean_value: boolean) => { /** * Calls `if_true` if the wrapped value is true, otherwise calls `if_false`. * @param if_true function to call when the value is true * @param if_false function to call when the value is false * @returns the result of whichever function was called */ decide: (if_true: () => RT, if_false: () => RT) => RT; }; /** * Wraps a dictionary and provides a rich set of transformation and query methods. */ export declare const dictionary: (dict: p_di.Dictionary) => { /** * Returns the number of entries in the dictionary. */ amount_of_entries: () => number; /** * each entry in the dictionary is converted to a list item using the provided assign_item function, * which gives access to the value and the id of the entry */ convert_to_list: (assign_item: (value: T, id: string) => New_Type) => p_di.List; /** * filters the dictionary entries based on the provided callback function. * if you also want to transform the values, use map_optionally instead. */ filter: (callback: (value: T, id: string) => boolean) => p_di.Dictionary; /** * Flattens a dictionary of dictionaries into a single dictionary, * the first step is to provide a child dictionary for each entry in the parent dictionary * the second step is to provide a new id based on the parent id and the child id * @param get_child_dictionary function to retrieve the child dictionary for each entry * @param get_id function to compute a new id from the parent id and the child id * @param abort callbacks invoked on error; `duplicate_id` is called with the conflicting id if two entries would share the same id * @returns a new flat dictionary containing all entries from all child dictionaries */ flatten: (get_child_dictionary: (value: T) => p_di.Dictionary, get_id: (parent_id: string, child_id: string) => string, abort: { duplicate_id: Abort; }) => p_di.Dictionary; /** * differs from 'flatten' in that it does not require a new id to be computed, * and instead uses the child id directly. This child id has to be globally unique */ flatten2: (get_child_dictionary: (value: T, id: string) => p_di.Dictionary, abort: { duplicate_id: Abort; }) => p_di.Dictionary; /** * flattens the dictionary into a list, where each entry in the dictionary is converted to a list of items using the provided assign_item function, */ flatten_to_list: (assign_item: (value: T, id: string) => p_di.List) => p_di.List; /** * Retrieves a possible entry from the dictionary. * @param id The id of the entry to retrieve. * @param if_set Function to call if the entry is set. * @param if_not_set Function to call if the entry is not set. * @returns The result of either if_set or if_not_set. */ get_possible_entry(id: string, if_set: ($: T) => RT, if_not_set: () => RT): RT; /** * Groups the entries of the dictionary based on group id that is provided for each entry. * the entries of each group are then aggregated into a desired result using the provided aggregate function. * @param get_group_id Function to determine the group id for each entry. * @param aggregate Function to aggregate the entries of each group. * @returns A dictionary where the id's are group id's and the values are the aggregated results. */ group: (get_group_id: (value: T, id: string) => string, aggregate: ($: p_di.Dictionary, group_id: string) => RT) => p_di.Dictionary; /** * joins the current dictionary with another dictionary based on their ids. * The resulting dictionary will have the same ids and the same amount of entries as the current dictionary. * for each entry in the current dictionary, the corresponding entry in the other dictionary is retrieved (if it exists). * the provided assign_entry function is then called with the value from the current dictionary, the optional value from the other dictionary, and the id. * the result of assign_entry is used as the value for the new dictionary. * @param other_dictionary the dictionary to join against * @param assign_entry function called for each entry with the current value, the optional matching value from the other dictionary, and the entry id * @returns a new dictionary with the same ids as the current dictionary and values produced by `assign_entry` */ join: (other_dictionary: p_di.Dictionary, assign_entry: (value: T, other_value: p_di.Optional_Value, id: string) => Result) => p_di.Dictionary; /** * converts the values of the dictionary to a new type using the provided assign_entry function. * @param assign_entry function to convert each entry; receives the current value and the entry id * @returns a new dictionary with the same ids and the converted values */ map: (assign_entry: (value: T, id: string) => New_Type) => p_di.Dictionary; /** * filters and converts values in 1 go, using the provided assign_optional_entry function. * if the function returns a not set value, it will be excluded from the new dictionary. * if the function returns a set value, it will be included in the new dictionary. * the set value will be the new value for that entry in the new dictionary. * @param assign_optional_entry * @returns */ map_optionally: (assign_optional_entry: (value: T, id: string) => p_di.Optional_Value) => p_di.Dictionary; /** * executes one of the provided functions depending on whether the dictionary has entries or not. * @param if_true function to execute if the dictionary has entries * @param if_not_true function to execute if the dictionary has no entries * @returns the result of the executed function */ on_has_entries: (if_true: ($: p_di.Dictionary) => RT, if_not_true: () => RT) => RT; /** * executes one of the provided functions depending on whether the dictionary has a single entry, multiple entries, or no entries. * @param if_true function to execute if the dictionary has a single entry * @param if_multiple function to execute if the dictionary has multiple entries * @param if_none function to execute if the dictionary has no entries * @returns the result of the executed function */ on_has_single_entry: (if_true: ($: T, id: string) => RT, if_multiple: ($: p_di.Dictionary) => RT, if_none: () => RT) => RT; /** * use this function to map the values of the dictionary to a new type, while giving access to the siblings of this entry during the mapping process. * this is useful when the mapping of an entry depends on the values of other entries in the dictionary. * the assign_entry function is called for each entry in the dictionary, and is provided with the value of the entry, the id of the entry, and two lookups: acyclic and cyclic. * * the acyclic lookup can be used to access other entries in the dictionary that have already been resolved (i.e. their assign_entry function has already been called), * or can be resolved on the spot without it having a direct or indirect dependency on the current entry. * * the cyclic lookup can be used to access other entries in the dictionary that are potentially depending directly or indirectly on the current entry. The lookup will provide * a link to the other entry, but this link should not be accessed before the whole dictionary has been resolved, otherwise it will throw an exception. The cyclic lookup is useful for creating circular references between entries in the dictionary. * @param assign_entry * @returns */ resolve: (assign_entry: (value: T, id: string, acyclic_lookup: p_ti.lookup.Acyclic, cyclic_lookup: p_ti.lookup.Cyclic) => Resolved) => p_di.Dictionary; /** * sums all the entries of the dictionary. * each entry is converted to a number using the provided assign_value function, and the results are summed up. * @param assign_value function to convert each entry to a number * @returns the sum of all converted values */ sum: (assign_value: (item: T) => number) => number; }; /** * Wraps a list and provides a rich set of transformation and query methods. */ export declare const list: (list: p_di.List) => { /** * Returns the number of items in the list. */ amount_of_items: () => number; /** * filters the list based on the provided callback function. * if you also want to transform the values, use map_optionally instead. * @param callback a function that takes an item and returns a boolean indicating whether the item should be included in the filtered list. * @returns a new list containing only the items for which the callback returned true. */ filter: (callback: (item: T) => boolean) => p_di.List; /** * flattens a list of lists into a single list, where each item in the original list is converted to a list of items using the provided assign_list function. * @param assign_list function to convert each item into a list of new items * @returns a new flat list containing all items produced by `assign_list` */ flatten: (assign_list: ($: T) => p_di.List) => p_di.List; /** * performs a full join between the current list and another list, creating a new list of results based on the provided assign_item function. * The amount of items in the resulting list will be equal to the maximum amount of items in either of the two lists. * if you want the amount of items in the resulting list to be equal to the amount of items in the main list, use 'join' instead. * @param other_list * @param assign_item * @returns */ full_join: (other_list: p_di.List, assign_item: (value: p_di.Optional_Value, other_value: p_di.Optional_Value) => Result) => p_di.List; /** * groups the items in the list based on a group id that is provided for each item. * the items of each group are then aggregated into a desired result using the provided aggregate function. * @param get_id function to determine the group id for each item * @param aggregate function to aggregate the items of each group into a result value * @returns a dictionary where the id's are group id's and the values are the aggregated results */ group: (get_id: (item: T) => string, aggregate: ($: p_di.List, group_id: string) => RT) => p_di.Dictionary; /** * joins the current list with another list based on their indices. * The resulting list will have the same amount of items as the current list. * for each item in the current list, the corresponding item in the other list is retrieved (if it exists). * the provided assign_item function is then called with the value from the current list, the optional value from the other list. * the result of assign_item is used as the value for the new list. * @param other_list * @param assign_item * @returns */ join: (other_list: p_di.List, assign_item: (value: T, other_value: p_di.Optional_Value) => Result_1) => p_di.List; /** * converts the items in the list to a new type using the provided assign_item function. * @param assign_item function to convert each item to a new value * @returns a new list containing the converted values */ map: (assign_item: (item: T) => New_Type) => p_di.List; /** * filters and converts items in 1 go, using the provided assign_optional_item function. * if the function returns a not set value, it will be excluded from the new list. * if the function returns a set value, it will be included in the new list. * the set value will be the new value for that item in the new list. * @param assign_optional_item * @returns */ map_optionally: (assign_optional_item: (item: T) => p_di.Optional_Value) => p_di.List; /** * converts the items in the list to a new type using the provided assign_item function. * the assign_item function receives both the item and its index in the list. * @param assign_item * @returns */ map_with_index: (assign_item: (item: T, index: number) => New_Type) => p_di.List; /** * maps the items in the list to a new type while maintaining a state that can be updated with each item. * the initial state is provided as an argument, and the assign_item function is called for each item in the list, receiving both the item and the current state. * the update_state function is then called with the result of assign_item and the current state, allowing you to update the state for the next iteration. * finally, after all items have been processed, the wrapup function is called with the final list of results and the final state, allowing you to produce a final result. * @param initial_state the initial value of the state before processing any items * @param assign_item function to convert each item using the current state * @param update_state function to produce the next state from the converted item and the current state * @param wrapup function called once with the final converted list and the final state to produce the result * @returns the result produced by `wrapup` */ map_with_state: (initial_state: State, assign_item: (item: T, state: State) => Target_Item, update_state: (item: Target_Item, state: State) => State, wrapup: (final_list: p_di.List, final_state: State) => Result_Type) => Result_Type; /** * executes one of the provided functions depending on whether the list has a first item or not. * if it has a first item, the if_true function is called with the first item and the rest of the list (excluding the first item). * if it does not have a first item, the if_not_true function is called. * @param if_true function to execute if the list has a first item * @param if_not_true function to execute if the list does not have a first item * @returns the result of either if_true or if_not_true */ on_has_first_item: (if_true: ($: T, rest: p_di.List) => RT, if_not_true: ($: p_di.List) => RT) => RT; /** * executes one of the provided functions depending on whether the list has items or not. * @param if_true function to execute if the list has items * @param if_not_true function to execute if the list does not have items * @returns the result of either if_true or if_not_true */ on_has_items: (if_true: ($: p_di.List) => RT, if_not_true: () => RT) => RT; /** * executes one of the provided functions depending on whether the list has a last item or not. * if it has a last item, the if_true function is called with the last item and the rest of the list (excluding the last item). * if it does not have a last item, the if_not_true function is called. * @param if_true function to execute if the list has a last item * @param if_not_true function to execute if the list does not have a last item * @returns the result of either if_true or if_not_true */ on_has_last_item: (if_true: ($: T, rest: p_di.List) => RT, if_not_true: () => RT) => RT; /** * sequentially tests each item in the list with the provided test function. * If a match is found, it returns the result of the test function. * If no match is found, it returns the result of the if_no_match function. */ on_has_match: (test: ($: T) => p_di.Optional_Value, if_no_match: () => RT) => RT; /** * executes one of the provided functions depending on whether the list has a single item, multiple items, or no items. * if it has a single item, the if_true function is called with that item. * if it has multiple items, the if_multiple function is called with the entire list. * if it has no items, the if_none function is called. * @param if_true function to execute if the list has a single item * @param if_multiple function to execute if the list has multiple items * @param if_none function to execute if the list has no items * @returns the result of either if_true, if_multiple, or if_none */ on_has_single_item: (if_true: ($: T) => RT, if_multiple: ($: p_di.List) => RT, if_none: () => RT) => RT; /** * sums all the items in the list. * each item is converted to a number using the provided assign_value function, and the results are summed up. * @param assign_value function to convert each item to a number * @returns the sum of all items */ sum: (assign_value: (item: T) => number) => number; /** * reduces the list to a boolean value by iteratively applying the update_state function to each item and the current state, starting from the initial_state. * @param initial_state the initial boolean state * @param update_state function to update the state based on each item * @returns the final boolean state after processing all items */ reduce_to_boolean: (initial_state: boolean, update_state: (value: T, current: boolean) => boolean) => boolean; /** * reduces the list to a number by iteratively applying the update_state function to each item and the current state, starting from the initial_state. * @param initial_state the initial numeric state * @param update_state function to update the state based on each item * @returns the final numeric state after processing all items */ reduce_to_number: (initial_state: number, update_state: (value: T, current: number) => number) => number; /** * reverses the order of the items in the list. * @returns a new list with the items in reverse order */ reverse: () => p_di.List; }; /** * Wraps a numeric value and provides arithmetic and utility methods. */ export declare const number: (number: number) => { /** * Performs integer division of two numbers with configurable rounding behavior. * * dividend / divisor * * Rounding modes: * - 'towards negative infinity': floor (7.8 → 7, -7.8 → -8) * - 'towards positive infinity': ceiling (7.2 → 8, -7.8 → -7) * - 'towards zero': truncate (7.8 → 7, -7.8 → -7) * - 'towards nearest': round to nearest integer (7.5 → 8, 7.4 → 7) * - 'away from zero': round away from zero (7.2 → 8, -7.2 → -8) */ divide: (divisor: number, round: ["towards negative infinity", null] | ["towards positive infinity", null] | ["towards nearest", null] | ["towards zero", null] | ["away from zero", null], abort: { divided_by_zero: Abort; }) => number; /** * Creates a list containing the given item repeated `number` times. * @param item the value to repeat * @returns a list of length `number` where every element is `item` */ repeat: (item: T) => p_di.List; }; /** * Wraps an optional value and provides methods to handle both the set and not-set cases. */ export declare const optional: (optional_value: p_di.Optional_Value) => { /** * Calls `if_set` with the wrapped value if it is set, otherwise calls `if_not_set`. * @param if_set function to call with the value when it is set * @param if_not_set function to call when the value is not set * @returns the result of whichever function was called */ decide: (if_set: ($: T) => RT, if_not_set: () => RT) => RT; /** * Transforms the wrapped value using the provided function if it is set. * If the value is not set, returns a not-set optional. * @param assign_set_value function to transform the value * @returns a new optional containing the transformed value, or not-set if the original was not set */ map: (assign_set_value: (value: T) => New_Type) => p_di.Optional_Value; }; /** * Wraps a state value and provides a method to produce a result from it. */ export declare const state: (state: State) => { /** * Passes the state to the provided function and returns the result. * @param assign function to produce a result from the state * @returns the result produced by `assign` */ decide: (assign: (output: State) => RT) => RT; }; /** * Wraps a string value. Currently no transformation methods are defined. */ export declare const text: (string: string) => {};