@reuters-graphics/electoral-college-permutations

[![npm version](https://badge.fury.io/js/%40reuters-graphics%2Felectoral-college-permutations.svg)](https://badge.fury.io/js/%40reuters-graphics%2Felectoral-college-permutations) [![Reuters open source software](https://badgen.net/badge/Reuters/open%20sou

Usage no npm install needed!

<script type="module">
  import reutersGraphicsElectoralCollegePermutations from 'https://cdn.skypack.dev/@reuters-graphics/electoral-college-permutations';
</script>

README

@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