Skip to the content

address-plusアドレスプラス

Parse, validate, format and compare addresses locally, add country modules and mount an optional native form field.

address-plus extends the parse-address style with typed results, validation, formatting and country modules. About the name

Contents

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

NameTypeDescription
textstring

The street text.

country (optional)"CA" | "US"

US or CA, for the types only one country uses.

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)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/address-plus 1.7.0.