UNPKG

abapmerge

Version:

Merge ABAP INCLUDEs into single file

80 lines 2.94 kB
"use strict"; var __values = (this && this.__values) || function(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; Object.defineProperty(exports, "__esModule", { value: true }); var Graph = /** @class */ (function () { function Graph() { this.nodes = []; this.edges = []; } Graph.prototype.addNode = function (key, value) { this.nodes.push([key, value]); }; Graph.prototype.addEdge = function (from, to) { this.edges.push([from, to]); }; Graph.prototype.removeNode = function (key) { this.nodes = this.nodes.filter(function (n) { return n[0] !== key; }); this.edges = this.edges.filter(function (e) { return e[1] !== key; }); }; Graph.prototype.toString = function () { var nodes = this.nodes.map(function (n) { return n[0]; }).join(", "); var edges = this.edges.map(function (e) { return e[0] + "->" + e[1]; }).join(", "); return nodes + "\n" + edges; }; Graph.prototype.countNodes = function () { return this.nodes.length; }; Graph.prototype.countEdges = function () { return this.edges.length; }; Graph.prototype.popLeaf = function () { var e_1, _a, e_2, _b; try { for (var _c = __values(this.nodes), _d = _c.next(); !_d.done; _d = _c.next()) { var node = _d.value; var leaf = true; try { for (var _e = (e_2 = void 0, __values(this.edges)), _f = _e.next(); !_f.done; _f = _e.next()) { var edge = _f.value; if (edge[0] === node[0]) { leaf = false; break; } } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_f && !_f.done && (_b = _e.return)) _b.call(_e); } finally { if (e_2) throw e_2.error; } } if (leaf === true) { this.removeNode(node[0]); return node[1]; } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_d && !_d.done && (_a = _c.return)) _a.call(_c); } finally { if (e_1) throw e_1.error; } } throw Error("No leaf found: " + this); }; return Graph; }()); exports.default = Graph; //# sourceMappingURL=graph.js.map