UNPKG

archunit

Version:

ArchUnit TypeScript is an architecture testing library, to specify and assert architecture rules in your TypeScript app

38 lines 1.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CycleUtils = void 0; class CycleUtils { static getOutgoingNeighbours(currentNode, graph) { return currentNode.outgoing .map((edge) => edge.to) .map((id) => graph.find((n) => n.node === id)) .filter((x) => x !== undefined); } static transformEdgeData(edges) { const data = []; const uniqueNodes = CycleUtils.findUniqueNodes(edges); uniqueNodes.forEach((id) => { data.push({ node: id, incoming: edges.filter((x) => x.to === id), outgoing: edges.filter((x) => x.from === id), }); }); return data; } static findUniqueNodes(edges) { const uniqueNodes = []; const pushIfNotFound = (value) => { if (uniqueNodes.indexOf(value) === -1) { uniqueNodes.push(value); } }; edges.forEach((edge) => { pushIfNotFound(edge.from); pushIfNotFound(edge.to); }); return uniqueNodes; } } exports.CycleUtils = CycleUtils; //# sourceMappingURL=cycle-utils.js.map