Undo / Redo
Step back and forward through state with return values.
npm install @biswaviraj/time-travel# orpnpm add @biswaviraj/time-travelimport { timeTravel } from "@biswaviraj/time-travel";
const tt = timeTravel<number>(0);
tt.add(1);tt.add(2);tt.add(3);
tt.get(); // 3tt.undo(); // returns 2tt.undo(); // returns 1tt.redo(); // returns 2
tt.canUndo; // truett.canRedo; // trueUndo / Redo
Step back and forward through state with return values.
History Navigation
Jump N steps with go(n) or inspect the full history.
React Hook
useTimeTravel for reactive undo/redo in React components.
Zero Dependencies
Fully typed, tree-shakeable, and under 1kB gzipped.