Efficient data structure for handling undo states.
npm install fast-undoEfficient data structure for handling undo states.

``javascript
// create an empty undo history
const history = undo.history()
// insert a few values
history.insert('cat')
history.insert('dog')
history.insert('rabbit')
// undo
history.undo() // cat <| dog |> rabbit
// redo
history.redo() // dog <| rabbit |> EMPTY
// export
history.toJSON() // '{"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:
`javascript
import { combineReducers } from 'redux';
import { withHistory } from 'fast-undo';
combineReducers({
undoableReducer: withHistory(myReducer)
});
`
See the tests.js file for some more inspiration.
typescript
function init(a: T): History;
`$3
`typescript
function undo(a: History): History;
`$3
`typescript
function redo(a: History): History;
`$3
`typescript
function insert(a: History, b: T): History;
`$3
`typescript
function prune(history: History, size?: number): History;
`$3
`typescript
function serialize(a: History): JSONHistory;
`$3
`typescript
function deserialize(a: JSONHistory): History;
`$3
`typescript
function history(a: T): {
undo: () => History;
redo: () => History;
insert: (a: T) => History;
get: () => History;
toJSON: () => string;
};
`$3
`typescript
function withHistory(a: Reducer): Reducer>;
``