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

fair-vote-profile

v0.0.7

Published

A voting profile for a fair voting system

Downloads

3

Readme

vote-profile

Voting profile for fair vote aggregation, and a collection of voting rules for deciding on it. The default profile, can calculate any kind of positional vote, and is easily extensible with data structures for pairwise comparisons, approval voting, grading, and multi-stage elections.
The project has a small but growing collection of voting rules, with a configurable elections, the goal is to make it easy to aggregate the opinions, in a way that reflects the preferences of the people who has them, and is otherwise unopinionated, if your interested in helping, please do!

Install it

npm install fair-vote-profile

Use it

var Profile = require('fair-vote-profile'); //require it
var P = new Profile(); //New election
var P2 = new Profile("condercet"); //extend

P.setCandidates(['a','b','d','e']); //these are the candidates;

P.vote(['b','a','d','e']); //vote
P.vote([['b','a'],'e','d']); //vote with a tie
P.vote(['e','d','a']); //incomplete vote
P.vote(['d','b','a','e']);

//your vote is stored in a profile, 

P.score("borda"); // Outputs scores of each candidate, in a borda election.
P.score("black");
P.score("condorcet");
P.score("schulze");
P.score("veto");
P.score("plurality");

The profile is the interface, there will be a simple express server made available soon on a seperate repository.

Contributing Voting Rules

Creating a voting rule is easy, simply make a function that takes a profile as an input, and outputs an object, with the names of the alternatives as keys, and the score of that candidate as values, the profile has a few helper methods: profile.each takes a visitFunction and runs that function on each group of similiar ballots. (e.g. for an object that looks like this {ordering:["a","b","c"],numVotes:33}) look in the folder "methods" for examples.

Contributing Extensions

Some rules require additional information about voters preferences, look at extensions, for some of examples of such additions, remember to add the name of methods into the beginning of the index.js profile initialized as _.noop, I will be creating a better encapsulated plugin system soon, for now be sure to call your method from the profile's vote method.