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

defaultconstant

The default export, shaped like parse-address's module: parseLocation, parseAddress, parseIntersection and parseInformalAddress on one object, so import parser from "@johnmorrisdotca/address-plus" works where parse-address was imported. Named imports work too.

Import it

import value from "@johnmorrisdotca/address-plus";

Definition

const parser: AddressParser = {
    parseLocation,
    parseIntersection,
    parseInformalAddress,
    parseAddress,
}

Members

NameTypeDescription
parseAddress(address: string, options?: ParseOptions): ParsedAddress | null
parseInformalAddress(address: string, options?: ParseOptions): ParsedAddress | null
parseIntersection(address: string, options?: ParseOptions): ParsedIntersection | null
parseLocation(address: string, options?: ParseOptions): ParsedAddress | null

Examples

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

const parsedAddress1=parser.parseLocation("123 Main St, New York, NY 10001");
if (!parsedAddress1) throw new Error("The example address did not parse.");
console.log(parsedAddress1.zip);
// → "10001"
10001

What it prints (run when this page was built)

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