UNPKG

@bangladeshi/bangladesh-address

Version:

A simple npm package for Bangladesh's administrative divisions, districts, upazilas, and metropolitan thanas.

106 lines (105 loc) 4.07 kB
import upazilaData from "../json/bd-upazila.json"; import thanaData from "../json/bd-thana.json"; import { Upazila, Thana } from "../types"; /** * Get all upazilas in a given district * @param district - The district name * @returns Array of upazila objects containing upazila, district, and division */ export declare const upazilasOf: (district: string) => Upazila[]; /** * Get all upazila names in a given district * @param district - The district name * @returns Array of upazila names (strings) */ export declare const upazilaNamesOf: (district: string) => string[]; /** * Get all upazila names in Bangladesh * @returns Array of all upazila names (495 upazilas) */ export declare const allUpazila: () => string[]; /** * Get all thanas (metropolitan police stations) in Bangladesh * @returns Array of thana objects (26 thanas) */ export declare const allThana: () => Thana[]; /** * Get all thana names in Bangladesh * @returns Array of all thana names (26 thanas) */ export declare const allThanaNames: () => string[]; /** * Get thanas in a given district * @param district - The district name * @returns Array of thana objects for the district */ export declare const thanasOf: (district: string) => Thana[]; /** * Get thana names in a given district * @param district - The district name * @returns Array of thana names (strings) */ export declare const thanaNamesOf: (district: string) => string[]; /** * Check if a location is a thana (metropolitan police station) * @param name - The location name to check * @param district - Optional district name to disambiguate (e.g., "Kotwali" exists in both Dhaka and Chattogram) * @returns true if the location is a thana, false otherwise */ export declare const isThana: (name: string, district?: string) => boolean; /** * Check if a location is an upazila * @param name - The location name to check * @param district - Optional district name to disambiguate * @returns true if the location is an upazila, false otherwise */ export declare const isUpazila: (name: string, district?: string) => boolean; /** * Get a thana by name * @param name - The thana name to find * @param district - Optional district name to disambiguate (e.g., "Kotwali" exists in both Dhaka and Chattogram) * @returns The thana object if found, undefined otherwise */ export declare const getThana: (name: string, district?: string) => Thana | undefined; /** * Get an upazila by name * @param name - The upazila name to find * @param district - Optional district name to disambiguate * @returns The upazila object if found, undefined otherwise */ export declare const getUpazila: (name: string, district?: string) => Upazila | undefined; /** * Get the district for a given upazila (reverse lookup) * @param upazila - The upazila name * @param division - Optional division name to disambiguate if upazila name exists in multiple districts * @returns The district name if found, undefined otherwise */ export declare const getDistrictOfUpazila: (upazila: string, division?: string) => string | undefined; /** * Get all upazilas in a given division * @param division - The division name * @returns Array of upazila objects for the division */ export declare const upazilasOfDivision: (division: string) => Upazila[]; /** * Get all upazila names in a given division * @param division - The division name * @returns Array of upazila names (strings) */ export declare const upazilaNamesOfDivision: (division: string) => string[]; /** * Search result item representing a location match */ export interface SearchResult { name: string; type: "division" | "district" | "upazila" | "thana"; district?: string; division?: string; } /** * Search across all locations (divisions, districts, upazilas, thanas) * @param query - The search query (case-insensitive, partial match) * @returns Array of matching locations sorted by type (division > district > upazila > thana) */ export declare const searchLocations: (query: string) => SearchResult[]; export { upazilaData, thanaData };