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 · /capitals

capitalsOffunction

The capitals of a country that has more than one capital city, or a capital that capital does not name alone, each with its role: South Africa's Pretoria (administrative), Cape Town (legislative) and Bloemfontein (judicial). Each role is what the country's own government or law says, read on the day in CAPITALS_READ; docs/capitals.md lists the page and the line for every one. The country's capital is unchanged.

Import it

import { capitalsOf } from "@johnmorrisdotca/kuni/capitals";

Definition

function capitalsOf(code: string): readonly CountryCapital[] | null

Parameters

NameTypeDescription
codestring

An ISO 3166-1 alpha-2 code, "ZA" or "za".

Returns

readonly CountryCapital[] | null

The capitals in the order of the table, frozen; null for a country with no entry (almost every country, whose one capital is capital) and for anything that is not a code. Israel and the Palestinian Territories have no entry: a disputed capital is left to the maintainer.

Examples

import { capitalsOf } from "@johnmorrisdotca/kuni/capitals";

console.log(capitalsOf("ZA")?.map((one) => `${one.name.en} ${one.role}`)); // ["Pretoria administrative", "Cape Town legislative", "Bloemfontein judicial"]
console.log(capitalsOf("BI")?.map((one) => `${one.name.ja} ${one.role}`));  // ["ギテガ political", "ブジュンブラ economic"]
console.log(capitalsOf("JP"));                                             // null
[
  'Pretoria administrative',
  'Cape Town legislative',
  'Bloemfontein judicial'
]
[ 'ギテガ political', 'ブジュンブラ economic' ]
null

What it prints (run when this page was built)

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