withSmallStates関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The world with its smallest countries put back as dots. The 1:110m world has no outline for 62 of the 238 countries
(Singapore, Malta, Bahrain, most of the Caribbean and the Pacific); this adds each as a small: true region, a
small round shape at the middle of its largest island or piece, with its code, names, reading, continent and the
countries it touches. Every region the map already has is kept as it is and the dots come after them, so the world
is drawn, framed, labelled, called out and asked in a quiz as before, with the 62 as countries like any other. Only
the world (id world) and its finer drawing (world-detail) get dots: any other map, and a world cut down to a
group (groupMap), come back as they are, as does a world that already has every dot. The same map is returned
for the same input, and the map given is never changed.
It is its own entry, so the table costs nothing until it is used. Draw or ask with the dots by giving the functions the
map it returns: drawChizu(withSmallStates(WORLD)), findQuestion(withSmallStates(WORLD), "SG", random),
pickDistractors(withSmallStates(WORLD), "SG"). mountChizu (smallStates: true), <chizu-map small-states> and
<chizu-quiz small-states> fetch the entry themselves, only when that is on.
インポート
import { withSmallStates } from "@johnmorrisdotca/chizu/small-states";
定義
function withSmallStates<M extends SmallStatesMap>(map: M): M
引数
| 名前 | 型 | 説明 |
|---|---|---|
map | M | The world map, or its finer drawing; any other map is returned unchanged. |
戻り値
M
The map with a dot added for each small country it does not draw, or map itself when there is nothing to add.
例
import WORLD from "@johnmorrisdotca/chizu/world";
import { withSmallStates } from "@johnmorrisdotca/chizu/small-states";
const withDots = withSmallStates(WORLD);
const singapore = withDots.regions.find((region) => region.code === "SG")!;
console.log(WORLD.regions.length, withDots.regions.length, singapore.small, singapore.nameJa);
// 173 235 true シンガポール173 235 true シンガポール出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。