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

@lanka-data-layer/admin

v0.1.0

Published

Offline, dependency-free lookup library for Sri Lanka's administrative hierarchy (province, district, DS division, GN division), keyed by official p-codes.

Downloads

129

Readme

@lanka-data-layer/admin

Offline lookup library for Sri Lanka's administrative hierarchy — provinces, districts, DS divisions and GN divisions — keyed by official OCHA COD-AB p-codes.

The full dataset (14,417 units, in English, Sinhala and Tamil) is bundled into the package at build time. There is no network call, no filesystem read, and no runtime dependency: import it and it works, in Node 18+, in the browser, or on an edge runtime. Everything after the first lookup call runs off in-memory indexes built lazily on first use, so the import itself stays cheap.

Install

npm install @lanka-data-layer/admin

Quick start

import {
  getUnit,
  getChildren,
  getParentChain,
  unitsAtLevel,
  searchByName,
} from "@lanka-data-layer/admin";

getUnit("LK11");
// { pcode: "LK11", level: 2, name: "Colombo District",
//   nameSi: "කොළඹ දිස්ත්‍රික්ක", nameTa: "கொழும்பு மாவட்டம்",
//   parentPcode: "LK1", areaKm2: 687.11,
//   centroid: { lat: 6.848501, lon: 80.022807 } }

getUnit("lk11"); // pcode lookup is case-insensitive

getChildren("LK1");
// the districts of Western Province: LK11, LK12, LK13

getParentChain("LK1103005");
// [Sri Lanka, Western Province, Colombo District] — root first,
// excludes LK1103005 itself

unitsAtLevel(2);
// all 25 districts

searchByName("colombo");
// exact name matches rank above prefix matches above substring matches,
// searched case-insensitively across English, Sinhala and Tamil names

searchByName("gampaha", { level: 2, limit: 5 });

The AdminUnit type

interface AdminUnit {
  pcode: string;
  level: 0 | 1 | 2 | 3 | 4; // country, province, district, DS division, GN division
  name: string;
  nameSi: string | null;
  nameTa: string | null;
  parentPcode: string | null;
  areaKm2: number | null;
  centroid: { lat: number; lon: number } | null;
}

API

| Function | Description | |---|---| | getUnit(pcode) | Single unit by p-code, or null. Case-insensitive. | | getChildren(pcode) | Direct children of a unit. | | getParentChain(pcode) | Ancestors from the country root down, excluding the unit itself. | | unitsAtLevel(level) | Every unit at a given level (0–4). | | searchByName(q, opts?) | Name search across all three languages. opts.level restricts to one admin level, opts.limit caps result count (default 10). | | DATA_VERSION | Foundry data release this build was generated from. | | UNIT_COUNT | Total number of units bundled (14,417). | | SOURCES | Provenance array — see below. |

Data

| Source | License | |---|---| | geoBoundaries + OCHA COD-AB Sri Lanka | CC BY 3.0 IGO / CC BY-IGO |

The exact source list bundled with your installed version is also available at runtime as SOURCES, and its release is stamped in DATA_VERSION (format YYYYMMDD.N). Boundaries, names and p-codes are regenerated periodically from the upstream sources by the Lanka Data Layer foundry — the offline ETL pipeline in the monorepo this package is extracted from. To pick up a new data release, upgrade the package; there is no separate data download step.

Gzipped install size is roughly 400KB (per module format — import and require each ship their own bundle with the dataset inlined).

Part of Lanka Data Layer

This package is a standalone extract of the admin-hierarchy dataset that powers Lanka Data Layer, an open geo-data platform for Sri Lanka. If you need more than offline lookups — reverse geocoding, boundary geometry, population and census indicators, postal/admin cross-references, election results — see the hosted API and interactive docs at lanka-data-layer.prabhavalabs.com.

Development

This package is built from within the lanka-data-layer monorepo and has no dependencies or devDependencies of its own; build tooling (tsup, typescript) is provided by the workspace root. See the repository for build instructions.

License

MIT © Prabhava Labs