Skip to content

romaindurand/maju

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

maju 🗳️

maju (for majority judgment) is a Javascript library implementing the majority judgment voting system.

More info on majority judgment

Usage

Add maju to your project with npm i maju or yarn add maju

The exposed method allows to create a poll :

const createPoll = require('maju')
const myPoll = createPoll(['Matrix', 'Ghostbusters', 'Terminator', 'Stargate'])

Use the poll's vote() function to cast a vote. The object parameter must have a property for each poll option name. The value must be an integer between 0 and 5 (the higher the better, no "bad" or "excellent" rank to be speaking-language-independant).

myPoll.vote({ Matrix: 5, Stargate: 1, Ghostbusters: 0, Terminator: 2 })

Use the poll's getWinner() function to get the winner's name.

console.log(myPoll.getWinner())

Demo

⚠️ Don't forget to install dev dependancies with yarn or npm i

Refer to demo/index.js for an usage example

  • yarn demo:node for a node-only example
  • yarn demo for a browser usage example

Majority Judgment

Majority judgment is a single-winner voting system. Voters freely grade each candidate in one of several named ranks, for instance from "excellent" to "bad", and the candidate with the highest median grade is the winner.

Ressources

TODO

  • Create test suite (createPoll, votes, getSortedOptions)