parseLocation関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
Parses a US, Canadian or Japanese address into its parts. The country is detected from the text (a state, a
province, a postal code, Japanese script or romaji designators) unless options.country names it. A Japanese
address fills its own fields (prefecture, municipality, town, chome, ban, go) and the shared ones that
stand for them. Australia and the United Kingdom are read too when their modules are passed in options.countries
(australia from /au, unitedKingdom from /gb): options.country picks one, or each module's own detection
decides, before the US, Canada and Japan are tried.
インポート
import { parseLocation } from "@johnmorrisdotca/address-plus";
定義
function parseLocation(address: string, options?: ParseOptions): ParsedAddress | null
引数
| 名前 | 型 | 説明 |
|---|---|---|
address | string | The address as one string; commas, line breaks and full-width characters are all read. |
options (省略可) | ParseOptions | How to parse: the country, strict postal codes, snake_case keys and the rest (see |
戻り値
ParsedAddress | null
The parts found, or null when the text is empty or holds nothing that can be read as an address. A part
that is not in the address is absent from the result, never an empty string.
例
import { parseLocation } from "@johnmorrisdotca/address-plus";
console.log(parseLocation("1600 Pennsylvania Ave NW, Washington, DC 20500"));
// → {"number":"1600","street":"Pennsylvania","type":"Ave","suffix":"NW","city":"Washington","state":"DC","zip":"20500","zipValid":true,"country":"US"}{
number: '1600',
street: 'Pennsylvania',
type: 'Ave',
suffix: 'NW',
city: 'Washington',
state: 'DC',
zip: '20500',
zipValid: true,
country: 'US'
}出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。