Reference · Places: countries of a continent, and search (the size counts every tier)
cityNamesOffunction
A country's cities, ids and names only: the light list a picker shows first (a third to a half of the country's
full file), in the order of citiesOf, each with major for the country's capital and its first twenty cities. The
rest of a city is one cityById away.
Import it
import { cityNamesOf } from "@johnmorrisdotca/kuni/places";
Definition
function cityNamesOf(code: string): Promise<readonly CityName[] | null>
Parameters
| Name | Type | Description |
|---|---|---|
code | string | An ISO 3166-1 alpha-2 code, any case. |
Returns
Promise<readonly CityName[] | null>
The list, or null for a code with no cities.
Examples
import { cityNamesOf } from "@johnmorrisdotca/kuni/places";
const japan = await cityNamesOf("JP");
console.log(japan?.[0].name.en); // "Tokyo"
console.log(japan?.filter((one) => one.major).length); // 20Tokyo
20What it prints (run when this page was built)