本文へ移動

address-plusアドレスプラス

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

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

目次

リファレンス

解析・書式・共通の型

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

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

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

エクスポート

名前種類概要
AddressAbbreviations型What getAddressAbbreviations returns: one map per kind of abbreviation.
AddressComparisonOptions型Options for comparing addresses: what to normalize before comparing, whether to allow small typos, and whether every field must match exactly.
AddressComparisonResult型What compareAddresses returns: the verdict, the match type and the similarity.
AddressComparisonTestCase型A comparison case in the package's JSON test files: two addresses and the match expected.
AddressDifference型One part on which two addresses differ, with both values and the kind of difference.
AddressFormattingOptions型Options for formatAddress and cleanAddress: what to abbreviate, capitals, the unit, the country and the line separator.
AddressFormattingTestCase型A formatting case in the package's JSON test files: an address and the text expected.
AddressMatchType型How strongly two addresses match, from exact to none.
AddressParser型The shape of the default export: the four parsers parse-address's users call on one object.
AddressParsingTestCase型A parsing case in the package's JSON test files: an address and the fields expected from it.
AddressSimilarityResult型How alike two addresses are: an overall score from 0 to 1, a score for each part, and the differences.
AddressValidationResult型What validateAddress returns.
AddressValidationTestCase型A validation case in the package's JSON test files: an address and the verdict and codes expected.
AustralianAddressFields型The fields an Australian address fills beside the shared ones.
AustralianPostcodeRange型One block of postcodes Australia Post allocates to a state or territory: every postcode from from to to, inclusive, written as four digits.
AustralianState型An Australian state or territory in the tables: Australia Post's code, the ISO 3166-2 code, and its name in English and in Japanese (from kuni, which takes them from Unicode CLDR and Wikidata).
AustralianStateCode型The code of an Australian state or territory, as Australia Post writes it on the last line of an address.
BatchParseError型One address a batch could not parse: its index, the input and the reason.
BatchParseOptions型Options for the batch parsers: the parse options, plus whether to stop at the first error and whether to include the statistics.
BatchParseResult型What a batch parser returns: the results in order, the errors and the statistics.
BatchParseStats型The counts and timing of a batch: how many were parsed, how many failed, and how long it took.
BatchProcessingTestCase型A batch case in the package's JSON test files: several addresses and the counts expected.
buildRegexFromDict関数A regular expression matching any key of a dictionary as a whole word, longest first.
CA_PROVINCE_ALTERNATIVES定数Other ways Canadian provinces are written (old and informal abbreviations such as PQ, Que., Nfld.), in lower case, to their codes.
CA_PROVINCE_NAMES定数Every Canadian province and territory by its English or French name, to its code.
CA_PROVINCE_NAMES_EN定数Every Canadian province and territory by its English name in lower case, to its two-letter code.
CA_PROVINCE_NAMES_FR定数Every Canadian province and territory by its French name in lower case, to its two-letter code.
CA_PROVINCES定数Every name and other spelling of a Canadian province, to its code: the names and the alternatives together.
CA_REGIONS定数Every name and other spelling of a Canadian province or territory as a Region object, for fuzzy matching by normalizeRegion.
CA_STREET_TYPES定数Every street type Canada Post lists, in English and French, with common spellings, in lower case, to the abbreviation the parser reports.
CanadaPostFormattingOptions型Options for formatCanadaPost: which lines to include, bilingual labels, and whether to set the letter case the Canada Post way.
CANADIAN_POSTAL_CODE_PATTERN定数A Canadian postal code with the letters Canada Post assigns, with or without its space.
CANADIAN_POSTAL_LIBERAL_PATTERN定数A Canadian postal code of any letters, for finding one before it is checked.
capitalizeStreetName関数Capitalizes a street name the way it is signed.
capitalizeWords関数Capitalizes the first letter of each word.
CITY_PATTERNS定数Patterns for a city of one or more words at the end of a text, after a space, used where no comma marks it.
cleanAddress関数Tidies an address typed in a hurry: spaces, commas, letter case, the street type and the state, without changing what it says.
cleanAddressDetailed関数Tidies an address like cleanAddress, and says what it changed.
CleanAddressOptions型Options for cleanAddress: which tidying to do, and the letter case to set.
CleanAddressResult型What cleanAddressDetailed returns: the tidied address and what changed.
CleanAddressTestCase型A cleaning case in the package's JSON test files: an address and the tidied text expected.
COMMON_PARSER_PATTERNS定数Pattern builders the parsers share: a ZIP, a state or a postal code at the end of a text, and a city before a state.
COMMON_STREET_NAMES_PATTERN定数Street names common enough that they must not be taken as part of a city's name.
compareAddresses関数Compares two parsed addresses field by field, allowing for abbreviations (Street and St), state names and codes, letter case and small typos.
CONNECTOR_WORDS定数Small words (of, the, and) that may be in lower case inside a facility's name written in title case.
COUNTRIES定数The country codes the parser reports: US, CA and JP.
CountryCode型A country code the parser reports: US, CA or JP.
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.
default定数The default export, shaped like parse-address's module: parseLocation, parseAddress, parseIntersection and parseInformalAddress on one object, so import parser from "@johnmorrisdotca/address-plus" works where parse-address was imported.
detectCountry関数Which country a parsed address is in, from its postal code, then its state or province.
DIRECTION_EXPANSIONS定数Each directional abbreviation in lower case, to the word in full.
DIRECTIONAL_MAP定数Each directional word, in English or French, in lower case, to its abbreviation (northwest and nord-ouest to NW and NO).
FACILITY_DELIMITER_PATTERN定数A facility's name followed by a comma or a dash and then the address.
FACILITY_DELIMITER_PATTERNS定数The ways a facility's name is set off from an address: in parentheses, before a delimiter, or as a trailing island.
FACILITY_INDICATORS定数Words that mark a place's name as a facility (center, tower, hospital, université), in lower case.
FACILITY_PATTERNS定数The patterns that find a facility's name, in English and French.
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.
formatAddress関数Writes a parsed address back out as lines and as one line, with abbreviations or in full.
formatCanadaPost関数Writes a parsed address the way Canada Post asks: capitals, the unit before the civic number joined by a hyphen, and the postal code two spaces after the province.
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.
FormattedAddress型A formatted address: its lines, and the same on one line.
formatUSPS関数Writes a parsed address the way USPS Publication 28 asks: capitals, standard abbreviations, the unit on the street line, and the city, state and ZIP+4 on the last.
FRENCH_PREPOSITIONS定数French particles that can open a street name, each with the space after it, to the way it is written there (de la as De la ).
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.
FuzzyMatchOptions型Settings for fuzzy string matching: the lowest similarity that counts, the largest edit distance, and phonetic matching.
GENERAL_DELIVERY_PATTERNS定数General delivery written alone or before a city.
GermanAddressFields型The fields an address in Germany fills beside the shared ones.
GermanPostcode型A postcode taken apart: the Land it is in, and whether GeoNames' list has it.
GermanState型A Land of Germany in the tables: 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).
GermanStateCode型The code of one of the sixteen Länder of Germany, as ISO 3166-2:DE writes it after DE-.
getAddressAbbreviations関数Every abbreviation the formatters use: street types, directionals, secondary units, states and provinces.
getAddressSimilarity関数The similarity of two parsed addresses, part by part, without a verdict: the score and each part's score, and the differences.
getPostalPrefixesForPrefecture関数The three-digit postal prefixes a prefecture's codes begin with, the reverse of getPrefectureFromJapanesePostalCode.
getPostalPrefixesForProvince関数The postal code prefixes a province or territory uses, the reverse of getProvinceFromPostalCode.
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.
getProvinceFromPostalCode関数The province or territory a Canadian postal code is in, from its first letter, and for the X codes of the north, its first three characters.
getStateFromZip関数The state or territory a US ZIP code is in.
getValidationErrors関数The errors validateAddress finds, without the rest of its result.
getZipPrefixesForState関数The ZIP code prefixes a state or territory uses, the reverse of getStateFromZip: three digits where a whole block of a hundred belongs to it, five where only part of one does.
hasValidAddressComponents関数Whether a string looks like an address at all: a number and a street, a PO box, a postal code or another recognised part.
INTERSECTION_PATTERNS定数The regular expressions and pattern builders the intersection parser uses to find the city and each street with its type.
ISLAND_TYPE_PATTERN定数The words for an island, for addresses on one (Island, Isle, Île).
isSameAddress関数Whether two parsed addresses are the same place, by the same rules as compareAddresses.
isValidAddress関数Whether an address passes validateAddress.
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.
MUSIC_SQUARE_EAST_PATTERN定数Nashville's Music Square East, whose name ends in a directional word that is part of it.
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.
normalizeRegion関数Finds the US state or Canadian province a name, code or misspelling means: Calfornia, Que., British Columbia, nfld.
normalizeStateProvinceName関数The code of a US state or Canadian province written in full, in lower case.
normalizeText関数Lower-cases a string, turns its periods, commas and semicolons into spaces, folds runs of spaces to one and trims it: the form the parsers compare words in.
PARENTHETICAL_PATTERN定数Words in parentheses inside an address; group 1 is what is inside them.
parseAddress関数Parses a street address.
parseAddresses関数Parses many street addresses with parseAddress, in order.
parseAddressesBatch関数Parses many street addresses with parseAddress, and reports which failed and how long it took.
ParsedAddress型What parseLocation returns: every part it found, each absent when the address has none.
ParsedIntersection型What parseIntersection returns: two streets, each with its name, type and directionals, and the place.
parseDirectional関数Takes a leading directional off a street (NW Main St), abbreviated.
parseFacility関数Takes a facility's name (a building, a park, a hospital) off the start of an address.
parseInformalAddress関数Reads an address written loosely, as a fallback when parseLocation finds no street address: a description such as Downtown near City Hall is kept whole as the street, with any ZIP code after it.
parseInformalAddresses関数Parses many loosely written addresses with parseInformalAddress, in order.
parseInformalAddressesBatch関数Parses many loosely written addresses with parseInformalAddress, and reports which failed and how long it took.
parseIntersection関数Parses an intersection of two streets, joined by &, and, at or @, with the city, state and ZIP that may follow.
parseIntersections関数Parses many intersections with parseIntersection, in order.
parseIntersectionsBatch関数Parses many intersections with parseIntersection, and reports which failed and how long it took.
parseJapaneseAddress関数Parses a Japanese address, in Japanese script or in romaji, into the Japanese fields and the shared ones.
parseLocation関数Parses a US, Canadian or Japanese address into its parts.
parseLocations関数Parses many addresses with parseLocation, in order.
parseLocationsBatch関数Parses many addresses with parseLocation, and reports which failed and how long it took.
ParseOptions型Options for every parser: the country, strict postal codes, snake_case keys and the rest.
parseParenthetical関数Takes words in parentheses out of an address, such as (Rear Entrance).
parsePostalCode関数Takes a ZIP code, ZIP+4 or Canadian postal code off the end of a text.
parseSecondaryUnit関数Takes a secondary unit (apartment, suite, floor and the rest) off a street line.
parseStateProvince関数Takes a US state or Canadian province off the end of a text, by code or by name.
parseStreetNumber関数Takes the house number off the start of a street line, with a fraction or a letter if it has one.
parseStreetType関数Takes the street type off the end of a street, abbreviated the USPS way.
PO_BOX_PATTERNS定数The regular expressions the PO box parser uses: the box itself, a station after it, a box number first, and a trailing comma.
POSTAL_CODE_TO_PROVINCE定数Each first letter of a Canadian postal code, to the province or territory it is assigned to.
PostalValidationResult型What validatePostalCode returns: whether the code is well formed, its type, and the code written the standard way.
PROVINCE_EXPANSIONS定数Each Canadian province's code in lower case, to its name in lower case: English by default, the French names under their own keys.
PROVINCE_EXPANSIONS_EN定数Each Canadian province's code in lower case, to its English name in lower case.
PROVINCE_EXPANSIONS_FR定数Each Canadian province's code in lower case, to its French name in lower case.
Region型A US state or Canadian province: its code, its country and its name, as normalizeRegion matches them.
SECONDARY_UNIT_PATTERN定数A unit at the end of a street line: group 1 is the street before it, group 2 the unit.
SECONDARY_UNIT_TYPES定数Each secondary unit designator, abbreviated or in full, in lower case, to the word the parser reports in full: USPS Publication 28 Appendix C2, and Canada Post's French unit words, which stay French.
setValidatedPostalCode関数Sets a ZIP or postal code on a result, the way the parsers do: split into ZIP and ZIP+4, a Canadian code in capitals with one space, with zipValid set, and in strict mode only when the code is well formed.
StateCode型A US state, DC or territory code that getStateFromZip can return.
STREET_NAME_ACRONYMS定数Acronyms written in capitals inside a street name (US, FBI), from their lower-case form, for capitalizeStreetName.
STREET_TYPE_DETECTION_PATTERN定数Whether a text has a common street type in it, used to judge that a parse found a street.
STREET_TYPE_EXPANSIONS定数Each USPS street type abbreviation in lower case, to the word in full.
STREET_TYPE_PROPER_CASE定数Each street type abbreviation in lower case, to the way the parser reports it (Ave, Xing).
SubRegion型An administrative part of a city (a borough, a parish, a ward, an arrondissement) that may be written where the city is expected.
TERRITORY_POSTAL_PREFIXES定数The first three characters of each territory's postal codes, since the territories share a first letter.
TERRITORY_POSTAL_RANGES定数The patterns that tell the Northwest Territories' X codes from Nunavut's, by their first three characters.
TestCase型Any case in the package's JSON test files.
TestCaseBase型The fields every case in the package's JSON test files has: a name or description, the input, what is expected and the options.
UKAddressFields型The fields an address in the United Kingdom fills beside the shared ones.
UKNation型A nation of the United Kingdom in the tables: 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).
UKNationCode型The code of one of the four nations of the United Kingdom, as ISO 3166-2:GB writes it after GB-.
UKPostcode型A postcode taken apart: the outward code (area and district) and the inward code (sector and unit), and where it delivers.
UNIT_TYPE_KEYWORDS定数The secondary unit designators that take a value after them, as one alternation for a regular expression, longest first so that apartment is tried before apt: USPS Publication 28 Appendix C2, Canada Post's English and French unit words, and a few spellings people write.
UNIT_TYPE_NUMBER_PATTERN定数A unit's designator and value: groups 1 and 2 (apt 123, `Apt.
US_REGIONS定数Every name and other spelling of a US state, DC or territory as a Region object, for fuzzy matching by normalizeRegion.
US_STATE_ALTERNATIVES定数Other ways US states are written (shortened forms, old abbreviations, D.C.), in lower case, to their codes.
US_STATE_EXPANSIONS定数Each US state's code in lower case, to its name in lower case: the reverse of US_STATE_NAMES.
US_STATE_NAMES定数Every US state, DC and territory by its name in lower case, to its two-letter code.
US_STATES定数Every name and other spelling of a US state in lower case, to its code: US_STATE_NAMES and US_STATE_ALTERNATIVES together.
US_STREET_TYPES定数Every street type USPS Publication 28 lists, and the common spellings of each, in lower case, to its USPS abbreviation in lower case.
USPSFormattingOptions型Options for formatUSPS: which lines to include, and whether to set the letter case the USPS way.
validateAddress関数Checks an address: whether it has what an address needs, whether its ZIP or postal code is well formed and belongs to the state, province or prefecture named, and how sure the parser is.
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.
validatePostalCode関数Checks the shape of a US ZIP code or a Canadian postal code.
VALIDATION_PATTERNS定数Small regular expressions the validators share: letters, digits, a house number at the start, and the like.
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.
WRITTEN_NUMBERS定数House numbers written as words (One, Twenty), as one alternation for a regular expression, so One Microsoft Way is read as number 1.
ZIP_CODE_PATTERN定数A US ZIP code with an optional ZIP+4.
ZIP_CODE_REGEX_PATTERN定数The source of ZIP_CODE_PATTERN, for building larger patterns.
ZIP_VALIDATION_PATTERNS定数The shape of something that could be a ZIP code.

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

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