interlanguage-checker/src/main/js/Shared.ts

28 lines
958 B
TypeScript

/**
* The message that is displayed when the application fails to connect to the API.
*/
export const couldNotConnectMessage: string =
"Could not to connect to API. Is the URL correct? Are you using a script blocker? " +
"See the <b>About</b> section for more information.";
// TODO: Add a merge strategy (to prefer HTTPS)
/**
* Merges the given maps into a new map containing all their elements.
*
* @param maps the maps to merge into a single map
* @return the combined map
*/
export const mergeMaps = <K, V>(maps: Map<K, V>[]): Map<K, V> => {
return maps.reduce((combined, map) => new Map([...combined, ...map]), new Map());
}
/**
* Merges the given sets into a new set containing all their elements.
*
* @param sets the sets to merge into a single set
* @return the combined set
*/
export const mergeSets = <T>(sets: Set<T>[]): Set<T> => {
return sets.reduce((combined, set) => new Set([...combined, ...set]), new Set());
}