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

countryfunction

One country by its code.

Import it

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

Definition

function country(code: string): Country | null

Parameters

NameTypeDescription
codestring

Alpha-2 ("JP", "jp"), alpha-3 ("JPN") or numeric ("392").

Returns

Country | null

The country, frozen; null for anything that is not one of the 250 codes.

Examples

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

console.log(country("JP")?.name.en);     // "Japan"
console.log(country("jpn")?.alpha2);     // "JP"
console.log(country("392")?.name.ja);    // "日本"
console.log(country("JP")?.capital);     // { "en": "Tokyo", "ja": "東京" }
console.log(country("XX"));              // null
Japan
JP
日本
{ en: 'Tokyo', ja: '東京' }
null

What it prints (run when this page was built)

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