本文へ移動

address-plusアドレスプラス

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

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

目次

リファレンス

日本の住所

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

最小化と gzip 圧縮をしたサイズは 60.6 kB(読み込むものをすべて含み、esbuild で計測)

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

エクスポート

名前種類概要
findMunicipalitiesByName関数The municipalities a Japanese name could mean: several when the name is shared (府中市 is in Tokyo and in Hiroshima).
findMunicipalitiesByRomaji関数The municipalities a romaji name could mean, written with or without macrons and designators (Chiyoda-ku, Chiyoda City, Sapporo-shi Chuo-ku, Chuo-ku, Sapporo).
findMunicipalityByCode関数The municipality with a JIS X 0402 code, a designated city's own code included.
findPrefecture関数The prefecture a name, reading, romaji spelling or JIS code refers to: 東京都, 東京, トウキョウト, Tokyo, Osaka Prefecture, 13.
formatJapanese関数Writes a Japanese address in Japanese order, as an envelope is addressed: 〒100-0005, then 東京都千代田区丸の内1-2-3, then サンプルビル5階501号室.
formatJapaneseEnglish関数Writes a Japanese address in English order, as a form from abroad expects: building, room, block, town, municipality, prefecture, postal code, Japan.
getPostalPrefixesForPrefecture関数The three-digit postal prefixes a prefecture's codes begin with, the reverse of getPrefectureFromJapanesePostalCode.
getPrefectureFromJapanesePostalCode関数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.
JapaneseAddressFields型The fields a Japanese address fills on top of the shared ones.
JapaneseEnglishFormattingOptions型Options for formatJapaneseEnglish.
JapaneseFormattingOptions型Options for formatJapanese.
JapaneseMunicipality型A municipality (市区町村) in the tables: its JIS code, its prefecture's code, its official name with the district for a town or village in one, its reading and its romaji.
JapanesePrefecture型A prefecture (都道府県) in the tables: its JIS code, official name, katakana reading and romaji.
JapaneseValidation型What validateJapaneseAddress returns: the errors and the warnings found.
JP_DESIGNATED_CITIES定数The twenty designated cities (政令指定都市) as municipalities of their own.
JP_MUNICIPALITIES定数Every municipality (市区町村) by JIS X 0402 code, with its prefecture, official name, reading and romaji; a designated city's wards are listed, and the city itself is in JP_DESIGNATED_CITIES.
JP_POSTAL_EXCEPTIONS定数The postal codes that deliver to another prefecture than the rest of their three-digit prefix, each to that prefecture's JIS code.
JP_POSTAL_PREFIXES定数Each three-digit postal prefix, to the JIS code of the prefecture most of its codes deliver to.
JP_PREFECTURES定数The 47 prefectures in JIS X 0401 order, each with its code, official name, katakana reading and romaji.
kanjiNumeralsToDigits関数Turns the kanji numerals that stand for block, floor or room numbers into digits: 一丁目二番三号 becomes 1丁目2番3号.
looksJapanese関数Whether a text is a Japanese address: in Japanese script, ending with Japan, or naming a prefecture beside a Japanese postal code, a romaji designator (-ku, -shi) or a municipality written with an English word (Chiyoda City).
municipalitiesOf関数Every municipality of a prefecture, the designated cities included.
normalizeJapaneseAddressText関数Makes the text of a Japanese address uniform, as the parser reads it: widths folded, spaces tidied, numerals as digits, and 1の2の3, 1-2-3 or any other dash written 1-2-3.
ParsedAddress型What parseLocation returns: every part it found, each absent when the address has none.
parseJapaneseAddress関数Parses a Japanese address, in Japanese script or in romaji, into the Japanese fields and the shared ones.
ParseOptions型Options for every parser: the country, strict postal codes, snake_case keys and the rest.
validateJapaneseAddress関数Checks a parsed Japanese address against the tables: the postal code's shape, whether any code begins with its first three digits, whether it delivers to the prefecture named, and whether the municipality is a real one in that prefecture.
ValidationError型One finding of a validator: the field it is about, its code, a message, and how serious it is.
ValidationOptions型Options for the validators: which parts an address must have, which kinds are allowed, and whether a postal code that does not match its region is an error.

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

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