Reference · Rules, games and records
parsePositionfunction
The position that text of formatPosition's kind stands for, or null if it is not one. bar, reserve and off may be left out.
Import it
import { parsePosition } from "@johnmorrisdotca/sugoroku";
Definition
function parsePosition(text: string): Position | null
Parameters
| Name | Type | Description |
|---|---|---|
text | string | Native move notation, position text or full record specified by the signature. |
Returns
Position | null
The position that text of formatPosition's kind stands for, or null if it is not one. bar, reserve and off may be left out.
Examples
import { formatPosition, parsePosition, settingsFor, startPosition } from "@johnmorrisdotca/sugoroku";
const settings = settingsFor("backgammon",{points:5,cube:true});
const spec = settings.variant;
const position = startPosition(spec);
console.log(parsePosition(formatPosition(position))?.bar);[ 0, 0 ]What it prints (run when this page was built)