Skip to content

Latest commit

 

History

History
39 lines (24 loc) · 866 Bytes

README.md

File metadata and controls

39 lines (24 loc) · 866 Bytes

meek-stv

a lightweight meek stv javascript library

based on caritat

Usage

import Election and Ballot from the package

import { Election, Ballot } from "meek-stv";

create a new election with the available options and your candidates

const candidates = ["Epic", "Cool", "Nice", "Great"];

const election = new Election({ candidates });

add the ballots to the election

election.addBallot(new Ballot(["Cool", "Epic", "Great", "Nice"], 29));

election.addBallot(new Ballot(["Epic", "Cool", "Great", "Nice"], 13));

election.addBallot(new Ballot(["Great", "Epic", "Cool", "Nice"], 38));

election.addBallot(new Ballot(["Nice", "Epic", "Cool", "Great"], 15));

run the election with the amount of seats you want elected and get the results

const results = election.run(1);