Writing a tiny undo/redo stack in JavaScript 170 points by julik·616 days ago·blog.julik.nl·Show in HN
You can find a similar method in zundo, a zustand middleware for undo/redo. It has the concept of pastStates and futureStates.