New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

highest-averages

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

highest-averages

Zero-dependency and extensible set of highest averages methods for allocating seats in a parliament. ### Install ```shell npm i highest-averages ``` ### Pure Example - Define the candidates with their vote ```typescript const a = new Candidate('A', 200) c

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

highest-averages

Zero-dependency and extensible set of highest averages methods for allocating seats in a parliament.

Install

npm i highest-averages

Pure Example

  • Define the candidates with their vote
const a = new Candidate('A', 200)
const b = new Candidate('B', 140)
const c = new Candidate('C', 70)
  • Implement divisor function
const divisor: Divisor = new class implements Divisor {
  next (iteration: number): number {
    return iteration + 2
  }
}
  • Define the highest averages method
const highestAverage = new HighestAverage(divisor)
  • Get the results for 5 seats
const result = highestAverage
  .withSeat(5)
  .withCandidates([a, b, c])
  .apply()

result.forEach(candidate => console.log(`${candidate.name()}:${candidate.seat}`))
  • Result
A:3
B:2
C:0
  • Selection table of example
12345Result
A100*66.6666.66*50*403
B7070*46.6646.6646.66*2
C35353535350

Predefined Highest Averages Methods

  • D'Hondt
const result = new DHondt()
  .withSeat(5)
  .withCandidates([])
  .apply()
  • Sainte-Laguë
const result = new SainteLague()
  .withSeat(5)
  .withCandidates([])
  .apply()
  • Imperiali
const result = new Imperiali()
  .withSeat(5)
  .withCandidates([])
  .apply()
  • Huntington–Hill
const result = new HuntingtonHill()
  .withSeat(5)
  .withCandidates([])
  .apply()
  • Danish
const result = new Danish()
  .withSeat(5)
  .withCandidates([])
  .apply()

Election Implementations (examples)

  • Greenland general election (Inatsisartut) (2018, 2021)
  • Dutch general election (Tweede Kamer der Staten-Generaal) (2017, 2021)
  • San Marino general election (Consiglio Grande e Generale) (2019)

Keywords

highest averages

FAQs

Package last updated on 09 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts