@dice-roller/rpg-dice-roller / RollHistory
Class: RollHistory
Defined in: src/RollHistory.ts:8
A log of rolls.
Implements
Iterable<Roll<unknown>>
Constructors
Constructor
new RollHistory():
RollHistory
Returns
RollHistory
Accessors
length
Get Signature
get length():
number
Defined in: src/RollHistory.ts:22
Number of rolls in the history.
Returns
number
rolls
Get Signature
get rolls(): readonly
Roll<unknown>[]
Defined in: src/RollHistory.ts:12
A copy of the rolls, oldest first.
Returns
readonly Roll<unknown>[]
total
Get Signature
get total():
number
Defined in: src/RollHistory.ts:17
The sum of the roll totals, or 0 when empty (NaN if they include both Infinity and -Infinity).
Returns
number
Methods
[iterator]()
[iterator]():
Iterator<Roll<unknown>>
Defined in: src/RollHistory.ts:37
Iterates over a snapshot of the rolls, oldest first.
Returns
Iterator<Roll<unknown>>
Implementation of
Iterable.[iterator]
add()
add(...
rolls):void
Defined in: src/RollHistory.ts:27
Appends rolls in order.
Parameters
rolls
...Roll<unknown>[]
Returns
void
clear()
clear():
void
Defined in: src/RollHistory.ts:32
Removes all rolls from the history.
Returns
void
present()
present<
T>(presenter?):T
Defined in: src/RollHistory.ts:42
Presents the whole history; defaults to the default TextPresenter.
Type Parameters
T
T = string
Parameters
presenter?
Presenter<T>
Returns
T
toJSON()
toJSON():
object
Defined in: src/RollHistory.ts:54
JSON-safe export data with non-finite numbers tagged; evaluates uncached roll min/max totals.
Returns
rolls
readonlyrolls: readonlyobject[]
total
readonlytotal:EncodedNumber
Can be NaN, e.g. for a history of 1/0 and -1/0.
type
readonlytype:"history"
version
readonlyversion:1
toString()
toString():
string
Defined in: src/RollHistory.ts:49
Always the default TextPresenter output.
Returns
string