Class representing a history of values. History
const history = History.create(10) Copy
const history = History.create(10)
const historyOfValue = History.of(50) Copy
const historyOfValue = History.of(50)
const updatedHistory = history .map(value => value + 5) .map(value => value * 2) Copy
const updatedHistory = history .map(value => value + 5) .map(value => value * 2)
const currentValue = updatedHistory.current() // output: 30 Copy
const currentValue = updatedHistory.current() // output: 30
const resetHistory = updatedHistory.reset() Copy
const resetHistory = updatedHistory.reset()
const rolledBackHistory = resetHistory.rollback() Copy
const rolledBackHistory = resetHistory.rollback()
The type of values in the history.
Private
Private constructor to create an instance of History.
History
The history of values.
Get the current value at the end of the history.
The current value.
Apply a function to the current value and add the new value to the history.
The function to be applied to the current value.
A new instance of History with the updated value.
Reset the history to contain only the initial value.
A new instance of History with the history reset.
Revert the history to a previous value, removing the indicated number of values.
The number of values to revert. Default is 1.
A new instance of History with the history reverted.
Static
Create a new instance of History with an initial value.
The initial value.
A new instance of History.
History#create
Generated using TypeDoc
Class representing a history of values. History
Example: Create a new History instance with an initial value of 10.
Example: Create a new History instance using the alias method.
Example: Add new values using the map method.
Example: Get the current value from the updated history.
Example: Reset the history to its initial value.
Example: Rollback to a previous value.