Source: compute/socialChoiceMethods/dHondt.js

  1. /** @module */
  2. import * as types from '@paretoman/votekit-types'
  3. import divisorGeneral from './divisorGeneral.js'
  4. /**
  5. * Run the d'Hondt / Jefferson method of apportionment and return an allocation of seats.
  6. * @param {types.typesVotes.votes} votes - The object for vote data.
  7. * @param {types.typesSocialChoice.socialChoiceOptions} socialChoiceOptions - options to specify a social choice function.
  8. * @returns {types.typesSocialChoice.socialChoiceResults} - the results returned from a social choice function.
  9. */
  10. export default function dHondt(votes, socialChoiceOptions) {
  11. const typeOfDivisor = 'dHondt'
  12. const socialChoiceResults = divisorGeneral(votes, socialChoiceOptions, typeOfDivisor)
  13. return socialChoiceResults
  14. }
  15. /** @constant {object} - an object: this function and descriptions of its name, input, and output */
  16. export const dHondtMetadata = {
  17. name: "d'Hondt",
  18. shortName: "d'Hondt",
  19. functionName: 'dHondt',
  20. voteCasterName: 'plurality', // for input
  21. socialChoiceType: 'allocation',
  22. elect: dHondt,
  23. }