本文へ移動

address-plusアドレスプラス

住所を端末の中で解析・確認・整形・比較し、国のモジュールや任意のフォームの入力欄を使えます。

address-plusは、parse-addressの使い方を広げ、型付きの結果、確認、書式、国のモジュールを加えます。 名前について(英語)

目次

リファレンス · ドイツのモジュール

formatDeutschePost関数

リファレンスの説明と例は英語です。見出しと目次は日本語です。

Writes an address in Germany as Deutsche Post asks: who it is care of (c/o), the part of the building, the flat and the floor, the street and its house number, then the postcode and the place, each on its own line, with no punctuation at the end of a line. A Postfach is written with its number in pairs (Postfach 12 34 56) and a Packstation with its number.

インポート

import { formatDeutschePost } from "@johnmorrisdotca/address-plus/de";

定義

function formatDeutschePost(address: ParsedAddress, options?: DeutschePostFormattingOptions): FormattedAddress

引数

名前型説明
addressParsedAddress

The address as parseGermanAddress returns it.

options (省略可)DeutschePostFormattingOptions

Whether to add the country (see DeutschePostFormattingOptions).

戻り値

FormattedAddress

The lines, the same on one line, the delivery line (the street and its number) and the last line.

例

import { formatDeutschePost, parseGermanAddress } from "@johnmorrisdotca/address-plus/de";

const parsedAddress1=parseGermanAddress("Hinterhaus, 2. OG, Kastanienallee 4 b, 10435 Berlin");
if (!parsedAddress1) throw new Error("The example address did not parse.");
console.log(formatDeutschePost(parsedAddress1).lines);
// → ["Hinterhaus","2. OG","Kastanienallee 4B","10435 Berlin"]
[ 'Hinterhaus', '2. OG', 'Kastanienallee 4B', '10435 Berlin' ]

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/address-plus 1.7.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。