Javascript implementation of UndoStack and UndoCommand inspired by QUndoStack