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

parseDirectionalfunction

Takes a leading directional off a street (NW Main St), abbreviated.

Import it

import { parseDirectional } from "@johnmorrisdotca/address-plus";

Definition

function parseDirectional(text: string): { direction: string | undefined; remaining: string; }

Parameters

NameTypeDescription
textstring

The street text.

Returns

{ direction: string | undefined; remaining: string; }

The directional (undefined when there is none) and the text that remains.

Examples

import { parseDirectional } from "@johnmorrisdotca/address-plus";

console.log(parseDirectional("NW Main St"));
// → {"direction":"NW","remaining":"Main St"}
{ direction: 'NW', remaining: 'Main St' }

What it prints (run when this page was built)

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