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
| Name | Type | Description |
|---|---|---|
countryCode | string | An alpha-2 code, either case. |
options (optional) | SubdivisionsOptions |
|
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")); // null47
26
124
nullWhat it prints (run when this page was built)