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 · Country trivia

triviafunction

The trivia about one country, by its alpha-2 code in either case.

Import it

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

Definition

function trivia(code: string): CountryTrivia | null

Parameters

NameTypeDescription
codestring

An ISO 3166-1 alpha-2 code, "JP" or "jp"; for an alpha-3 or numeric code, pass country(code)?.alpha2.

Returns

CountryTrivia | null

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

Examples

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

console.log(trivia("CA")?.officialLanguages);      // ["en", "fr"]
console.log(trivia("AU")?.largestCity?.name.en);   // "Sydney"
console.log(trivia("IN")?.inception);              // { "year": 1947, "day": "1947-08-15" }
console.log(trivia("XX"));                         // null
[ 'en', 'fr' ]
Sydney
{ year: 1947, day: '1947-08-15' }
null

What it prints (run when this page was built)

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