UNPKG

zipcodes-us

Version:

Fast, lightweight US ZIP code lookup library providing city, state, county, and geographic coordinates with TypeScript support - works in both browser and Node.js

81 lines (80 loc) 2.74 kB
import { ZipCodeInfo, ZipLookupResult, StateResult, Coordinates } from "./types.js"; /** * Finds complete information for a ZIP code * @param zipCode 5-digit ZIP code to look up * @returns Object with location data and validity flag */ export declare function find(zipCode: string): ZipLookupResult; /** * Finds state information for a ZIP code * @param zipCode 5-digit ZIP code to look up * @returns State name and code with validity flag */ export declare function findState(zipCode: string): StateResult; /** * Finds city name for a ZIP code * @param zipCode 5-digit ZIP code to look up * @returns City name or empty string with validity flag */ export declare function findCity(zipCode: string): { city: string; isValid: boolean; }; /** * Finds county name for a ZIP code * @param zipCode 5-digit ZIP code to look up * @returns County name or empty string with validity flag */ export declare function findCounty(zipCode: string): { county: string; isValid: boolean; }; /** * Finds coordinates for a ZIP code * @param zipCode 5-digit ZIP code to look up * @returns Latitude and longitude with validity flag */ export declare function findCoordinates(zipCode: string): Coordinates; /** * Finds all ZIP codes for a given city and state * @param city City name * @param stateCode Two-letter state code (e.g., "CA") * @returns Array of matching ZIP codes with their information */ export declare function findByCity(city: string, stateCode: string): ZipCodeInfo[]; /** * Find all ZIP codes in a given county * @param countyName County name * @param stateCode Two-letter state code * @returns Array of matching ZIP codes with their information */ export declare function findByCounty(countyName: string, stateCode: string): ZipCodeInfo[]; /** * Find ZIP codes within a radius of a given location * @param latitude Center point latitude * @param longitude Center point longitude * @param radiusMiles Radius in miles * @returns Array of ZIP codes within the radius, sorted by distance */ export declare function findByRadius(latitude: number, longitude: number, radiusMiles: number): ZipCodeInfo[]; /** * Returns all states with their codes and names * @returns Array of state objects with code and name */ export declare function getStates(): Array<{ code: string; name: string; }>; export { ZipCodeInfo }; declare const zipcodesUs: { find: typeof find; findState: typeof findState; findCity: typeof findCity; findCounty: typeof findCounty; findCoordinates: typeof findCoordinates; findByCity: typeof findByCity; findByCounty: typeof findByCounty; findByRadius: typeof findByRadius; getStates: typeof getStates; }; export default zipcodesUs;