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

parseFacilityfunction

Takes a facility's name (a building, a park, a hospital) off the start of an address.

Import it

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

Definition

function parseFacility(text: string): { facility: string | undefined; remaining: string; }

Parameters

NameTypeDescription
textstring

The address text.

Returns

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

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

Examples

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

console.log(parseFacility("Empire State Building, 350 5th Ave"));
// → {"facility":"Empire State Building","remaining":", 350 5th Ave"}
{ facility: 'Empire State Building', remaining: ', 350 5th Ave' }

What it prints (run when this page was built)

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