UNPKG

ecclesia

Version:

Framework for political and electoral simulations

31 lines (30 loc) 1.1 kB
/** * The results of a binary vote. * The blank votes are not counted. To calculate a threshold on the whole * number of members, use vote.votesFor / house.nSeats. * To calculate the threshold on the number of duly elected members, use * vote.votesFor / sum(house.members.values()). */ export declare class Vote { readonly votesFor: number; readonly votesAgainst: number; constructor(votesFor: number, votesAgainst: number); /** * Returns the reverse of the vote, inverting the for/against ratio. * Simulates a vote on the opposite motion. */ get neg(): Vote; get votesCast(): number; /** * Returns the ratio of votes for over the total number of votes cast. * If there are no votes cast, returns an Infinity. */ get ratio(): number; /** * Compares two votes in order of decreasing ratio. * The ties will be ordered by decreasing number of positive votes, * and then by the order they came in. * This is a function to be passed to Array.prototype.sort. */ static compare(a: Vote, b: Vote): number; }