Reference
Countries and lookup tools
import { … } from "@johnmorrisdotca/kuni";
21.4 kB minified and gzipped, with everything it imports (measured with esbuild)
Exports
| Name | Kind | What it is |
|---|---|---|
Continent | type | A continent's two letters: "AF", "AN", "AS", "EU", "NA", "OC" or "SA". |
continentName | function | A continent's name, from CLDR. |
CONTINENTS | constant | The seven continents, as two letters: Africa, Antarctica, Asia, Europe, North America, Oceania, South America. |
countries | function | Every country: the 249 ISO 3166-1 codes and Kosovo (XK). |
CountriesOptions | type | What countries() may be asked. |
country | function | One country by its code. |
Country | type | A country, or a territory with an ISO 3166-1 code of its own, as the lookups hand it out (frozen). |
COUNTRY_CODES | constant | The 250 country codes: the 249 ISO 3166-1 alpha-2 codes and XK for Kosovo, in alphabetical order. |
countryByName | function | A country from what somebody typed: its name or short name in English or Japanese ("Germany", ドイツ, どいつ), its own name ("Deutschland"), a name it is also known by ("Holland", "UK", 米国), or a code. |
CountryCode | type | One of the 250 country codes, as a type: "JP" | "US" | ... |
countryName | function | A country's name in English or Japanese. |
CountryNameOptions | type | What countryName() may be asked. |
CountryOrder | type | The order countries() lists them in: "code" (alpha-2), "en" (by English name) or "ja" (by Japanese name, in kana). |
flag | function | The flag of a country as an emoji: two regional-indicator letters, which most systems draw as the flag and some (Windows) as the two letters. |
fold | function | What two ways of typing a name have in common: width (full-width letters to ASCII, half-width katakana to full), case, accents (except the two marks that make が and ぱ), katakana to hiragana, apostrophes dropped, and every other run of punctuation or space to one space. |
isCountryCode | function | Whether a value is one of the 250 codes exactly as ISO writes it: two capital letters ("JP", and "XK" for Kosovo). |
Language | type | A language every name is kept in: "en" or "ja". |
LANGUAGES | constant | The two languages every name is kept in. |
Subdivision | type | A subdivision of a country (a state, a province, a prefecture), with its ISO 3166-2 code, as the lookups hand it out (frozen). |
SubdivisionType | type | A kind of subdivision, in kebab case: "prefecture", "state", "autonomous-community". |
subregionName | function | A UN M49 subregion's name, from CLDR. |
VERSION | constant | The package's version, the same as package.json's. |