JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 47
  • Score
    100M100P100Q53509F
  • License MIT

A simple function that converts state or province names to their abbreviations, and converts state or province names back to full names.

Package Exports

  • convert-region
  • convert-region/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (convert-region) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

convert-region

A simple utility to convert region abbreviations to full names and vice-versa. Currently works with all 50 US states, and all Canadian provinces. Over time the goal will be to add functionality for multiple continents and regions. Built with Typescript.

Story

I found myself building an application with location data being return from an existing API as abbreviations but, for presentation's sake I needed full names. I wrote a utility locally within my project, and ultimately decided to publish.

Usage

To use, simply import the utility into your project.

import convertRegion from 'convert-region'

To convert abbreviations to full names use convertRegion.toFullName('CA') which will turn NY to New York.

To convert full names to abbreviations use convertRegion.toAbbreviation('New York') which will turn New York to NY.

Currently Available Regions

Below is a list of all the regions currently contained, with their accompanying abbreviations.

United States

Alabama - AL  
Alaska - AK  
American Samoa - AS
Arizona - AZ
Arkansas - AR
Armed Forces Americas - AA
Armed Forces Europe - AE
Armed Forces Pacific - AP
California - CA
Colorado - CO
Connecticut - CT  
Delaware - DE
District Of Columbia - DC 
Florida - FL
Guam - GU
Georgia - GA 
Hawaii - HI 
Idaho - ID 
Illinois - IL 
Indiana - IN 
Iowa - IA 
Kansas - KS
Kentucky - KY 
Louisiana - LA 
Maine - ME
Marshall Islands - MH 
Maryland - MD 
Massachusetts - MA  
Michigan - MI
Minnesota - MN 
Mississippi - MS 
Missouri - MO 
Montana - MT 
Nebraska - NE 
Nevada - NV 
New Hampshire - NH  
New Jersey - NJ 
New Mexico - NM
New York - NY  
North Carolina - NC  
North Dakota - ND 
Ohio - OH 
Oklahoma - OK 
Oregon - OR 
Pennsylvania - PA
Rhode Island - RI 
South Carolina - SC 
South Dakota - SD 
Tennessee - TN 
Texas - TX 
Utah - UT
Vermont - VT 
Virginia - VA 
Washington - WA 
West Virginia - WV 
Wisconsin - WS 
Wyoming - WY

Canada

Alberta - AB
British Columbia - BC
Manitoba - MB
New Brunswick - NB
Newfoundland - NF
Northwest Territory - NT
Nova Scotia - NS
Nunavut - NU
Ontario - ON
Prince Edward Island - PE
Quebec - QC
Saskatchewan - SK
Yukon - YT

Support Me

If for some reason this package is useful to you my Venmo is @thejessewinton.