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
| Name | Type | Description |
|---|---|---|
postalCode | string | 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"27What it prints (run when this page was built)