kenya-locations
Version:
A comprehensive and intuitive TypeScript package for working with Kenyan administrative divisions (counties, sub-counties, constituencies, and wards)
97 lines (96 loc) • 3.06 kB
TypeScript
import { Locality, Area, County } from './types';
/**
* Locality wrapper class with methods to access related data
*/
export declare class LocalityWrapper {
private readonly _data;
constructor(data: Locality);
/** Get the locality name */
get name(): string;
/** Get the county this locality belongs to */
get county(): string;
/** Get all data for the locality */
get data(): Locality;
/**
* Get all areas in this locality
*/
areas(): Area[];
/**
* Get an area by name
* @param name Name of the area
* @throws LocationNotFoundError if not found
*/
area(name: string): Area;
/**
* Get the county this locality belongs to
*/
getCounty(): County | undefined;
}
/**
* Get all localities
* @returns Array of all localities
* @example
* ```ts
* import { getLocalities } from 'kenya-locations/localities';
* const localities = getLocalities();
* ```
*/
export declare function getLocalities(): Locality[];
/**
* Get a locality by its name
* @param name Locality name (case-insensitive)
* @returns LocalityWrapper instance or undefined if not found
* @example
* ```ts
* import { getLocalityByName } from 'kenya-locations/localities';
* const westlands = getLocalityByName('Westlands');
* ```
*/
export declare function getLocalityByName(name: string): LocalityWrapper | undefined;
/**
* Get all localities in a county
* @param countyName County name
* @returns Array of localities in the county
* @example
* ```ts
* import { getLocalitiesInCounty } from 'kenya-locations/localities';
* const nairobiLocalities = getLocalitiesInCounty('Nairobi');
* ```
*/
export declare function getLocalitiesInCounty(countyName: string): Locality[];
/**
* Get the county of a locality
* @param localityName The name of the locality
* @returns County object or undefined if not found
* @example
* ```ts
* import { getCountyOfLocality } from 'kenya-locations/localities';
* const county = getCountyOfLocality('Westlands');
* ```
*/
export declare function getCountyOfLocality(localityName: string): County | undefined;
/**
* Get a locality by name with optional county filter
* @param name Locality name
* @param countyName Optional county name to filter by
* @returns LocalityWrapper instance or undefined if not found
* @example
* ```ts
* import { locality } from 'kenya-locations/localities';
* const westlands = locality('Westlands', 'Nairobi');
* ```
*/
/**
* Get all localities matching a name across all counties.
* Useful when the same locality name exists in more than one county.
* @param name Locality name (case-insensitive)
* @returns Array of LocalityWrapper instances
* @example
* ```ts
* import { getLocalitiesByName } from 'kenya-locations/localities';
* const allTown = getLocalitiesByName('Town');
* ```
*/
export declare function getLocalitiesByName(name: string): LocalityWrapper[];
export declare function locality(name: string, countyName?: string): LocalityWrapper | undefined;
export type { Locality };