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/census

v0.1.0

Published

Offline Sri Lankan census indicators — 2024 population, age structure, ethnicity, and religion for the country, every district, and every DS division, with a 2012-census comparison. Zero dependencies.

Downloads

87

Readme

@lanka-data-layer/census

Offline Sri Lankan census indicators — 2024 population, age structure, ethnicity, and religion for the country, all 25 districts, and all 339 DS divisions (365 p-coded units in total), plus a 2012-vs-2024 comparison for the 25 districts. The dataset ships inside the package: no network calls, no filesystem reads, nothing to configure. Works in Node 18+, browsers, and edge runtimes (Workers, Deno, Bun) alike — it's just data and pure functions.

Install

npm install @lanka-data-layer/census

Quick start

import { CENSUS_YEAR, coveredPcodes, population, ethnicity, religion, demographics } from "@lanka-data-layer/census";

CENSUS_YEAR; // 2024

coveredPcodes().length; // 365 — country ("LK") + 25 districts + 339 DS divisions

population("LK11");
// { total: 2375415, male: 1154799, female: 1220616,
//   ages: { "0-14": 392721, "15-59": 1525340, "60-64": 136268, "65+": 321086 } }

ethnicity("LK11");
// [{ key: "sinhala", count: 1807945, share: 0.7611 }, { key: "moor", count: 285346, share: 0.1201 }, ...]

religion("LK11");
// [{ key: "buddhist", count: 1682524, share: 0.7083 }, ...]

demographics("LK11");
// {
//   pcode: "LK11", censusYear: 2024,
//   population: { total: 2375415, male: 1154799, female: 1220616, sexRatio: 94.6, femaleShare: 0.5139 },
//   age: {
//     buckets: [{ bucket: "0-14", count: 392721, share: 0.1653 }, ...],
//     dependencyRatio: 43, workingAgeShare: 0.6995, childShare: 0.1653, elderlyShare: 0.1352,
//   },
//   ethnicity: [...], religion: [...],
//   change2012: {
//     ethnicity: [{ key: "sinhala", share2012: 0.7454, share2024: 0.7611, delta: 0.0157 }, ...],
//     religion: [...],
//   },
// }

Every function returns null for a p-code this dataset doesn't cover — there's no need to wrap calls in try/catch. population, ethnicity, and religion cover all 365 p-codes; GN divisions (level 4) are outside 2024 census coverage and always resolve to null.

Data model

  • population(pcode) — raw 2024 counts: { total, male, female, ages }, where ages is keyed by the census's four coarse buckets ("0-14", "15-59", "60-64", "65+" — the published tables carry no finer breakdown and no sex-by-age cross-tabulation).
  • ethnicity(pcode) / religion(pcode){ key, count, share }[], descending by count. share is a fraction of the group's own total (all ethnicity counts, or all religion counts), four decimal places.
  • demographics(pcode) — the full derived profile, matching the indicators served by the hosted API's /v1/demographics endpoint: population with sexRatio (males per 100 females) and femaleShare; age with per-bucket shares plus dependencyRatio ((0-14 + 65+) / (15-59 + 60-64) * 100), workingAgeShare, childShare, and elderlyShare; ethnicity and religion breakdowns; and change2012, a 2012-vs-2024 comparison restricted to keys present in both census years, null for any p-code outside the 25 districts the 2012 census covered.
  • coveredPcodes() — every p-code with 2024 census data, for iterating the full dataset or checking coverage up front.

All types are exported — Population, StatEntry, AgeBucket, AgeBucketShare, ChangeEntry, Demographics, SourceAttribution.

Data provenance

| Source | License | |---|---| | Department of Census and Statistics, Sri Lanka | Not stated (government statistical publication) |

The same attribution is exported at runtime as SOURCES: SourceAttribution[]. The Department of Census and Statistics publishes the 2024 Census of Population and Housing tables without explicit license terms on the source pages; this package reproduces them as a public government statistical publication, with full attribution.

Versioning and freshness

DATA_VERSION (format YYYYMMDD.N) is exported alongside the data and tracks the build that produced it — compare it against a previously cached value to detect a stale copy. This package is a point-in-time snapshot generated by the Lanka Data Layer monorepo's foundry ETL pipeline; a new release is cut whenever the underlying census data changes. If you need indicators this snapshot doesn't cover, check the hosted API or open an issue.

Part of Lanka Data Layer

This package is one piece of Lanka Data Layer, an open geo-data platform for Sri Lanka — reverse geocoding, universal search, postal codes, population, and election results for every GN division, DS division, district, and province on the island. If you'd rather query this data over HTTP instead of bundling it, the same indicators are served at lanka-data-layer.prabhavalabs.com (GET /v1/demographics/:pcode). See also @lanka-data-layer/electoral for election results.

License

MIT — see LICENSE. Census data remains under the source's own terms (see Data provenance above); please preserve attribution to the Department of Census and Statistics, Sri Lanka in anything you build with it.