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

@devmubs/pakistan-cities

v1.0.0

Published

Zero-dependency dataset + API of all Pakistani cities across provinces and territories. Works in Node and the browser, no backend or network calls required.

Readme

@devmubs/pakistan-cities

Zero-dependency dataset + API of every city in Pakistan — all 4 provinces, plus Azad Jammu & Kashmir, Gilgit-Baltistan, and the Islamabad Capital Territory.

No backend, no fetch, no API key. The data ships inside the package and runs entirely client-side or server-side — works in Node, React, Vue, plain HTML, anywhere JavaScript runs.

Install

npm install @devmubs/pakistan-cities

Also works with other package managers:

yarn add @devmubs/pakistan-cities
pnpm add @devmubs/pakistan-cities

Or run it directly with npx — no install needed

npx @devmubs/pakistan-cities search lahore
npx @devmubs/pakistan-cities province Sindh
npx @devmubs/pakistan-cities capitals
npx @devmubs/pakistan-cities count

Full CLI command list:

| Command | Example | |---|---| | search <name> | npx @devmubs/pakistan-cities search multan | | city <name> | npx @devmubs/pakistan-cities city lahore | | province <name> | npx @devmubs/pakistan-cities province Punjab | | provinces | npx @devmubs/pakistan-cities provinces | | capitals | npx @devmubs/pakistan-cities capitals | | list | npx @devmubs/pakistan-cities list | | count | npx @devmubs/pakistan-cities count | | help | npx @devmubs/pakistan-cities help |

Every command prints JSON to stdout, so you can pipe it straight into jq, a file, or another script.

Quick start

const PakistanCities = require('@devmubs/pakistan-cities');

PakistanCities.count();               // 191
PakistanCities.search('lahore');      // [{ city: 'Lahore', province: 'Punjab', capital: true }]
PakistanCities.getByProvince('Sindh'); // all Sindh cities

ESM / TypeScript:

import PakistanCities from '@devmubs/pakistan-cities';

const results = PakistanCities.search('gwadar');

CDN (no npm install, no bundler)

Just drop this at the bottom of your <body> — works on plain HTML pages, no build step:

<script src="https://unpkg.com/@devmubs/pakistan-cities/dist/pakistan-cities.min.js"></script>
<script>
  console.log(PakistanCitiesAPI.count());          // 191
  console.log(PakistanCitiesAPI.search('lahore'));  // [{ city: 'Lahore', ... }]
</script>

jsDelivr also works, and you can pin a version once published:

<script src="https://cdn.jsdelivr.net/npm/@devmubs/pakistan-cities@1/dist/pakistan-cities.min.js"></script>

This CDN build exposes a single global — window.PakistanCitiesAPI — with the exact same methods as the npm import. Same dataset, same API, zero dependencies either way.

API

| Method | Returns | Description | |---|---|---| | getAll() | PakistanCity[] | Every city, unfiltered | | getProvinces() | string[] | The 7 provinces/territories | | getByProvince(name) | PakistanCity[] | Cities in a province (case-insensitive) | | search(query, options?) | PakistanCity[] | Substring match on city name. options.limit caps results | | getCity(name) | PakistanCity \| undefined | Exact case-insensitive lookup | | getCapitals() | PakistanCity[] | The capital of each province/territory | | count() | number | Total number of cities | | isValidProvince(name) | boolean | Validate a province name | | toOptions(province?) | {value, label}[] | Ready-made list for <select> dropdowns |

Each city object looks like:

{ city: string, province: string, capital?: boolean }

Recipes

Cascading <select> (Province → City)

const provinceSelect = document.querySelector('#province');
const citySelect = document.querySelector('#city');

PakistanCities.getProvinces().forEach((p) => {
  provinceSelect.add(new Option(p, p));
});

function fillCities(province) {
  citySelect.innerHTML = '';
  PakistanCities.toOptions(province).forEach((opt) => {
    citySelect.add(new Option(opt.label, opt.value));
  });
}

provinceSelect.addEventListener('change', (e) => fillCities(e.target.value));
fillCities(provinceSelect.value);

Autocomplete field

input.addEventListener('input', () => {
  const matches = PakistanCities.search(input.value, { limit: 8 });
  renderDropdown(matches);
});

Form validation

function validateCityField(cityName, provinceName) {
  const city = PakistanCities.getCity(cityName);
  if (!city) return 'Unknown city';
  if (city.province !== provinceName) return 'City does not belong to selected province';
  return null;
}

Why this exists

Most "Pakistan cities" packages on npm are either abandoned, missing AJK/Gilgit-Baltistan, or require a network call. This one is a flat, static, dependency-free dataset — safe to bundle into a frontend build with zero runtime cost.

License

MIT © Usama Saleem