sri-lanka-postal-codes
v1.0.0
Published
Sri Lankan postal codes with city names for developers.
Maintainers
Readme
Sri Lankan Postal Codes & Cities
A lightweight (optimized), zero-dependency npm package for developers to access Sri Lankan postal codes and city names. Fully typed with TypeScript support.
Features
- 🇱🇰 Complete Data: Access over 2000+ Sri Lankan cities and postal codes.
- � Lightweight: Optimized data for minimal bundle size impact.
- 🔍 Powerful Search: Fuzzy search support for cities and codes.
- �️ TypeScript Ready: Built-in type definitions for excellent developer experience.
- 🌐 Multilingual: Supports Sinhala, Tamil, and English city names.
- ⚡ Zero Dependencies: Keeps your project lean.
Installation
npm install sri-lanka-postal-codesUsage
const postal = require('sri-lanka-postal-codes');
// 1. Get all data
const allCities = postal.getAll();
console.log(`Loaded ${allCities.length} cities.`);
// 2. Get by City Name (Case insensitive, supports English, Sinhala, Tamil)
const colombo = postal.getByCity('Colombo');
const anuradhapura = postal.getByCity('අනුරාධපුරය'); // Sinhala
console.log(colombo);
// 3. Get by Postal Code
const piliyandala = postal.getByCode('10300');
console.log(piliyandala);
// 4. Search (Partial match, case insensitive)
// Great for autocomplete inputs!
const results = postal.search('Piliyan');
console.log(results);Data Structure
Each entry follows this TypeScript interface:
interface City {
id: string;
name_en: string; // English Name
name_si: string; // Sinhala Name
name_ta: string; // Tamil Name
postcode: string;
latitude: string;
longitude: string;
}Example JSON output:
{
"id": "365",
"name_en": "Piliyandala",
"name_si": "පිළියන්දල",
"name_ta": "பிலியந்தலை",
"postcode": "10300",
"latitude": "6.80175750",
"longitude": "79.92273130"
}Contributing
Contributions are welcome! Please check out the CONTRIBUTING.md guide for details.
License
MIT © Vishwa Pramuditha
