fromCodefunction
Import it
import { fromCode } from "@johnmorrisdotca/toranpu";
Definition
function fromCode(text: string): ReadGame | null
Parameters
| Name | Type | Description |
|---|---|---|
text | string | The notation, encoded state or saved text to read. |
Returns
ReadGame | null
The reconstructed game, or null when the code or JSON does not represent a supported legal game.
Examples
import { fromCode, newGame, toCode } from "@johnmorrisdotca/toranpu";
const game = newGame("hearts", { players: ["Aki", "Ben", "Cy", "Dev"], seed: 42 })!;
console.log(fromCode(toCode("hearts", game))?.kind);heartsWhat it prints (run when this page was built)