fromJSON関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
A game from text that toJSON or toCode wrote, whichever game it is.
Nothing in it is trusted: every move is played through the rules again, and
a move the rules refuse means the text is not a game. Null for text that is
not JSON, names no game, is of a later format than this version reads, or
cannot be played out.
インポート
import { fromJSON } from "@johnmorrisdotca/toranpu";
定義
function fromJSON(text: string): ReadGame | null
引数
| 名前 | 型 | 説明 |
|---|---|---|
text | string | The notation, encoded state or saved text to read. |
戻り値
ReadGame | null
A game from text that toJSON or toCode wrote, whichever game it is. Nothing in it is trusted: every move is played through the rules again, and a move the rules refuse means the text is not a game. null for text that is not JSON, names no game, is of a later format than this version reads, or cannot be played out.
例
import { fromJSON, newGame, toJSON } from "@johnmorrisdotca/toranpu";
const game = newGame("hearts", { players: ["Aki", "Ben", "Cy", "Dev"], seed: 42 })!;
console.log(fromJSON(toJSON("hearts", game))?.kind);hearts出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。