irem
Version:
Search for any city in any language in Earth.
41 lines (40 loc) • 2.19 kB
TypeScript
import { Place, PlaceMatch, SupportedLanguage } from "./types.js";
import { Trie } from "./trie.js";
export declare const supportedLanguages: SupportedLanguage[];
export declare function isSupportedLanguage(language?: SupportedLanguage): boolean;
export declare const TRIE_FILE: string;
export declare const TSV_DB_FILE: string;
export declare const COUNTRIES_FILE: string;
/**
* Sort places by GPS position proximity.
* If any of `latitude` or `longitude` is not provided, sort by edit distance to the search term
* @export
* @template {PlaceMatch} T
* @param {T[]} places
* @param {?number} [latitude]
* @param {?number} [longitude]
*/
export declare function sortPlaces<T extends PlaceMatch>(places: T[], latitude?: number, longitude?: number, countryCode?: string): void;
export declare function enrichPlaceMatchesWithCountryName<T extends Place>(results: T[], language?: SupportedLanguage): (T & {
country: string;
})[];
export declare function normalizeString(str: string): string;
export declare function readGzippedFile(filePath: string): Promise<unknown>;
export declare function readGzippedJSON(filePath: string): Promise<any>;
export declare function writeGzippedJSON(filePath: string, jsonObject: Record<string, any>): Promise<void>;
export declare function readLinesFromTSV(tsvFilePath: string, lineNumbers: number[] | Set<number>, indexFilePath?: string): Promise<Place[]>;
export declare function gridSearchByGPS(latitude: number, longitude: number, resultCount?: number): Promise<Place[]>;
export declare function convertLinesToObjectArray(line: string, lineNumber: number): Place;
export declare function getAutocompleteResults(searchTerm: string, trie: Trie, maxResultCount?: number): Promise<PlaceMatch[]>;
export declare function isDefined<T>(a: T | undefined | null): a is NonNullable<T>;
/**
* add all elements of `setB` to `setA`. So it mutates `setA`
*
* @export
* @template T
* @param {Set<T>} setA
* @param {Set<T>} setB
*/
export declare function uniteSets<T>(setA: Set<T>, setB: Array<T>): void;
export declare function getPrefixMatchCount(str1: string, str2: string): number;
export declare function getValidResultCount(count?: number): number;