本文へ移動

address-plusアドレスプラス

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

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

目次

リファレンス

フランスのモジュール

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

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

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

エクスポート

名前種類概要
compareFrenchAddresses関数Compares two addresses in France field by field: the delivery point, the building, the number and its extension, the type and name of the street, the lieu-dit, the box, the commune 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.
findFrenchDepartment関数Finds a department of France by its code (75, 2A, 971) or its name (Paris, Haute-Corse), without regard to letter case or accents.
formatLaPoste関数Writes an address in France as La Poste's specification asks (SP 8855): the person it is care of, then the line of the apartment, the floor and the staircase, the line of the entrance and the building, the number and street, the lieu-dit and the box, then the postcode, the commune and its CEDEX, each on its own line, in capitals without accents or punctuation.
FormattedAddress型A formatted address: its lines, and the same on one line.
FR_BUILDING_WORDS定数The words that open the line naming a building, a residence or a zone (La Poste's third line), which the parser keeps whole as building (Résidence Les Lilas, Bâtiment A, Zone industrielle Nord, ZAC des Prés), with their abbreviations.
FR_COLLECTIVITIES定数The overseas collectivities that have postcodes in La Poste's base: each with its code, its ISO 3166-1 country code and its name.
FR_DEPARTMENTS定数The 101 departments of France, in order of their codes, each with its code (75, 2A, 971), its name and its region's.
FR_NUMBER_EXTENSIONS定数The words that may follow the number as its indice de répétition: bis, ter, quater and the rest of the Latin series.
FR_STREET_TYPES定数The types of voie the parser takes off the front of a street's name and reports, in full, as type (rue de la Paix is street de la Paix, type Rue), with the abbreviations it reads for each.
FR_UNIT_TYPES定数The types of the part of a building that an address names below the number: an apartment or a door, which the parser reports as secUnitType and secUnitNum, with the abbreviations it reads for each.
france定数France's module, for parseLocation and validateAddress: pass it in countries, and an address that ends with France (or Monaco or an overseas territory), holds CEDEX, or has a French type of voie and a postcode first on its last line is read as French; country: "FR" reads any address as one, and so does the code of an overseas department or collectivity.
FrenchAddressFields型The fields an address in France fills beside the shared ones.
FrenchCollectivity型An overseas collectivity of France in the tables: its code (987), the ISO 3166-1 country code an address in it reads as (PF) and its name.
FrenchDepartment型A department of France in the tables: its code (75, 2A, 971), its name and its region's, from INSEE's Code officiel géographique.
FrenchPostalCountry型The country an address in La Poste's base belongs to: FR for France (the metropolis and the overseas departments), MC for Monaco, and the ISO 3166-1 code of an overseas collectivity (PM, BL, MF, WF, PF, NC), which is French but has a country code of its own and is listed apart by the Universal Postal Union.
FrenchPostcode型A postcode taken apart: the code of the department or territory its number belongs to, the country it delivers to, and whether La Poste's base has it.
getDepartmentFromFrenchPostcode関数The department a postcode's number belongs to, by its code: 75 for 75008, 2B for 20200, 971 for 97100.
isKnownFrenchPostcode関数Whether La Poste's base officielle des codes postaux lists a postcode: France, the overseas departments and collectivities and Monaco.
isValidFrenchPostcode関数Whether a postcode follows La Poste's shape: five digits.
LaPosteFormattingOptions型Options for formatLaPoste.
looksFrench関数Whether an address is surely French, with no hint: it ends with France, an overseas department, Monaco or one of the collectivities, or holds CEDEX beside a postcode, or its last line begins with a postcode whose number names a department, a collectivity or Monaco, followed by a commune (75008 Paris), while the address has a French type of voie (rue, avenue, chemin) at the start of a street, a BP, a TSA or a lieu-dit.
ParsedAddress型What parseLocation returns: every part it found, each absent when the address has none.
parseFrenchAddress関数Parses an address in France (or Monaco, or an overseas department or collectivity, which are written the same way) into the parts La Poste's norm names: who it is care of (careOf), an apartment or a door (secUnitType, secUnitNum), a floor, a staircase, an entrance, the building or residence (building), the number with its extension (numberExtension: bis, ter, a letter), the type of voie in full in type and its name in street (rue de la Paix is Rue and de la Paix), a lieu-dit, a box (BP 12, CS 30001), the commune in city with its arrondissement and CEDEX, and the postcode in zip with the department's code in state.
parseFrenchPostcode関数Takes a postcode apart: the code of the department or territory its number belongs to, and the country it delivers to (FR for France and its overseas departments, MC for Monaco, PF, NC and the other collectivities' own codes), and whether La Poste's base lists it.
ParseOptions型Options for every parser: the country, strict postal codes, snake_case keys and the rest.
validateFrenchAddress関数Checks an address in France against La Poste's postcode shape and the tables: the postcode is five digits, its number names a department, a collectivity or Monaco, and La Poste's base officielle lists it.
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 のソースから作成しました。

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