本文へ移動

address-plusアドレスプラス

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

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

目次

リファレンス

/in

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

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

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

エクスポート

名前種類概要
compareIndianAddresses関数Compares two addresses in India field by field: the unit, the street, its number, the area, the city and the PIN code.
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.
findIndianState関数Finds a state or union territory of India by its code (KA, IN-KA) or its name in English, ignoring accents, & for and, and letter case.
formatIndiaPost関数Writes an address in India as India Post asks: who it is care of, the flat and the building, the house number and the street, a landmark, the area, then the city and the PIN code, then the state, each on its own line.
FormattedAddress型A formatted address: its lines, and the same on one line.
getStateFromIndianPostcode関数The state or union territory a PIN code is in, by its code without IN- (KA for Karnataka): the one most of GeoNames' places for the PIN code are in.
IN_STATES定数The states and union territories of India.
india定数India's module, for parseLocation and validateAddress: pass it in countries, and an address that ends with India, or with the word PIN and a PIN code, or with a state's name and a PIN code the list has, is read as Indian; country: "IN" reads any address as one.
IndiaPostFormattingOptions型Options for formatIndiaPost.
isKnownIndianPostcode関数Whether GeoNames' list for India has a PIN code (19,238 of them).
isValidIndianPostcode関数Whether a PIN code follows India Post's shape: six digits, the first not nought, with or without a space after the third.
looksIndian関数Whether an address is surely Indian, with no hint: it ends with India (IN alone is Indiana's, so it is not read), or it ends with a PIN code after the word PIN or Pin code, or after the name of a state or union territory of India with a PIN code that GeoNames' list has.
ParsedAddress型What parseLocation returns: every part it found, each absent when the address has none.
parseIndianAddress関数Parses an address in India into the parts India Post lays out: who it is care of (careOf, from C/o, S/o, D/o, W/o), a building's name (building), the flat or shop (secUnitType and secUnitNum: Flat 4B), the floor, the house number (number: 12, 12/3, 12-A) and the street as written (street: MG Road), a landmark (place: Near City Mall), the area in locality, the city in city, the PIN code in zip (560038, with no space) and the state's code in state (KA), as written or from the PIN code.
parseIndianPostcode関数Takes a PIN code apart: the state 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).
validateIndianAddress関数Checks an address in India: the PIN code is six digits and GeoNames' list has it, the state written agrees with the PIN code's, and the city and the street's number 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 のソースから作成しました。

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