fast-undo
Efficient data structure for handling undo states.
// create an empty undo historyconst history = undohistory // insert a few valueshistoryhistoryhistory // undohistory // cat <| dog |> rabbit // redohistory // dog <| rabbit |> EMPTY // exporthistory // '{"past":["dog","cat"],"present":"rabbit","future":[]}'
Install as an NPM module:
$ npm install fast-undo
Works as a higher-order reducer with Redux, or similiar:
;; ;
See the tests.js file for some more inspiration.
API
init
;
undo
;
redo
;
insert
;
prune
;
serialize
;
deserialize
;
history
;
withHistory
;