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
| Name | Type | Description |
|---|---|---|
addressString | string | The address as typed. |
options (optional) | CleanAddressOptions | What to tidy and the letter case to set (see |
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 10118What it prints (run when this page was built)