Reference · Parsing, formatting and shared types
normalizeRegionfunction
Finds the US state or Canadian province a name, code or misspelling means: Calfornia, Que., British Columbia,
nfld.
Import it
import { normalizeRegion } from "@johnmorrisdotca/address-plus";
Definition
function normalizeRegion(input: string): { abbr: string; country: "CA" | "US"; } | null
Parameters
| Name | Type | Description |
|---|---|---|
input | string | A state or province name, code or abbreviation, in English or French. |
Returns
{ abbr: string; country: "CA" | "US"; } | null
Its code and country, or null when nothing is close enough.
Examples
import { normalizeRegion } from "@johnmorrisdotca/address-plus";
console.log(normalizeRegion("Calfornia"));
// → {"abbr":"CA","country":"US"}{ abbr: 'CA', country: 'US' }What it prints (run when this page was built)