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 · All subdivisions

subdivisionsfunction

A country's subdivisions, in code order: the first level unless level asks for another or for "all".

Import it

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

Definition

function subdivisions(countryCode: string, options?: SubdivisionsOptions): readonly Subdivision[] | null

Parameters

NameTypeDescription
countryCodestring

An alpha-2 code, either case.

options (optional)SubdivisionsOptions

level: 1 (the default), 2, 3 or "all".

Returns

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 { subdivisions } from "@johnmorrisdotca/kuni/subdivisions";

console.log(subdivisions("JP")?.length);                    // 47
console.log(subdivisions("FR")?.length);                    // 26
console.log(subdivisions("FR", { level: "all" })?.length);  // 124
console.log(subdivisions("XX"));                            // null
47
26
124
null

What it prints (run when this page was built)

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