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 · Cities: lookups and loading (the tiers load on demand; the size counts every tier)

citySetfunction

Joins lists of cities (a tier's list, or several) into one set with the lookups built once. A city that is in more than one list is kept once, the first.

Import it

import { citySet } from "@johnmorrisdotca/kuni/cities";

Definition

function citySet(...lists: readonly (readonly City[])[]): CitySet

Parameters

NameTypeDescription
...listsreadonly (readonly City[])[]

Lists of cities, such as capitalCities() and cities1m().

Returns

CitySet

The set, with byId, inCountry, inSubdivision, nearest and within; nothing in it can be changed.

Examples

import { citySet } from "@johnmorrisdotca/kuni/cities";
import { capitalCities } from "@johnmorrisdotca/kuni/cities/capitals";

const capitals = citySet(capitalCities());
console.log(capitals.byId("Q1490")?.country);                           // "JP"
console.log(capitals.inCountry("fr").some((one) => one.name.en === "Paris")); // true
console.log(capitals.nearest({ lat: 48.85, lon: 2.35 })?.city.name.en);   // "Paris"
console.log(capitals.byId("Q0"));                                        // null
JP
true
Paris
null

What it prints (run when this page was built)

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