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 · On-demand subdivisions

loadSubdivisionsfunction

The subdivisions of one country, every level, in code order: the same list as

Import it

import { loadSubdivisions } from "@johnmorrisdotca/kuni/load";

Definition

function loadSubdivisions(countryCode: string): Promise<readonly Subdivision[] | null>

Parameters

NameTypeDescription
countryCodestring

An alpha-2 code, either case.

Returns

Promise<readonly Subdivision[] | null>

The list, frozen; an empty list for a country that has none (Antarctica); null for a code that is not a country.

Examples

import { loadSubdivisions } from "@johnmorrisdotca/kuni/load";

console.log((await loadSubdivisions("CA"))?.length);         // 13
console.log((await loadSubdivisions("jp"))?.[12].name.ja);   // "東京都"
console.log(await loadSubdivisions("AQ"));                   // []
console.log(await loadSubdivisions("XX"));                   // null
13
東京都
[]
null

What it prints (run when this page was built)

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