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

AddressMatchTypetype

How strongly two addresses match, from exact to none.

Import it

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

Definition

type AddressMatchType = "exact" | "strong" | "moderate" | "weak" | "none";

Examples

import { compareAddresses, parseLocation } from "@johnmorrisdotca/address-plus";
import type { AddressMatchType } from "@johnmorrisdotca/address-plus";

const parsedAddress1=parseLocation("123 Main St, Anytown, NY 12345");
if (!parsedAddress1) throw new Error("The example address did not parse.");
const parsedAddress2=parseLocation("456 Oak Ave, Portland, OR 97201");
if (!parsedAddress2) throw new Error("The example address did not parse.");
console.log(compareAddresses(parsedAddress1, parsedAddress2).matchType);
// → "none"
none

What it prints (run when this page was built)

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