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

countryByNamefunction

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. Case, accents, width, kana and punctuation do not matter.

Import it

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

Definition

function countryByName(text: string): Country | null

Parameters

NameTypeDescription
textstring

What was typed.

Returns

Country | null

The country, frozen; null when nothing matches, never a near miss.

Examples

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

console.log(countryByName("ドイツ")?.alpha2);          // "DE"
console.log(countryByName("Holland")?.name.ja);        // "オランダ"
console.log(countryByName("USA")?.alpha2);           // "US"
console.log(countryByName("cote d'ivoire")?.alpha2);   // "CI"
console.log(countryByName("Narnia"));                  // null
DE
オランダ
US
CI
null

What it prints (run when this page was built)

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