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

parseAddressfunction

Parses a street address. The same as parseLocation, kept under the name parse-address's users know.

Import it

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

Definition

function parseAddress(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 parts found, or null when nothing can be read as an address.

Examples

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

console.log(parseAddress("123 Main St Apt 4, Anytown, NY 12345")?.secUnitNum);
// → "4"
4

What it prints (run when this page was built)

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