Reference · Parsing, formatting and shared types
USPSFormattingOptionstype
Options for formatUSPS: which lines to include, and whether to set the letter case the USPS way.
Import it
import type { USPSFormattingOptions } from "@johnmorrisdotca/address-plus";
Definition
interface USPSFormattingOptions {
includeDeliveryLine?: boolean;
includeLastLine?: boolean;
includeBarcode?: boolean;
standardizeCase?: boolean;
}
Members
| Name | Type | Description |
|---|---|---|
includeDeliveryLine (optional) | boolean | undefined | |
includeLastLine (optional) | boolean | undefined | |
includeBarcode (optional) | boolean | undefined | |
standardizeCase (optional) | boolean | undefined |
Examples
import { formatUSPS, parseLocation } from "@johnmorrisdotca/address-plus";
import type { USPSFormattingOptions } from "@johnmorrisdotca/address-plus";
const parsedAddress1=parseLocation("123 Main St, Anytown, NY 12345");
if (!parsedAddress1) throw new Error("The example address did not parse.");
console.log(formatUSPS(parsedAddress1, { includeLastLine: false }).lines);
// → ["123 MAIN ST"][ '123 MAIN ST' ]What it prints (run when this page was built)