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

getPrefectureFromJapanesePostalCodefunction

The prefecture a Japanese postal code delivers to, from Japan Post's data: by its first three digits, and for the codes on the far side of a prefix that straddles a border, by the whole code.

Import it

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

Also exported from: @johnmorrisdotca/address-plus

Definition

function getPrefectureFromJapanesePostalCode(postalCode: string): string | null

Parameters

NameTypeDescription
postalCodestring

The seven-digit code, with or without its hyphen, in either width.

Returns

string | null

The prefecture's JIS code, or null for a malformed code or one no Japanese code begins like.

Examples

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

console.log(getPrefectureFromJapanesePostalCode("530-0001"));
// → "27"
27

What it prints (run when this page was built)

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