UNPKG

nope-js-browser

Version:

NoPE Runtime for the Browser. For nodejs please use nope-js-node

65 lines (64 loc) 2.29 kB
/** * @author Martin Karkowski * @email m.karkowski@zema.de * @desc [description] */ /** * Extracts the unique values of an map. * * @author M.Karkowski * @export * @template D Return Type * @template K The Key of the Map * @template V The Value of the Map * @param {Map<K, V>} map The Map * @param {string} [path=""] The Path of the Data to extract. * @param {string} [pathKey=null] The Path of the unique key. If set to `null` -> The Item is selected directly. * @return {Set<D>} */ export declare function extractUniqueValues<D, K = any, V = any>(map: Map<K, V>, path?: string, pathKey?: string): Set<D>; /** * Helper to extract values of the map. Therefore the path must be provided. * @param map * @param path * @returns */ export declare function extractValues<D, K>(map: Map<K, any>, path?: string): Array<D>; /** * Transform the values. * * * @author M.Karkowski * @export * @template ExtractedValue * @template ExtractedKey * @template OriginalKey * @param {Map<OriginalKey, any>} map * @param {string} [pathExtractedValue=""] * @param {string} [pathExtractedKey=null] Additional Path of a Key. * @return {*} {Map<ExtractedKey, ExtractedData>} */ export declare function tranformMap<ExtractedKey = string, ExtractedValue = any, OriginalKey = string>(map: Map<OriginalKey, any>, pathExtractedValue: string, pathExtractedKey: string, equals?: (a: ExtractedValue, b: ExtractedValue) => boolean): { extractedMap: Map<ExtractedKey, ExtractedValue>; keyMapping: Map<OriginalKey, Set<ExtractedKey>>; conflicts: Map<ExtractedKey, Set<ExtractedValue>>; keyMappingReverse: Map<ExtractedKey, Set<OriginalKey>>; orgKeyToExtractedValue: Map<OriginalKey, Set<ExtractedValue>>; amountOf: Map<ExtractedKey, number>; }; /** * Reverses the given map. * * If the path is provided, the Data is extracted based on the given path. * If the `pathKey`, a different Key is used. * * @author M.Karkowski * @export * @template K * @template V * @param {Map<any,any>} map * @param {string} [path=""] * @param {string} [pathKey=null] * @return {*} {Map<V, Set<K>>} */ export declare function reverse<K, V>(map: Map<any, any>, path?: string, pathKey?: string): Map<V, Set<K>>;