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

cleanAddressfunction

Tidies an address typed in a hurry: spaces, commas, letter case, the street type and the state, without changing what it says.

Import it

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

Definition

function cleanAddress(addressString: string, options?: CleanAddressOptions): string

Parameters

NameTypeDescription
addressStringstring

The address as typed.

options (optional)CleanAddressOptions

What to tidy and the letter case to set (see CleanAddressOptions).

Returns

string

The tidied address; the input, trimmed, when it cannot be parsed.

Examples

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

console.log(cleanAddress("350 FIFTH AVENUE, NEW YORK, NY 10118"));
// → "350 Fifth Ave, New York NY 10118"
350 Fifth Ave, New York NY 10118

What it prints (run when this page was built)

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