Skip to the content

Korokoroコロコロ

Roll mixed dice or type notation, compare exact probabilities, keep a history and replay seeded rolls.

Korokoro describes something small rolling in Japanese. About the name

Contents

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

NameTypeDescription
textstring | 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);
1

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/korokoro 1.16.0.