UNPKG

641 BJavaScriptView Raw
1"use strict";
2var DagGraph_1 = require("../DagGraph");
3var jumpToState_1 = require("./jumpToState");
4var log = require('debug')('redux-dag-history:DagHistory');
5function 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}
16Object.defineProperty(exports, "__esModule", { value: true });
17exports.default = undo;