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

v0.1.0

Published

Offline Sri Lankan election results — 2024 parliamentary and 2015/2019/2024 presidential, by district, polling division, and postal vote. Zero dependencies.

Readme

@lanka-data-layer/electoral

Offline Sri Lankan election results — 2024 parliamentary and the 2015, 2019, and 2024 presidential elections, broken down by electoral district, polling division, and postal vote, plus the national total. 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/electoral

Quick start

import {
  listElections,
  getElection,
  listEntities,
  getEntity,
  listParties,
  getResult,
  resultsForElection,
  resultsForEntity,
} from "@lanka-data-layer/electoral";

listElections();
// [{ id: "parl-2024", type: "parliamentary", year: 2024, date: "2024-11-14", label: "2024 Parliamentary" }, ...]

getElection("pres-2024");
// { id: "pres-2024", type: "presidential", year: 2024, date: "2024-09-21", label: "2024 Presidential" }

listEntities().length; // 205 — electoral districts, polling divisions, postal-vote entities, and "LK" (national)

getEntity("EC-01");
// { id: "EC-01", kind: "ED", name: "Colombo", edId: "EC-01" }

listParties().find((p) => p.electionId === "parl-2024" && p.code === "NPP");
// { electionId: "parl-2024", code: "NPP", candidate: "...", name: "National People's Power", color: "#dc2626" }

getResult("parl-2024", "EC-01");
// {
//   electors: 1765351, polled: 1211738, valid: 1149125, rejected: 62613,
//   turnout: 0.6864,
//   winner: { party: "NPP", votes: 788636, share: 0.6863 },
//   parties: [{ party: "NPP", votes: 788636, share: 0.6863 }, ...]
// }

resultsForElection("parl-2024");   // every entity's result for one election, each tagged with entityId
resultsForEntity("EC-01");         // one entity's result across every election it appears in, tagged with electionId

getResult, resultsForElection, and resultsForEntity all return null (or an empty array, for the list forms) when given an id this dataset doesn't cover — there's no need to wrap calls in try/catch.

Data model

  • Election{ id, type, year, date, label }. Four elections total: parl-2024, pres-2015, pres-2019, pres-2024.
  • ElectoralEntity{ id, kind, name, edId }, where kind is one of "ED" (electoral district), "PD" (polling division), "POSTAL" (a district's postal-vote entity), or "NATIONAL" (the country total, id "LK"). edId is the parent electoral district's id, or null for the national entity.
  • Party{ electionId, code, candidate, name, color }, one row per party per election it contested (a party's candidate, display name, and color can differ between elections). This list covers the notable contesting parties, not every candidate — Result.parties below is the exhaustive one.
  • Result{ electors, polled, valid, rejected, turnout, winner, parties }. turnout is polled / electors to four decimal places (null if electors is 0). winner is { party, votes, share } with share as a fraction of valid votes, or null if the source recorded no winner. parties is every party code the source recorded for that result, descending by votes, each with its own share of valid.

All types are exported — Election, ElectoralEntity, ElectoralEntityKind, Party, Result, PartyResult, Winner, ResultForElection, ResultForEntity, SourceAttribution.

Data provenance

| Source | License | |---|---| | Election Commission of Sri Lanka, via nuuuwan/lk_elections | Open |

The same attribution is exported at runtime as SOURCES: SourceAttribution[].

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 election data changes. If you need results for an election this snapshot doesn't cover yet, 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 results are served at lanka-data-layer.prabhavalabs.com (GET /v1/elections, GET /v1/elections/:id/results/:entity). See also @lanka-data-layer/census for population and demographic indicators.

License

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