Reference · Cities: lookups and loading (the tiers load on demand; the size counts every tier)
citiesOffunction
One country's cities, every tier together, the most populous first: the same list as
Import it
import { citiesOf } from "@johnmorrisdotca/kuni/cities";
Definition
function citiesOf(countryCode: string): Promise<readonly City[] | null>
Parameters
| Name | Type | Description |
|---|---|---|
countryCode | string | An ISO 3166-1 alpha-2 code, in either case. |
Returns
Promise<readonly City[] | null>
The list, frozen; an empty list for a country with no city in the data; null for a code that is not a country.
Examples
import { citiesOf } from "@johnmorrisdotca/kuni/cities";
const japan = await citiesOf("jp");
console.log(japan?.[0].country); // "JP"
console.log(japan?.some((one) => one.capital === "national")); // true
console.log(await citiesOf("XX")); // nullJP
true
nullWhat it prints (run when this page was built)