election-helpers
v0.1.0
Published
Election helpers
Downloads
5
Readme
Election Helpers
Read docs.md or GH pages for documentation
--
Functions
stateNameHash ⇒ string
Example
stateNameHash['01']
// returns 'Alabama'
getStateFipsFromStateAbbr(stateAbbr) ⇒ string
Example
getStateFipsFromStateAbbr('CA')
// => '06'
getStateFipsFromStateAbbr('NY')
// => '36'
stateAbbrToName(stateAbbr) ⇒ string
Example
getStateNameFromStateAbbr('AL')
// returns 'Alabama'
getStateAbbrFromStateFips(stateFips) ⇒ string
Example
getStateAbbrFromStateFips('01')
// returns 'AL'
Example
getStateAbbrFromStateFips('36')
// returns 'NY'
Example
getStateAbbrFromStateFips('XX')
// throws an error
getStateCodeFromCountyFips(countyFips) ⇒ string
Example
getStateCodeFromCountyFips('01001')
// returns '01'
Example
getStateCodeFromCountyFips(01000)
// throws Error
Example
getStateCodeFromCountyFips('01')
// throws Error
candidateVotePercentage(candidateVote, totalVotes) ⇒ number
Example
getPercentageOfVotes(100, 200)
// returns 50
sortCandidatesByVotes(candidates, sortFunction) ⇒ Array
stateFipsToName(stateFips) ⇒ string
Example
stateFipsToName('01')
// returns 'Alabama'
stateAbbrToFips(stateAbbreviation) ⇒ string
Example
getStateFipsFromAbbreviation('NY')
// returns '36'
stateNameToFips(stateName) ⇒ string
Example
getStateFipsFromStateName('Alabama')
// returns '01'
boundariesAvailableForRaceType(raceType) ⇒ array
Example
boundariesAvailableForRaceType('president')
// returns ['state', 'county']
Example
boundariesAvailableForRaceType('senate')
// returns ['state']
Example
boundariesAvailableForRaceType('house')
// returns ['district']
Example
boundariesAvailableForRaceType(2016)
// returns null
isBoundaryAvailableForRaceType(raceType, boundaryType)
Example
isBoundaryAvailableForRaceType('president', 'county')
// returns true
Example
isBoundaryAvailableForRaceType('president', 'state')
// returns true
Example
isBoundaryAvailableForRaceType('president', 'district')
// returns false