### Install tinyaddress via npm Source: https://github.com/alizeait/tinyaddress/blob/master/README.md Use the npm package manager to install the library. ```bash $ npm install tinyaddress ``` -------------------------------- ### Install tinyaddress via yarn Source: https://github.com/alizeait/tinyaddress/blob/master/README.md Use the yarn package manager to install the library. ```bash $ yarn add tinyaddress ``` -------------------------------- ### Format address as a string Source: https://github.com/alizeait/tinyaddress/blob/master/README.md Pass { output: "string" } to the options argument to join the address lines into a single string. ```ts import { formatAddress } from "tinyaddress"; const address = formatAddress( { name: "Mr John Smith", region: "New York", city: "Kingston", addressLines: ["132, My Street"], postalCode: "12401", countryCode: "US", }, { output: "string" } ); /* "Mr John Smith 132, My Street Kingston, New York 12401 */ ``` -------------------------------- ### formatAddress(address, options?) Source: https://github.com/alizeait/tinyaddress/blob/master/README.md Formats a postal address based on the provided address object and optional formatting options. Returns an array of sorted address lines by default, or a string if the output option is set to 'string'. ```APIDOC ## formatAddress(address, options?) ### Description Formats a postal address based on the provided address object and optional formatting options. Returns an array of sorted address lines by default, or a string if the output option is set to 'string'. ### Method Function ### Signature formatAddress(address: Address, options?: Options): string[] | string ### Parameters #### Address Object - **countryCode** (string) - Required - ISO 3166-2 country code. Used only for formatting and not included in the output. - **name** (string) - Optional - The name of the person. - **organization** (string) - Optional - The organization, firm, company, or institution at the address. - **addressLines** (string[]) - Optional - A sorted array of address lines. - **postalCode** (string) - Optional - The postal code or ZIP code. - **city** (string) - Optional - The city/town portion of the address. - **country** (string) - Optional - The country of the address. Always the last line in the address. - **region** (string) - Optional - The top-level administrative subdivision (e.g., state, province). - **dependentLocality** (string) - Optional - Dependent locality or sublocality within a city. - **sortingCode** (string) - Optional - Sorting code system (e.g., CEDEX in France). #### Options - **format** (string) - Optional - 'local' or 'latin'. Default is 'local'. Some countries have a 'latin' alternative. - **output** (string) - Optional - 'string' or 'array'. Default is 'array'. If 'string', joins the array with '/n'. ### Request Example ```ts import { formatAddress } from "tinyaddress"; const address = formatAddress({ name: "Mr John Smith", region: "New York", city: "Kingston", addressLines: ["132, My Street"], postalCode: "12401", countryCode: "US", }); ``` ### Response #### Success Response Returns an array of sorted lines: ``` ["Mr John Smith", "132, My Street", "Kingston, New York 12401"] ``` Or a string when output is 'string': ``` "Mr John Smith\n132, My Street\nKingston, New York 12401" ``` ``` -------------------------------- ### Format address as an array Source: https://github.com/alizeait/tinyaddress/blob/master/README.md The default behavior of formatAddress is to return an array of sorted address lines. ```ts import { formatAddress } from "tinyaddress"; const address = formatAddress({ name: "Mr John Smith", region: "New York", city: "Kingston", addressLines: ["132, My Street"], postalCode: "12401", countryCode: "US", }); /* ["Mr John Smith", "132, My Street", "Kingston, New York 12401"] */ ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.