Reference · Parsing, formatting and shared types
detectCountryfunction
Which country a parsed address is in, from its postal code, then its state or province.
Import it
import { detectCountry } from "@johnmorrisdotca/address-plus";
Definition
function detectCountry(address: ParsedAddress): "US" | "CA" | undefined
Parameters
| Name | Type | Description |
|---|---|---|
address | ParsedAddress | The parsed address, or any object with its |
Returns
"CA" | "US" | undefined
US or CA, or undefined when nothing says.
Examples
import { detectCountry } from "@johnmorrisdotca/address-plus";
console.log(detectCountry({ zip: "M5H 2N2" }));
// → "CA"CAWhat it prints (run when this page was built)