8000 GitHub - Applifting/stv: STV (Single Transferable Vote) implementation in TypeScript
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Applifting/stv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Single Transferable Vote (STV) NPM library

TypeScript implementation of STV algorithm without any runtime dependencies.

Getting started

Add the library into your project using either:

npm add stv

or

yarn add stv

Import it into your project:

import { stv } from 'stv';

Usage

To evaluate election using STV, invoke the algorithm by calling the stv(opts) function:

const results = stv({
  seatsToFill: 2,
  candidates: ["Wonderwoman", "Superman", "Batman", "Iron Man"],
  votes: [
    {
      weight: 1,
      preferences: ["Wonderwoman", "Batman"]
    },
    {
      weight: 1,
      preferences: ["Iron Man", "Batman"]
    },
    {
      weight: 1,
      preferences: ["Iron Man"]
    }
  ],
  report: console.log
});

Which STV counting method is implemented?

Currently, the Scottish STV rules are implemented. There may be more variants in the future.

License 📜

The stv library is licensed under MIT license.

About

STV (Single Transferable Vote) implementation in TypeScript

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  
0