npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

srilankan-provinces-districts

v2.0.0

Published

This provides all the Provinces and Districts in Sri Lanka

Readme

Sri Lankan Provinces & Districts 🇱🇰

A modern TypeScript package providing data for all provinces and districts in Sri Lanka.

📋 Table of Contents

✨ Features

  • TypeScript First: Complete type definitions for enhanced developer experience
  • Dual Package Format: Both ES Modules and CommonJS support for any project
  • Framework Agnostic: Works with Node.js, React, Next.js, Nest.js, and more
  • Complete Data: All 9 provinces and 25 districts of Sri Lanka with metadata
  • Developer Friendly: Case-insensitive lookups, helpful error handling
  • Zero Dependencies: Lightweight and clean implementation
  • Backward Compatible: All v1.x API functions still work

📦 Installation

# Using npm
npm install srilankan-provinces-districts

🚀 Usage

CommonJS (Legacy API)

// CommonJS require syntax
const provinceDistricts = require('srilankan-provinces-districts');

// Get all province names as an array
const provinces = provinceDistricts.getProvinces();
console.log(provinces);

## Output
["Western", "Central", "Southern", "Northern", "Eastern", ...]

// Get district names in a province
const westernDistricts = provinceDistricts.getDistricts("Western");
console.log(westernDistricts);

## Output
["Colombo", "Gampaha", "Kalutara"]

TypeScript / ES Modules

// ES Modules import syntax
import { 
  // Types
  Province, 
  District,
  
  // Functions - Legacy API
  getProvinces, 
  getDistricts,
  
  // Functions - New TypeScript API
  getProvince,
  getAllProvinces, 
  getAllDistricts, 
  getDistrictsByProvince 
} from 'srilankan-provinces-districts';

// Get all provinces with detailed data
const provinces: Province[] = getAllProvinces();
console.log(provinces);

## Output 
[
  { id: "western", name: "Western", code: "WP" },
  { id: "central", name: "Central", code: "CP" },
  ...
]


// Get a specific province by name (case-insensitive)
const western: Province | undefined = getProvince('Western');
console.log(western);

### Output
{
  id: "western",
  name: "Western",
  code: "WP"
}

// Get districts in Western province with detailed data
const westernDistricts: District[] = getDistrictsByProvince('Western');
console.log(westernDistricts);

## Output
[
  { id: "colombo", provinceId: "western", name: "Colombo", code: "CMB" },
  { id: "gampaha", provinceId: "western", name: "Gampaha", code: "GMP" },
  { id: "kalutara", provinceId: "western", name: "Kalutara", code: "KLT" }
]

📚 API Reference

Original API

getProvinces()-Returns an array of all province names in Sri Lanka

const provinces = getProvinces();

## Output
// ["Western", "Central", "Southern", "Northern", "Eastern", ...]

getDistricts(provinceName)-Returns an array of all district names in a specific province

const districts = getDistricts("Western");

## Output
// ["Colombo", "Gampaha", "Kalutara"]

TypeScript API

getProvince(nameOrId)-Returns a province by name or ID (case-insensitive)

const province = getProvince("Western"); // Also works with "western" or "WESTERN"

## Output
// { id: "western", name: "Western", code: "WP" }

getAllProvinces()-Returns an array of all provinces with full data

const provinces = getAllProvinces();

## Output
// [{ id: "western", name: "Western", code: "WP" }, ...]

getAllDistricts()-Returns an array of all districts with full data

const districts = getAllDistricts();

##Output
// [{ id: "colombo", provinceId: "western", name: "Colombo", code: "CMB" }, ...]

getDistrictsByProvince(provinceNameOrId)-Returns an array of districts in a specific province

const westernDistricts = getDistrictsByProvince("Western");

## Output
[
   { id: "colombo", provinceId: "western", name: "Colombo", code: "CMB" },
   { id: "gampaha", provinceId: "western", name: "Gampaha", code: "GMP" },
   { id: "kalutara", provinceId: "western", name: "Kalutara", code: "KLT" }
]

🖥️ Framework Examples

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  • Fork the repository
  • Create your feature branch (git checkout -b feature/amazing-feature)
  • Commit your changes (git commit -m 'Add some amazing feature')
  • Push to the branch (git push origin feature/amazing-feature)
  • Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Support

💻 Author