1 | "use strict";
|
2 | var DagGraph_1 = require("../DagGraph");
|
3 | var jumpToState_1 = require("./jumpToState");
|
4 | var log = require('debug')('redux-dag-history:DagHistory');
|
5 | function undo(history) {
|
6 | var graph = history.graph;
|
7 | var reader = new DagGraph_1.default(graph);
|
8 | var parentId = reader.parentOf(reader.currentStateId);
|
9 | if (parentId !== null && parentId !== undefined) {
|
10 | log('undoing %s => %s', reader.currentStateId, parentId);
|
11 | return jumpToState_1.default(parentId, history);
|
12 | }
|
13 | log('cannot undo');
|
14 | return history;
|
15 | }
|
16 | Object.defineProperty(exports, "__esModule", { value: true });
|
17 | exports.default = undo;
|