formatIndiaPostfunction
Writes an address in India as India Post asks: who it is care of, the flat and the building, the house number and the street, a landmark, the area, then the city and the PIN code, then the state, each on its own line.
Import it
import { formatIndiaPost } from "@johnmorrisdotca/address-plus/in";
Definition
function formatIndiaPost(address: ParsedAddress, options?: IndiaPostFormattingOptions): FormattedAddress
Parameters
| Name | Type | Description |
|---|---|---|
address | ParsedAddress | The address as |
options (optional) | IndiaPostFormattingOptions | Whether to add the country (see |
Returns
FormattedAddress
The lines, the same on one line, the delivery line and the last line.
Examples
import { formatIndiaPost, parseIndianAddress } from "@johnmorrisdotca/address-plus/in";
const parsedAddress1 = parseIndianAddress("Flat 4B, Sunshine Apartments, 12 MG Road, Indiranagar, Bengaluru, Karnataka 560038");
if (!parsedAddress1) throw new Error("The example address did not parse.");
console.log(formatIndiaPost(parsedAddress1).lines);
// → ["Sunshine Apartments","Flat 4B","12 MG Road","Indiranagar","Bengaluru 560038","Karnataka"][
'Sunshine Apartments',
'Flat 4B',
'12 MG Road',
'Indiranagar',
'Bengaluru 560038',
'Karnataka'
]What it prints (run when this page was built)