UNPKG

1.09 kBJavaScriptView Raw
1"use strict";
2var DagGraph_1 = require("../DagGraph");
3var nextId_1 = require("../nextId");
4var log = require('debug')('redux-dag-history:DagHistory');
5function createBranch(branchName, history) {
6 log('creating branch %s', branchName);
7 var graph = history.graph, current = history.current;
8 var reader = new DagGraph_1.default(graph);
9 return {
10 current: current,
11 graph: graph.withMutations(function (g) {
12 var reader = new DagGraph_1.default(graph);
13 var lastBranchId = reader.lastBranchId;
14 var newBranchId = nextId_1.default(lastBranchId);
15 return reader
16 .setCurrentBranch(newBranchId)
17 .setLastBranchId(newBranchId)
18 .setBranchName(newBranchId, branchName)
19 .setCommitted(newBranchId, reader.currentStateId)
20 .setFirst(newBranchId, reader.currentStateId)
21 .setLatest(newBranchId, reader.currentStateId);
22 }),
23 };
24}
25Object.defineProperty(exports, "__esModule", { value: true });
26exports.default = createBranch;