The way browser history is implemented, with the History interface, is useful for other things than site navigation. The same idea, basically an extended stack that allows going back and forward, is the same algorithm used for undo/redo, and command line history.
It would be nice to be able to do const h = new History()
and h.pushState(someData)
with arbitrary states, but the browser won't let you construct a new instance of History
. It's only accessible from window.history
.
So I re-defined History
to allow this.
See the details on the github site.