Skip to the content

Kuni国

Look up countries, codes, names and subdivisions, load country data on demand and mount a native country card.

Kuni (国) is Japanese for a country. About the name

Contents

Reference

Countries and lookup tools

import { … } from "@johnmorrisdotca/kuni";

21.4 kB minified and gzipped, with everything it imports (measured with esbuild)

Exports

NameKindWhat it is
ContinenttypeA continent's two letters: "AF", "AN", "AS", "EU", "NA", "OC" or "SA".
continentNamefunctionA continent's name, from CLDR.
CONTINENTSconstantThe seven continents, as two letters: Africa, Antarctica, Asia, Europe, North America, Oceania, South America.
countriesfunctionEvery country: the 249 ISO 3166-1 codes and Kosovo (XK).
CountriesOptionstypeWhat countries() may be asked.
countryfunctionOne country by its code.
CountrytypeA country, or a territory with an ISO 3166-1 code of its own, as the lookups hand it out (frozen).
COUNTRY_CODESconstantThe 250 country codes: the 249 ISO 3166-1 alpha-2 codes and XK for Kosovo, in alphabetical order.
countryByNamefunctionA 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.
CountryCodetypeOne of the 250 country codes, as a type: "JP" | "US" | ...
countryNamefunctionA country's name in English or Japanese.
CountryNameOptionstypeWhat countryName() may be asked.
CountryOrdertypeThe order countries() lists them in: "code" (alpha-2), "en" (by English name) or "ja" (by Japanese name, in kana).
flagfunctionThe 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.
foldfunctionWhat 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.
isCountryCodefunctionWhether a value is one of the 250 codes exactly as ISO writes it: two capital letters ("JP", and "XK" for Kosovo).
LanguagetypeA language every name is kept in: "en" or "ja".
LANGUAGESconstantThe two languages every name is kept in.
SubdivisiontypeA subdivision of a country (a state, a province, a prefecture), with its ISO 3166-2 code, as the lookups hand it out (frozen).
SubdivisionTypetypeA kind of subdivision, in kebab case: "prefecture", "state", "autonomous-community".
subregionNamefunctionA UN M49 subregion's name, from CLDR.
VERSIONconstantThe package's version, the same as package.json's.

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/kuni 1.4.0.