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

formatJapanesefunction

Writes a Japanese address in Japanese order, as an envelope is addressed: 〒100-0005, then 東京都千代田区丸の内1-2-3, then サンプルビル5階501号室. The prefecture and municipality are always in kanji, from the tables. A town or building parsed from romaji keeps its romaji, set off by spaces so the scripts do not run together. Kyoto's street directions are written before the town.

Import it

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

Also exported from: @johnmorrisdotca/address-plus

Definition

function formatJapanese(address: ParsedAddress, options?: JapaneseFormattingOptions): string

Parameters

NameTypeDescription
addressParsedAddress

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

options (optional)JapaneseFormattingOptions

The block's style (1-2-3 or 1丁目2番3号), the postal code, and lines or one line (see JapaneseFormattingOptions).

Returns

string

The address as text, its lines joined with newlines unless options.multiline is false; an empty string when the address has none of the parts.

Examples

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

const parsedAddress1=parseLocation("〒100-0005 東京都千代田区丸の内1-2-3");
if (!parsedAddress1) throw new Error("The example address did not parse.");
console.log(formatJapanese(parsedAddress1, { blockStyle: "markers", multiline: false }));
// → "〒100-0005 東京都千代田区丸の内1丁目2番3号"
〒100-0005 東京都千代田区丸の内1丁目2番3号

What it prints (run when this page was built)

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