history-component

Keep track of and cycle through history

History

Keep track of and cycle through capped history (chat messages, REPL command-lines etc).

$ component install component/history

Initialize with an array of vals.

Add a value, for example a chat message or REPL command line. This method resets the history index, meaning the next call to .back() will be this latest value.

Cycle backwards through history, returning a value added by .add().

Cycle forwards through history, returning a value added by .add().

The maximum number of entries defaulting to 1000.

Reset the index to the latest value.

MIT