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 🙏

© 2024 – Pkg Stats / Ryan Hefner

gallagher

v1.1.0

Published

Calculates the Gallagher Index for an election result.

Downloads

12

Readme

Gallagher index

Calculates the Gallagher index for an election result.

js-semistandard-style NPM Version

The Gallagher index measures an electoral system’s relative disproportionality between votes received and seats allotted in a legislature. As such, it measures the difference between the percentage of votes each party gets, and the percentage of seats each party gets in the resulting legislature -- and it measures this dis-proportionality from all parties collectively in one given election. This collective dis-proportionality from this one election is given a precise score, which can then be used in comparing various levels of proportionality among various elections from various electoral systems.

Use

var gallagher = require('gallagher');

var parties = [
  { name: 'Party A', votes: 1058636, seats: 59 },
  { name: 'Party B', votes: 614937, seats: 34 },
  { name: 'Party C', votes: 247372, seats: 14 },
  { name: 'Party D', votes: 147544, seats: 8 },
  { name: 'Party E', votes: 59237, seats: 0 },
  { name: 'Party F', votes: 31982, seats: 3 },
  { name: 'Party G', votes: 24168, seats: 1 },
  { name: 'Party H', votes: 23889, seats: 1 },
  { name: 'Party I', votes: 13443, seats: 1 },
  { name: 'Party J', votes: 11738, seats: 0 },
  { name: 'Party K', votes: 1714, seats: 0 },
  { name: 'Party L', votes: 1595, seats: 0 },
  { name: 'Party M', votes: 1209, seats: 0 }
];

var result = gallagher(parties); // 2.377974544114885

License

MIT