undo: (steps = 1) => {
// Fastest way to clone an array on Chromium. Needed to create a new array reference
const pastStates = get().pastStates.slice();
const futureStates = get().futureStates.slice();
if (pastStates.length) {
// Based on the steps, get values from the pastStates array and push them to the futureStates array
for (let i = 0; i < steps; i++) {
const pastState = pastStates.pop();
if (pastState) {
futureStates.push(options?.partialize?.(userGet()) || userGet());
userSet(pastState);
}
}
set({ pastStates, futureStates });
}