本文へ移動

address-plusアドレスプラス

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

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

目次

リファレンス

/kr

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

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

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

エクスポート

名前種類概要
compareKoreanAddresses関数Compares two addresses in South Korea field by field: the province, the district, the road and its number, the dong, the floor, the unit and the postcode.
CountryComparison型What a country module's comparer returns: whether the two addresses are the same delivery point, and every field that differs once both are in the same form (letter case, punctuation, a street type written out or abbreviated).
CountryDifference型One way two addresses differ, as a country module's comparer reports it: the field, and its value in each address after both were put in the same form.
CountryModule型A country's address module: its codes, how to tell its addresses apart, and its parser, validator, formatter and comparer.
CountryValidation型What a country module's validator returns: the errors and the warnings it found.
findKoreanProvince関数Finds a province or metropolitan city of South Korea by its code (11, KR-11), its name in English (Seoul, Gyeonggi-do) or its name in Korean (서울특별시, 서울), ignoring letter case, spaces and hyphens.
formatKoreaPost関数Writes an address in South Korea as Korea Post asks.
FormattedAddress型A formatted address: its lines, and the same on one line.
getProvinceFromKoreanPostcode関数The province or metropolitan city a postcode is in, by its ISO 3166-2 code without KR- (11 for Seoul).
isKnownKoreanPostcode関数Whether GeoNames' list for South Korea has a postcode (34,249 of them).
isValidKoreanPostcode関数Whether a postcode follows Korea Post's shape: five digits.
KoreaPostFormattingOptions型Options for formatKoreaPost.
KR_PROVINCES定数The metropolitan cities and provinces of South Korea.
looksKorean関数Whether an address is surely Korean, with no hint: it ends with South Korea, Korea or 대한민국, or it is written in Hangul with the name of a metropolitan city or province, or a road and its number, or it is written in Latin letters with a road (-ro, -daero, -gil), a province's name and a postcode the list has before the end.
ParsedAddress型What parseLocation returns: every part it found, each absent when the address has none.
parseKoreanAddress関数Parses an address in South Korea, written in Hangul from the province down (서울특별시 중구 세종대로 110 (태평로1가)) or in Latin letters from the number up (110 Sejong-daero, Jung-gu, Seoul 04524).
parseKoreanPostcode関数Takes a postcode apart: the province it is in, and whether GeoNames' list has it.
ParseOptions型Options for every parser: the country, strict postal codes, snake_case keys and the rest.
PostcodeLookup型A postcode taken apart: its canonical form, the region it is in (when the country's table has regions), and whether the country's list has it.
PostcodeRegion型A region a postcode can be in, as a country's table holds it: its code, its ISO 3166-2 code, and its name in English and in Japanese (from kuni, which takes them from Unicode CLDR and Wikidata).
southKorea定数South Korea's module, for parseLocation and validateAddress: pass it in countries, and an address that ends with South Korea, Korea or 대한민국, or is written in Hangul with a province's name or a road and its number, is read as Korean; country: "KR" reads any address as one.
validateKoreanAddress関数Checks an address in South Korea: the postcode is five digits and GeoNames' list has it, the province written agrees with the postcode's, and the road's building number and the district are given.
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.10.2 のソースから作成しました。

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