本文へ移動

address-plusアドレスプラス

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

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

目次

リファレンス · 英国のモジュール

parseUKPostcode関数

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

Takes a postcode apart: outward code, inward code, area, district and sector, and says where it delivers: the country (GB, or JE, GY or IM for the Crown Dependencies) and, in the United Kingdom, the nation. A district that crosses a border gives the nation most of its postcodes are in; getNationsForUKPostcode gives them all.

インポート

import { parseUKPostcode } from "@johnmorrisdotca/address-plus/gb";

定義

function parseUKPostcode(postcode: string): UKPostcode | null

引数

名前型説明
postcodestring

The postcode, in any letter case, with or without its space.

戻り値

UKPostcode | null

The parts, or null when it does not follow the grammar or its area is not one Royal Mail uses.

例

import { parseUKPostcode } from "@johnmorrisdotca/address-plus/gb";

console.log(parseUKPostcode("JE2 3AB"));
// → {"postcode":"JE2 3AB","outward":"JE2","inward":"3AB","area":"JE","district":"JE2","sector":"JE2 3","country":"JE"}
{
  postcode: 'JE2 3AB',
  outward: 'JE2',
  inward: '3AB',
  area: 'JE',
  district: 'JE2',
  sector: 'JE2 3',
  country: 'JE'
}

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

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

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