Utility for converting between different U.S. state abbreviations.
npm install us-abbreviations
Requiring the module returns a U.S. abbreviations constructor that takes
two keys as parameters: from
and to
. It's probably easiest to create
a converter by immediately setting these parameters:
var convertStatesToPostStyle = require('us-abbreviations')('full', 'post');
convertStatesToPostStyle('California');
=> 'Calif.'
convertStatesToPostStyle('New York');
=> 'N.Y.'
var convertFIPSToFull = require('us-abbreviations')('fips', 'full');
convertStatesToPostStyle('01');
=> 'Alabama'
'full' – Full state name
* `Alabama`
* `Alaska`
* `Arizona`
'fips' – FIPS code
* Alabama => `01`
* Alaska => `02`
* Arizona => `04`
'postal' – U.S. Postal abreviations
* Alabama => `AK`
* Alaska => `AZ`
* Arizona => `AR`
'post' – Washington Post style (similar to AP style)
* Alabama => `Ala.`
* Alaska => `Alaska`
* Arizona => `Ariz.`
Updating json by hand is annoying. The abbreviations are stored in
src/abbreviations.csv.
src/abbreviations.json can be regenerated by having
csvkit installed and running make
.
# Make changes to the abbreviations spreadsheet
open src/abbreviations.csv
# Install csvkit
pip install csvkit
# Regenerate abreviations json file
make