Giter Club home page Giter Club logo

zip3's Introduction

zip3

Background

Using the first three digits of a US zip code, you can roughly approximate which metropolitan area that zip code is associated with.

Demo

zip3 gif

Code Sandbox: https://codesandbox.io/s/zip3-demo-rj8oc

Data

https://en.wikipedia.org/wiki/List_of_ZIP_Code_prefixes

High Level Design

This package exports a dictionary where the keys are the three-digit zip code prefixes, and the values are objects containing id (the three-digit zip), city, and state (if available).

For example:

{
  "440": { "id": "440", "city": "Cleveland", "state": "OH" }
}

Usage

import { useState } from "react"
import zips from "zip3"

function MetroParser() {
  const [zip, setZip] = useState("90210")
  const shortenedZip = zip.slice(0, 3)
  const metroObject = zips[shortenedZip] || {}
  const { city, state } = metroObject
  const metroString = city && state ? `${city}, ${state}` : ""

  return (
    <div>
      <label>
        Zip code:
        <input
          type="number"
          placeholder="44114"
          value={zip}
          onChange={(e) => {
            const { value } = e.target
            setZip(value)
          }}
        ></input>
      </label>
      <p>Metro: {metroString}</p>
    </div>
  )
}

zip3's People

Contributors

billfienberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

zip3's Issues

Identify unique metro areas

[
"Aberdeen, SD",
"Abilene, TX",
"Akron, OH",
"Alamosa, CO",
"Albany, GA",
"Albany, KY",
"Albany, NY",
"Albuquerque, NM",
"Alexandria, LA",
"Alexandria, VA",
"Alhambra, CA",
"Allentown, PA",
"Alliance, NE",
"Altoona, PA",
"Amarillo, TX",
"Amityville, NY",
"Anaheim, CA",
"Anchorage, AK",
"Andover, MA",
"Andrews, NC",
"Annapolis Junction, MD",
"Annapolis, MD",
"Anniston, AL",
"Ardmore, OK",
"Arlington, VA",
"Asheville, NC",
"Ashland, KY",
"Athens, GA",
"Athens, OH",
"Atlanta, GA",
"Atlantic City, NJ",
"Auburn, ME",
"Augusta, GA",
"Augusta, ME",
"Austin, TX",
"Bakersfield, CA",
"Baltimore, MD",
"Bangor, ME",
"Barrigada, GU",
"Batesville, AR",
"Bath, ME",
"Baton Rouge, LA",
"Beaufort, SC",
"Beaumont, TX",
"Beckley, WV",
"Bellows Falls, VT",
"Bemidji, MN",
"Bend, OR",
"Bennington, VT",
"Berkeley, CA",
"Bethesda, MD",
"Billings, MT",
"Binghamton, NY",
"Birmingham, AL",
"Bismarck, ND",
"Bloomington, IL",
"Bloomington, IN",
"Bluefield, WV",
"Boise, ID",
"Boston, MA",
"Boulder, CO",
"Bowling Green, KY",
"Bradenton, FL",
"Bradford, PA",
"Brainerd, MN",
"Brattleboro, VT",
"Bridgeport, CT",
"Bridgeton, NJ",
"Brighton, CO",
"Bristol, VA",
"Brockton, MA",
"Brookhaven, MS",
"Brooklyn, NY",
"Brooksville, FL",
"Brownwood, TX",
"Bryan, TX",
"Buffalo, NY",
"Burbank, CA",
"Burlington, IA",
"Burlington, VT",
"Butler, PA",
"Butte, MT",
"Cadillac, MI",
"Camden, AR",
"Camden, NJ",
"Campton, KY",
"Canton, OH",
"Cape Cod, MA",
"Cape Girardeau, MO",
"Carbondale, IL",
"Carrizozo, NM",
"Carroll, IA",
"Carson City, NV",
"Casper, WY",
"Cecil County, MD",
"Cedar Rapids, IA",
"Centralia, IL",
"Chambersburg, PA",
"Charleston, SC",
"Charleston, WV",
"Charlotte, NC",
"Charlottesville, VA",
"Chattanooga, TN",
"Cherry Hill, NJ",
"Cheyenne, WY",
"Chicago, IL",
"Childress, TX",
"Chillicothe, MO",
"Chillicothe, OH",
"Cincinnati, OH",
"Clarksburg, WV",
"Cleveland, OH",
"Clinton, OK",
"Clovis, NM",
"Colby, KS",
"Colorado Springs, CO",
"Columbia, MO",
"Columbia, SC",
"Columbia, TN",
"Columbus, GA",
"Columbus, IN",
"Columbus, MS",
"Columbus, NE",
"Columbus, OH",
"Concord, NH",
"Concordia, KS",
"Conroe, TX",
"Cookeville, TN",
"Corbin, KY",
"Corpus Christi, TX",
"Council Bluffs, IA",
"Creston, IA",
"Culpeper, VA",
"Cumberland, MD",
"Dallas, TX",
"Davenport, IA",
"Dayton, OH",
"Daytona Beach, FL",
"Decatur, AL",
"Decorah, IA",
"Denton, TX",
"Denver, CO",
"Des Moines, IA",
"Detroit Lakes, MN",
"Detroit, MI",
"Devils Lake, ND",
"Dickinson, ND",
"Dodge City, KS",
"Dothan, AL",
"Dover, DE",
"Dover, NJ",
"Doylestown, PA",
"DuBois, PA",
"Dubuque, IA",
"Dulles, VA",
"Duluth, MN",
"Durango, CO",
"Durant, OK",
"Durham, NC",
"East St. Louis, IL",
"East Stroudsburg, PA",
"Easton, MD",
"Eau Claire, WI",
"Effingham, IL",
"El Paso, TX",
"Elizabeth City, NC",
"Elizabeth, NJ",
"Elizabethtown, KY",
"Elko, NV",
"Ellsworth, ME",
"Elmira, NY",
"Ely, NV",
"Emporia, KS",
"Enid, OK",
"Erie, PA",
"Eugene, OR",
"Eureka, CA",
"Evanston, IL",
"Evansville, IN",
"Everett, WA",
"Evergreen, AL",
"Fairbanks, AK",
"Far Rockaway, NY",
"Fargo, ND",
"Farmington, NM",
"Farmville, VA",
"Fayetteville, AR",
"Fayetteville, NC",
"Fitchburg, MA",
"Flagstaff, AZ",
"Flint, MI",
"Floral Park, NY",
"Florence, SC",
"Flushing, NY",
"Fort Dodge, IA",
"Fort Lauderdale, FL",
"Fort Morgan, CO",
"Fort Myers, FL",
"Fort Pierce, FL",
"Fort Scott, KS",
"Fort Smith, AR",
"Fort Wayne, IN",
"Fort Worth, TX",
"Framingham, MA",
"Frankfort, KY",
"Frederick, MD",
"Fredericksburg, VA",
"Fresno, CA",
"Gadsden, AL",
"Gainesville, FL",
"Gainesville, GA",
"Galesburg, IL",
"Gallup, NM",
"Gary, IN",
"Glendale, AZ",
"Glendale, CA",
"Glens Falls, NY",
"Glenwood Springs, CO",
"Globe, AZ",
"Golden, CO",
"Grand Forks, ND",
"Grand Island, NE",
"Grand Junction, CO",
"Grand Rapids, MI",
"Great Falls, MT",
"Green Bay, WI",
"Greenfield, MA",
"Greensboro, NC",
"Greensburg, PA",
"Greenville, MS",
"Greenville, SC",
"Greenville, TX",
"Grenada, MS",
"Gulfport, MS",
"Hackensack, NJ",
"Hammond, LA",
"Hannibal, MO",
"Harrisburg, PA",
"Harrison, AR",
"Harrisonburg, VA",
"Harrisonville, MO",
"Hartford, CT",
"Hastings, NE",
"Hattiesburg, MS",
"Havre, MT",
"Hays, KS",
"Hazard, KY",
"Hazleton, PA",
"Helena, MT",
"Hickory, NC",
"Hicksville, NY",
"Holtsville, NY",
"Honolulu, HI",
"Hot Springs, AR",
"Houlton, ME",
"Houston, TX",
"Huntington, WV",
"Huntsville, AL",
"Hutchinson, KS",
"Idaho Falls, ID",
"Independence, KS",
"Indiana, PA",
"Indianapolis, IN",
"Indio, CA",
"Inglewood, CA",
"Iron Mountain, MI",
"Irvine, CA",
"Jackson, MI",
"Jackson, MS",
"Jackson, TN",
"Jackson, WY",
"Jacksonville, FL",
"Jamaica, NY",
"Jamestown, ND",
"Jamestown, NY",
"Jasper, AL",
"Jefferson City, MO",
"Jersey City, NJ",
"Johnson City, TN",
"Johnstown, PA",
"Jonesboro, AR",
"Joplin, MO",
"Juneau, AK",
"Kalamazoo, MI",
"Kalispell, MT",
"Kankakee, IL",
"Kansas City, KS",
"Kansas City, MO",
"Keene, NH",
"Kemmerer, WY",
"Ketchikan, AK",
"Kingman, AZ",
"Kingston, NY",
"Kinston, NC",
"Kirksville, MO",
"Kittanning, PA",
"Klamath Falls, OR",
"Knoxville, TN",
"Kokomo, IN",
"La Crosse, WI",
"La Grange, TX",
"LaSalle, IL",
"Lafayette, IN",
"Lafayette, LA",
"Lake Charles, LA",
"Lakeland, FL",
"Lakewood, NJ",
"Lancaster, PA",
"Lansing, MI",
"Las Cruces, NM",
"Las Vegas, NM",
"Las Vegas, NV",
"Lawton, OK",
"Lehigh Valley, PA",
"Lewisburg, WV",
"Lewiston, ID",
"Lexington, KY",
"Lexington, MA",
"Liberal, KS",
"Lima, OH",
"Lincoln, NE",
"Little Rock, AR",
"Littleton, NH",
"Logan, WV",
"Long Beach, CA",
"Long Island City, NY",
"Longmont, CO",
"Longview, TX",
"Los Angeles, CA",
"Louisville, KY",
"Lubbock, TX",
"Lufkin, TX",
"Lynchburg, VA",
"Lynn, MA",
"Mackinaw City, MI",
"Macon, GA",
"Madison, WI",
"Manchester, NH",
"Mankato, MN",
"Mansfield, OH",
"Marion, OH",
"Martinsburg, WV",
"Marysville, CA",
"Mason City, IA",
"McAlester, OK",
"McAllen, TX",
"McCook, NE",
"McKenzie, TN",
"Medford, OR",
"Melbourne, FL",
"Memphis, TN",
"Meridian, MS",
"Mesa, AZ",
"Metairie, LA",
"Miami, FL",
"Midland, TX",
"Miles City, MT",
"Military, AA",
"Military, AE",
"Military, AP",
"Milwaukee, WI",
"Mineola, NY",
"Minneapolis, MN",
"Minot, ND",
"Missoula, MT",
"Mitchell, SD",
"Mobile, AL",
"Mobridge, SD",
"Mojave, CA",
"Monroe, LA",
"Montgomery, AL",
"Monticello, NY",
"Montpelier, VT",
"Montrose, CO",
"Montrose, PA",
"Morgantown, WV",
"Muncie, IN",
"Muskogee, OK",
"Naples, FL",
"Nashville, TN",
"New Brunswick, NJ",
"New Castle, PA",
"New Haven, CT",
"New London, CT",
"New Orleans, LA",
"New Rochelle, NY",
"New York, NY",
"Newark, NJ",
"Newcastle, WY",
"Newport News, VA",
"Niagara Falls, NY",
"Norfolk, NE",
"Norfolk, VA",
"Norristown, PA",
"North Hollywood, CA",
"North Platte, NE",
"Oak Park, IL",
"Oakland, CA",
"Ocala, FL",
"Ogden, UT",
"Oil City, PA",
"Oklahoma City, OK",
"Olympia, WA",
"Omaha, NE",
"Opelika, AL",
"Orlando, FL",
"Oshkosh, WI",
"Ottumwa, IA",
"Overland Park, KS",
"Owensboro, KY",
"Paducah, KY",
"Palestine, TX",
"Palo Alto, CA",
"Panama City, FL",
"Paoli, PA",
"Park Hills, MO",
"Parkersburg, WV",
"Pasadena, CA",
"Pasadena, TX",
"Pasco, WA",
"Paterson, NJ",
"Pendleton, OR",
"Pensacola, FL",
"Peoria, IL",
"Petersburg, VA",
"Petersburg, WV",
"Philadelphia, PA",
"Phoenix, AZ",
"Pierre, SD",
"Pikeville, KY",
"Pine Bluff, AR",
"Pittsburgh, PA",
"Pittsfield, MA",
"Plattsburgh, NY",
"Pocatello, ID",
"Ponca City, OK",
"Poplar Bluff, MO",
"Portage, WI",
"Portland, ME",
"Portland, OR",
"Portsmouth, NH",
"Portsmouth, VA",
"Pottsville, PA",
"Poughkeepsie, NY",
"Prescott, AZ",
"Price, UT",
"Providence, RI",
"Provo, UT",
"Pueblo, CO",
"Pulaski, VA",
"Quincy, IL",
"Racine, WI",
"Raleigh, NC",
"Rancho Cucamonga, CA",
"Rapid City, SD",
"Rawlins, WY",
"Reading, PA",
"Red Bank, NJ",
"Redding, CA",
"Reno, NV",
"Rhinelander, WI",
"Richfield, UT",
"Richmond, CA",
"Richmond, TX",
"Richmond, VA",
"Riverhead, NY",
"Riverside, CA",
"Riverton, WY",
"Roanoke, VA",
"Rochester, MN",
"Rochester, NY",
"Rock Island, IL",
"Rock Springs, WY",
"Rockford, IL",
"Rockland, ME",
"Rocky Mount, NC",
"Rolla, MO",
"Roswell, NM",
"Russellville, AR",
"Rutland, VT",
"Sacramento, CA",
"Saginaw, MI",
"Salem, OR",
"Salida, CO",
"Salina, KS",
"Salinas, CA",
"Salisbury, MD",
"Salt Lake City, UT",
"San Angelo, TX",
"San Antonio, TX",
"San Bernardino, CA",
"San Diego, CA",
"San Francisco, CA",
"San Jose, CA",
"San Juan, PR",
"San Luis Obispo, CA",
"San Mateo, CA",
"San Rafael, CA",
"Santa Ana, CA",
"Santa Barbara, CA",
"Santa Fe, NM",
"Santa Monica, CA",
"Santa Rosa, CA",
"Savannah, GA",
"Schenectady, NY",
"Scranton, PA",
"Seattle, WA",
"Sedalia, MO",
"Selma, AL",
"Shawnee, OK",
"Sheldon, IA",
"Shenandoah, IA",
"Sheridan, WY",
"Show Low, AZ",
"Shreveport, LA",
"Sikeston, MO",
"Silver Spring, MD",
"Sioux City, IA",
"Sioux Falls, SD",
"Socorro, NM",
"Somerset, KY",
"Somerset, PA",
"South Bend, IN",
"Spartanburg, SC",
"Spencer, IA",
"Spokane, WA",
"Spooner, WI",
"Springfield, IL",
"Springfield, MA",
"Springfield, MO",
"Springfield, OH",
"St. Charles, MO",
"St. Cloud, MN",
"St. Johnsbury, VT",
"St. Joseph, MO",
"St. Louis, MO",
"St. Paul, MN",
"St. Petersburg, FL",
"Stamford, CT",
"State College, PA",
"Staten Island, NY",
"Staunton, VA",
"Stephenville, TX",
"Steubenville, OH",
"Stockton, CA",
"Suffern, NY",
"Summit, NJ",
"Sunbury, PA",
"Sutton, WV",
"Swainsboro, GA",
"Syracuse, NY",
"Tacoma, WA",
"Tallahassee, FL",
"Tampa, FL",
"Temple, TX",
"Terre Haute, IN",
"Texarkana, AR",
"Texarkana, TX",
"The Bronx, NY",
"The Lakes, NV",
"Thibodaux, LA",
"Thief River Falls, MN",
"Thousand Oaks, CA",
"Toledo, OH",
"Topeka, KS",
"Torrance, CA",
"Trenton, NJ",
"Truth or Consequences, NM",
"Tucson, AZ",
"Tucumcari, NM",
"Tulsa, OK",
"Tupelo, MS",
"Tuscaloosa, AL",
"Twin Falls, ID",
"Tyler, TX",
"Uniontown, PA",
"Urbana, IL",
"Utica, NY",
"Uvalde, TX",
"Valdosta, GA",
"Valentine, NE",
"Van Nuys, CA",
"Ventura, CA",
"Victoria, TX",
"Vinita, OK",
"Virgin Islands, VI",
"Waco, TX",
"Waldorf, MD",
"Washington, DC",
"Washington, IN",
"Washington, PA",
"Waterbury, CT",
"Waterloo, IA",
"Watertown, NY",
"Watertown, SD",
"Waterville Valley, NH",
"Waterville, ME",
"Wausau, WI",
"Waycross, GA",
"Welch, WV",
"Wellsboro, PA",
"Wenatchee, WA",
"West Memphis, AR",
"West Palm Beach, FL",
"Wheatland, WY",
"Wheeling, WV",
"White Plains, NY",
"White River Junction, VT",
"Whittier, CA",
"Wichita Falls, TX",
"Wichita, KS",
"Wilkes-Barre, PA",
"Williamsport, PA",
"Willimantic, CT",
"Williston, ND",
"Willmar, MN",
"Wilmington, DE",
"Wilmington, NC",
"Winchester, VA",
"Windom, MN",
"Winston-Salem, NC",
"Woburn, MA",
"Wolf Point, MT",
"Woodward, OK",
"Worcester, MA",
"Worland, WY",
"Yakima, WA",
"Yellowstone, WY",
"Yonkers, NY",
"York, PA",
"Youngstown, OH",
"Zanesville, OH"
]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.