UNPKG

@ultipa-graph/ultipa-node-sdk

Version:

NodeJS SDK for ultipa-server 4.0

40 lines 1.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.printPath = exports.getPathsPrintInfo = void 0; const types_1 = require("../types"); const alias_1 = require("./alias"); function getPathsPrintInfo(paths) { let pathsStr = []; paths === null || paths === void 0 ? void 0 : paths.forEach(p => { var _a; let pathString = []; (_a = p.edges) === null || _a === void 0 ? void 0 : _a.forEach((edge, index) => { let node = p.nodes[index]; let d1 = "-"; let d2 = "-"; if (edge) { if ((edge === null || edge === void 0 ? void 0 : edge.from) == (node === null || node === void 0 ? void 0 : node.id)) { d2 = "->"; } else { d1 = "<-"; } } pathString.push(`(${(node === null || node === void 0 ? void 0 : node.id) || (node === null || node === void 0 ? void 0 : node.uuid) || null}) ${d1} [${(edge === null || edge === void 0 ? void 0 : edge.uuid) || null}] ${d2}`); }); let lastNode = p.nodes[p.nodes.length - 1]; pathString.push(`(${(lastNode === null || lastNode === void 0 ? void 0 : lastNode.id) || (lastNode === null || lastNode === void 0 ? void 0 : lastNode.uuid) || null})`); pathsStr.push(pathString.join(" ")); }); return pathsStr; } exports.getPathsPrintInfo = getPathsPrintInfo; function printPath(d) { if ((d === null || d === void 0 ? void 0 : d.type) == types_1.ULTIPA.ResultType.RESULT_TYPE_PATH) { let paths = d.asPaths(); (0, alias_1.printAlias)(d); console.table(getPathsPrintInfo(paths)); } } exports.printPath = printPath; //# sourceMappingURL=path.js.map