UNPKG

kenya-locations

Version:

A comprehensive and intuitive TypeScript package for working with Kenyan administrative divisions (counties, sub-counties, constituencies, and wards)

92 lines (91 loc) 2.64 kB
import { County, Area, Ward } from './types'; import { ConstituencyWrapper } from './constituencies'; import { LocalityWrapper } from './localities'; /** * County wrapper class with methods to access related data */ export declare class CountyWrapper { private readonly _data; constructor(data: County); /** Get the county code */ get code(): string; /** Get the county name */ get name(): string; /** Get all data for the county */ get data(): County; /** * Get all constituencies in this county */ constituencies(): ConstituencyWrapper[]; /** * Get a constituency in this county by name or code * @throws LocationNotFoundError if not found */ constituency(nameOrCode: string): ConstituencyWrapper; /** * Get all localities in this county */ localities(): LocalityWrapper[]; /** * Get a locality in this county by name * @throws LocationNotFoundError if not found */ locality(name: string): LocalityWrapper; /** * Get all areas in this county */ areas(): Area[]; /** * Get all wards in this county */ wards(): Ward[]; /** * Get areas by locality name */ areasByLocality(localityName: string): Area[]; } /** * Get all counties * @returns Array of all counties * @example * ```ts * import { getCounties } from 'kenya-locations/counties'; * const counties = getCounties(); * ``` */ export declare function getCounties(): County[]; /** * Get a county by its code * @param code County code (e.g., '001', '047') * @returns County object or undefined if not found * @example * ```ts * import { getCountyByCode } from 'kenya-locations/counties'; * const mombasa = getCountyByCode('001'); * ``` */ export declare function getCountyByCode(code: string): County | undefined; /** * Get a county by name * @param name County name (case-insensitive) * @returns County object or undefined if not found * @example * ```ts * import { getCountyByName } from 'kenya-locations/counties'; * const nairobi = getCountyByName('Nairobi'); * ``` */ export declare function getCountyByName(name: string): County | undefined; /** * Get a county by name or code with chainable methods * @param nameOrCode County name or code * @returns CountyWrapper instance or undefined if not found * @example * ```ts * import { county } from 'kenya-locations/counties'; * const nairobi = county('Nairobi'); * const constituencies = nairobi?.constituencies(); * ``` */ export declare function county(nameOrCode: string): CountyWrapper | undefined; export type { County };