Reference · Parsing, formatting and shared types
parseStreetTypefunction
Takes the street type off the end of a street, abbreviated the USPS way.
Import it
import { parseStreetType } from "@johnmorrisdotca/address-plus";
Definition
function parseStreetType(text: string, country?: "US" | "CA"): { type: string | undefined; remaining: string; }
Parameters
| Name | Type | Description |
|---|---|---|
text | string | The street text. |
country (optional) | "CA" | "US" |
|
Returns
{ type: string | undefined; remaining: string; }
The type's USPS abbreviation in lower case (undefined when there is none) and the text that remains.
Examples
import { parseStreetType } from "@johnmorrisdotca/address-plus";
console.log(parseStreetType("Main Street"));
// → {"type":"st","remaining":"Main"}{ type: 'st', remaining: 'Main' }What it prints (run when this page was built)