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

serializeHistoryfunction

A history as text, to keep in a browser's storage or anywhere else. parseHistory reads it back.

Import it

import { serializeHistory } from "@johnmorrisdotca/korokoro";

Definition

function serializeHistory(history: readonly Roll[]): string

Parameters

NameTypeDescription
historyreadonly Roll[]

Completed rolls, newest first where the history API requires it.

Returns

string

A history as text, to keep in a browser's storage or anywhere else. parseHistory reads it back.

Examples

import { serializeHistory } from "@johnmorrisdotca/korokoro";
import { normalizeSpec, rollFrom } from "@johnmorrisdotca/korokoro";
const spec = normalizeSpec({ count: 2, sides: 6 });
const sample = rollFrom(spec, [2, 5], "saved", 0, null)!;
console.log(serializeHistory([sample]));
{"version":1,"rolls":[{"id":"saved","spec":{"count":2,"sides":6,"modifier":0,"keep":"all"},"faces":[2,5],"kept":[true,true],"total":7,"at":0,"seed":null}]}

What it prints (run when this page was built)

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