0.0.2 • Published 4 years ago

@reuters-graphics/electoral-college-permutations v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

npm.io

@reuters-graphics/electoral-college-permutations

npm version Reuters open source software

Quickstart

$ yarn add @reuters-graphics/electoral-college-permutations
import Election2020Scenarios from '@reuters-graphics/electoral-college-permutations';

const outstandingStates = {
  WI: 10,
  MI: 16,
  GA: 16,
  PA: 20,
  NC: 15,
  AZ: 11,
  NV: 6,
  AK: 3,
};
const candidateElectoralVotes = {
  R: 213,
  D: 227,
};

const election2020Scenarios = new Election2020Scenarios(candidateElectoralVotes, outstandingStates);

const scenarios = election2020Scenarios.call('MI', 'D');

// {
//  states: ['WI', 'MI', ...],
//  scenariosByWinner: {
//    R: [
//      {
//         scenario: ['R', 'D', ...],
//         result: { R: 220, D: 230 },
//      },
//      ...
//    ],
//    D: [ {}, ...],
//    Tie: [{}, ...],
//  }
// }

Testing

$ yarn test
0.0.2

4 years ago

0.0.1

4 years ago