loadTileWords関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
THE LIST, ONCE. In a browser (or its worker) it arrives as its own script, fetched by the dynamic import below the first time a Kumimoji needs it.
ONLY IN A BROWSER, AND SAID SO WHERE THE BUILD CAN SEE IT. The page's
components are drawn on the server too, and a dynamic import in them is a
copy of its target in every server function — two lists, 1.3 MB, which put
the site's grouped function over its size limit (functionSizeGate). The
build writes typeof window as a constant — "undefined" on the server,
"object" in a browser bundle, its worker included — so on the server the
branch, and the import with it, is gone before anything is traced. The
server reads the list through tileWordsModule.ts instead, which only the
server's own checks and the tests import.
インポート
import { loadTileWords } from "@johnmorrisdotca/kumimoji";
定義
function loadTileWords(language?: KumimojiLanguage): Promise<TileWords>
引数
| 名前 | 型 | 説明 |
|---|---|---|
language (省略可) | KumimojiLanguage | The English or Japanese tile language. |
戻り値
Promise<TileWords>
THE LIST, ONCE. In a browser (or its worker) it arrives as its own script, fetched by the dynamic import below the first time a Kumimoji needs it.
例
import { loadTileWords } from "@johnmorrisdotca/kumimoji";
import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
await loadTileWordsFromModule("english");
console.log((await loadTileWords("english")).allowed.size);110316出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。