Reference · Rolls and exact odds
toCSVfunction
Rolls as CSV for a spreadsheet: a header, then a row for each roll, lines
ended CRLF as RFC 4180 has them. total is empty for dice that are only
words; dice is each die as text (see diceText); faces is the bare
faces thrown; held is which dice were held, counted from 1; set is
2/6 for the second roll of six.
Import it
import { toCSV } from "@johnmorrisdotca/korokoro";
Definition
function toCSV(rolls: readonly Roll[]): string
Parameters
| Name | Type | Description |
|---|---|---|
rolls | readonly Roll[] | Completed rolls, or the number of attempts where this parameter is numeric. |
Returns
string
Rolls as CSV for a spreadsheet: a header, then a row for each roll, lines ended CRLF as RFC 4180 has them. total is empty for dice that are only words; dice is each die as text (see diceText); faces is the bare faces thrown; held is which dice were held, counted from 1; set is 2/6 for the second roll of six.
Examples
import { toCSV } 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(toCSV([sample]).split("\r\n")[0]);time,notation,label,total,dice,faces,seed,held,loaded,setWhat it prints (run when this page was built)