UNPKG

888 BJavaScriptView Raw
1"use strict";
2var DagGraph_1 = require("../DagGraph");
3var log = require('debug')('redux-dag-history:DagHistory');
4function replaceCurrentState(state, history, config) {
5 log('replace current state');
6 var graph = history.graph;
7 var reader = new DagGraph_1.default(graph);
8 var currentStateId = reader.currentStateId;
9 return {
10 current: state,
11 graph: graph.withMutations(function (g) {
12 var graph = new DagGraph_1.default(g);
13 if (config.stateKeyGenerator) {
14 var hash = config.stateKeyGenerator(state);
15 log('inserting state with key', hash);
16 graph.setHashForState(hash, currentStateId);
17 }
18 return graph.replaceState(currentStateId, state);
19 }),
20 };
21}
22Object.defineProperty(exports, "__esModule", { value: true });
23exports.default = replaceCurrentState;