@zerodep/geo-state
v2.3.8
Published
Get info about a state by its name or common abbreviation
Downloads
7
Readme
@zerodep/geo-state
A parser to get state abbreviation and information from a state name or abbreviation; it will throw a ZeroDepError
if the guard fails.
Full documentation is available at the zerodep.app page.
Examples
geoStateIso Examples
geoStateIso('n.y.'); // ['NY', 'US']
geoStateIso('oreg'); // ['OR', 'US']
geoStateIso('alberta'); // ['AB', 'CA']
geoState Examples
geoState(['utah']);
// {
// stateName: 'Utah',
// stateAbbr: 'UT',
// stateFips: '49',
// regionCensus: 'West',
// regionDivision: 'Mountain',
// regionBea: 'Rocky Mountain',
// countryName: 'United States',
// countryIso2: 'US',
// }
geoState('bc');
// {
// stateName: 'British Columbia',
// stateAbbr: 'BC',
// stateFips: '00',
// regionCensus: undefined,
// regionDivision: undefined,
// regionBea: undefined,
// countryName: 'Canada',
// countryIso2: 'CA',
// }
Unsuccessful Cases
geoStateIso('unknown'); // thows ZeroDepError: Could not find a state or province for "UNKNOWN"
geoState('unknown'); // thows ZeroDepError: Could not find a state or province for "UNKNOWN"