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

votes

v3.0.0

Published

Implementation of some [electoral systems](https://en.wikipedia.org/wiki/Electoral_system)

Downloads

43

Readme

votes

version npm bundle size language downloads last commit Libraries.io dependency status for latest release license Build Status Codacy Badge Codacy Badge CodeClimate Coverage CodeClimate Maintainability Code Climate technical debt CodeFactor codecov npms.io (final) npms.io (final) Website

🧑‍💻 Install

yarn add votes

🗳️ Use

import { Borda } from 'votes'

const borda = new Borda({
  candidates: ['Lion', 'Bear', 'Sheep'],
  ballots: [
    { ranking: [['Lion'], ['Bear'], ['Sheep']], weight: 4 },
    { ranking: [['Sheep'], ['Bear'], ['Lion']], weight: 3 },
    { ranking: [['Bear', 'Sheep'], ['Lion']], weight: 2 },
  ],
})

const scores = borda.scores()
// -> { Bear: 10, Lion: 8, Sheep: 9}

const ranking = borda.ranking()
// -> [ [ 'Bear' ], [ 'Sheep' ], [ 'Lion' ] ]

📚 Documentation

📊 Voting systems

Absolute majority: Checks if a candidate is ranked first by more than 50% of voters.

Approval voting: Each voter can select (“approve”) any number of candidates. The winner is the most-approved candidate.

Baldwin method: Iterative Borda count in which, each round, candidates scoring the lowest score are eliminated.

Borda count: For each voter, every candidate is given a number of points which equals the number of candidates ranked lower in the voter's preference.

Bottom-two-runoff: take the two options with the fewest first preference votes. The pairwise loser out of those two options is eliminated. Repeat.

Contingent vote (immediate Two-round system): If no candidate receives 50% of the votes in the first round, then a second round of voting is held with only the top two candidates.

Coombs' method: Each round, the candidate with the most last rank is eliminated. The election repeats until there is a winner.

Copeland's method: Rank candidates by number of duels won against other candidates.

Instant-runoff: Considering only the top choice of each voter, the candidate with the fewest votes is eliminated. The election repeats until there is a winner. This voting system is very similar to single transferable vote method.

Kemeny–Young method: A relatively complex computation generating a preference order aiming to minimize dissatisfaction of the voters. Also known as Kemeny rule, VoteFair popularity ranking, the maximum likelihood method, and the median relation.

Maximal lotteries & Randomized Condorcet: Returns probabilities for each candidate that should be used for a lottery between the Candidates. If a candidate is the Condorcet winner, its probability will be 1. Despite being non-deterministic, those methods are the fairest. Currently, these methods give incorrect results in many cases because of mistakes in the codes!

Majority Judgement: (⚠️ cardinal voting system). Voters can rank candidates in an array corresponding to 6 categories ("Excellent", "Very good", "Good", "Passable", "Mediocre" and "Bad"). Candidates with the best median are ranked first.

Minimax Condorcet method: Ranking the candidates by smallest pairwise defeat.

Minimax-TD: Compute the Smith set . Then compute the Minimax ranking on that set. TD stands for Tideman-Darlington.

Nanson method: Iterative Borda count in which, each round, candidates scoring the average score or less are eliminated.

Plurality: Simple voting method where only the preferred candidate of each voter gets 1 point. AKA first-past-the-post.

Random candidate: Selects a random ranking, regardless of ballots.

Random dictator: Selects a random ballot that decides the ranking.

Ranked pairs: Using the duel results as edges, build an acyclic graph starting by the strongest score differences. The roots of the graph are the winners.

Schulze method: From the votes, compute the results of all possible duels. Then remove the most indecisive (closest to 50/50) duels until there is an undefeated candidate, the winner. This popular voting system is used by several organizations (Ubuntu, Debian, Wikimedia...).

Smith's method: All members of the top cycle (a.k.a. Smith set): "the smallest non-empty set of candidates in a particular election such that each member defeats every candidate outside the set in a pairwise election"

🤝 Contributing

Contributions, issues and feature requests are welcome! Feel free to check issues page.

The repository is split in 2 projects:

  • /votes contains the source of the NPM package votes

  • /demo contains the source of the demo website