Reference · Rolls and exact odds
parseHistoryfunction
A kept history read back from its text. Rolls that do not add up are dropped; text that is not a history reads as empty.
Import it
import { parseHistory } from "@johnmorrisdotca/korokoro";
Definition
function parseHistory(text: string | null): Roll[]
Parameters
| Name | Type | Description |
|---|---|---|
text | string | null | Text to parse, validate or format. |
Returns
Roll[]
A kept history read back from its text. Rolls that do not add up are dropped; text that is not a history reads as empty.
Examples
import { parseHistory } from "@johnmorrisdotca/korokoro";
import { normalizeSpec, rollFrom, serializeHistory } from "@johnmorrisdotca/korokoro";
const spec = normalizeSpec({ count: 2, sides: 6 });
const sample = rollFrom(spec, [2, 5], "saved", 0, null)!;
console.log(parseHistory(serializeHistory([sample])).length);1What it prints (run when this page was built)