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 · Japanese addresses

formatJapaneseEnglishfunction

Writes a Japanese address in English order, as a form from abroad expects: building, room, block, town, municipality, prefecture, postal code, Japan. The prefecture and municipality are always romaji, from the tables; the town and building are written as they were parsed, since the tables hold no romaji for towns.

Import it

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

Also exported from: @johnmorrisdotca/address-plus

Definition

function formatJapaneseEnglish(address: ParsedAddress, options?: JapaneseEnglishFormattingOptions): string

Parameters

NameTypeDescription
addressParsedAddress

The address, as parseLocation returns it for a Japanese address.

options (optional)JapaneseEnglishFormattingOptions

Whether to end with the postal code and with Japan (see JapaneseEnglishFormattingOptions).

Returns

string

The address as one line, its parts joined by commas.

Examples

import { formatJapaneseEnglish } from "@johnmorrisdotca/address-plus/jp";
import { parseLocation } from "@johnmorrisdotca/address-plus";

const parsedAddress1=parseLocation("1-2-3 Marunouchi, Chiyoda-ku, Tokyo 100-0005");
if (!parsedAddress1) throw new Error("The example address did not parse.");
console.log(formatJapaneseEnglish(parsedAddress1));
// → "1-2-3 Marunouchi, Chiyoda-ku, Tokyo 100-0005, Japan"
1-2-3 Marunouchi, Chiyoda-ku, Tokyo 100-0005, Japan

What it prints (run when this page was built)

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