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

parseInformalAddressfunction

Reads an address written loosely, as a fallback when parseLocation finds no street address: a description such as Downtown near City Hall is kept whole as the street, with any ZIP code after it.

Import it

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

Definition

function parseInformalAddress(address: string, options?: ParseOptions): ParsedAddress | null

Parameters

NameTypeDescription
addressstring

The address as one string.

options (optional)ParseOptions

How to parse (see ParseOptions).

Returns

ParsedAddress | null

The street and the ZIP code it could find, or null when the text is empty.

Examples

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

console.log(parseInformalAddress("Downtown near City Hall, Springfield IL 62701"));
// → {"street":"Downtown near City Hall","zip":"62701","country":"US"}
{ street: 'Downtown near City Hall', zip: '62701', country: 'US' }

What it prints (run when this page was built)

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