Skip to content

JavaScript helper methods to retrieve congressional district numbers and U.S. state using U.S. zip code

License

Notifications You must be signed in to change notification settings

pwbrown/congressional-districts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Congressional Districts


JavaScript helper methods to retrieve congressional district numbers and U.S. state using U.S. zip code

****Based on the 113th congressional districts Data Source

Add it

  1. $ npm install congressional-districts --save
var districts = require('congressional-districts');

Methods

###Retrieve an array of all the district numbers from a specified zip code

var zipcode = "12345";
//or
var zipcode = 12345;
var returnedDistricts = districts.getDistricts(zipcode);

//returnedDistricts is now an array of district strings(["1","3"]);

//***Note: will return an empty array if the zip code was not found;

###Confirm that a zipcode is part of a specified district

var zipcode = 12345;
var district = 3;
var confirmed = districts.confirm(zipcode, district);

//this will return true if it is found, false if it isn't, and a -1 if the zip code was not found

###Retrieve the number of districts for a specified state

var state = "North Carolina";  //syntax is not too important, as long as there is either a " " or "_" between words
var numberOfDistricts = districts.getNumOfDistricts(state);

//numberOfDistricts will now contain a number corresponding to the number of districts for the state inputted

**** The data for this pluggin is likely to change yearly if not more, so create an issue if it is out of date, and I will try and update if possible

About

JavaScript helper methods to retrieve congressional district numbers and U.S. state using U.S. zip code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published