Skip to content

Releases: HDv2b/apportionment

3.0.0 Alpha

07 Feb 20:32

Choose a tag to compare

3.0.0 Alpha Pre-release
Pre-release
  • Modernized toolchain with Biome and Vitest.
  • Tree-shakeable library.

Breaking changes

Reverted to the simplicity of v1 while keeping the verbosity of v2 with extra control.

  • All methods now output the same format to allow easier switching by the user. This format is minimal for simplicity and performance.
  • An optional callback function can be used to log each step of the calculation, for debugging or educational purposes.
function myLogger(calculationStep, data) {
  console.log(calculationStep, data)
}

const result1 = adams([21878, 9713, 4167, 3252, 1065], 43, myLogger);
const result2 = adams([9, 5, 9, 1, 3, 5, 8], 20);

// result1 = { exact: [22, 10, 5, 4, 2] }
// result2 =
// {
//   low: [4, 2, 4, 1, 2, 2, 4],
//   high: [4, 3, 4, 1, 2, 3, 4],
// }

// console output:
/*
> "SUM_POP", 40075
> "INIT_DIVISOR", 931.9767441860465
> "INIT_QUOTIENTS"}, [23.47483468496569, 10.421933873986276, 4.4711416094822205,3.489357454772302, 1.14273237679351 
> "INIT_ALLOCATION", [24, 11, 5, 4, 2]
> "INIT_SEATS", 46
> ... etc
 */

2.0.3 - Added "workings out"

25 Apr 16:37

Choose a tag to compare

Same methods as available in v1. Changed outputs to include "workings out" rather than just the final result. Useful for debugging or academic purposes, where you might wish to see how the results were calculated, step-by-step.

If you prefer to just have a simpler output with just the final results and no need for the calculation steps, then you may prefer v1

NPM

1.0.9 - First release

25 Apr 16:10

Choose a tag to compare

Provides following methods:

  • Hamilton
  • Jefferson
  • Adams
  • Webster
  • Huntington-Hill

Simply outputs final result of calculations, this is the best release to use if that's all you need.

NPM