kumimojiFromJSON関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
A game from JSON that kumimojiToJSON wrote. Nothing in it is trusted: the
bag is dealt again from the seed, and the game opens only if every tile held
is one that came out of that bag. Resolves to null when the text is not
JSON, is of a later format than this version reads, is another game's, or
holds a hand or a grid that this bag never dealt.
The word list of the game's language is loaded first, since dealing needs
it; where there is no browser, import @johnmorrisdotca/kumimoji/words
once, or the promise is rejected as loadTileWords rejects it.
インポート
import { kumimojiFromJSON } from "@johnmorrisdotca/kumimoji";
定義
function kumimojiFromJSON(text: string): Promise<KumimojiSaved | null>
引数
| 名前 | 型 | 説明 |
|---|---|---|
text | string | The saved JSON text to validate. |
戻り値
Promise<KumimojiSaved | null>
A game from JSON that kumimojiToJSON wrote. Nothing in it is trusted: the bag is dealt again from the seed, and the game opens only if every tile held is one that came out of that bag. Resolves to null when the text is not JSON, is of a later format than this version reads, is another game's, or holds a hand or a grid that this bag never dealt.
例
import { deal, generateKumimoji, kumimojiFromJSON, kumimojiToJSON } from "@johnmorrisdotca/kumimoji";
import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
await loadTileWordsFromModule("english");
const play = deal("catdog",3);
const dealt = generateKumimoji(3,"hard",44);
const saved = {deal:dealt,play:deal(dealt.givens,dealt.size),elapsedMs:0};
console.log((await kumimojiFromJSON(kumimojiToJSON(saved)))?.deal.seed);44出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。