kenya-locations
Version:
A comprehensive and intuitive TypeScript package for working with Kenyan administrative divisions (counties, sub-counties, constituencies, and wards)
71 lines (70 loc) • 2.42 kB
TypeScript
import { SubCounty, County, Ward } from './types';
/**
* Get all sub-counties
* @returns Array of all sub-counties
* @example
* ```ts
* import { getSubCounties } from 'kenya-locations/sub-counties';
* const subCounties = getSubCounties();
* ```
*/
export declare function getSubCounties(): SubCounty[];
/**
* Get a sub-county by code
* @param code Sub-county code
* @returns SubCounty object or undefined if not found
* @example
* ```ts
* import { getSubCountyByCode } from 'kenya-locations/sub-counties';
* const subCounty = getSubCountyByCode('001');
* ```
*/
export declare function getSubCountyByCode(code: string): SubCounty | undefined;
/**
* Get a sub-county by name
* @param name Sub-county name (case-insensitive)
* @returns SubCounty object or undefined if not found
* @example
* ```ts
* import { getSubCountyByName } from 'kenya-locations/sub-counties';
* const subCounty = getSubCountyByName('Westlands');
* ```
*/
export declare function getSubCountyByName(name: string): SubCounty | undefined;
/**
* Get all sub-counties in a county
* @param nameOrCode County name or code
* @returns Array of sub-counties in the county
* @example
* ```ts
* import { getSubCountiesInCounty } from 'kenya-locations/sub-counties';
* const subCounties = getSubCountiesInCounty('Nairobi');
* ```
*/
export declare function getSubCountiesInCounty(nameOrCode: string): SubCounty[];
/**
* Get the county of a sub-county
* @param subCountyName The name of the sub-county
* @returns County object or undefined if not found
* @example
* ```ts
* import { getCountyOfSubCounty } from 'kenya-locations/sub-counties';
* const county = getCountyOfSubCounty('Westlands');
* ```
*/
export declare function getCountyOfSubCounty(subCountyName: string): County | undefined;
/**
* Get all wards in a sub-county by name or code.
* Sub-county names correspond to constituency names in the ward dataset,
* so this matches wards whose constituency field equals the sub-county name.
* @param nameOrCode Sub-county name or code
* @returns Array of wards in the sub-county
* @example
* ```ts
* import { getWardsInSubCounty } from 'kenya-locations/sub-counties';
* const wards = getWardsInSubCounty('154'); // by code
* const wards2 = getWardsInSubCounty('Ainabkoi'); // by name
* ```
*/
export declare function getWardsInSubCounty(nameOrCode: string): Ward[];
export type { SubCounty };