53 lines
2.4 KiB
JavaScript
53 lines
2.4 KiB
JavaScript
/* eslint-disable @typescript-eslint/no-for-in-array */
|
|
(function (factory) {
|
|
if (typeof module === "object" && typeof module.exports === "object") {
|
|
var v = factory(require, exports);
|
|
if (v !== undefined) module.exports = v;
|
|
}
|
|
else if (typeof define === "function" && define.amd) {
|
|
define(["require", "exports"], factory);
|
|
}
|
|
})(function (require, exports) {
|
|
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.mapConnectionsByDestination = mapConnectionsByDestination;
|
|
function mapConnectionsByDestination(connections) {
|
|
const returnConnection = {};
|
|
let connectionInfo;
|
|
let maxIndex;
|
|
for (const sourceNode in connections) {
|
|
if (!connections.hasOwnProperty(sourceNode)) {
|
|
continue;
|
|
}
|
|
for (const type of Object.keys(connections[sourceNode])) {
|
|
if (!connections[sourceNode].hasOwnProperty(type)) {
|
|
continue;
|
|
}
|
|
for (const inputIndex in connections[sourceNode][type]) {
|
|
if (!connections[sourceNode][type].hasOwnProperty(inputIndex)) {
|
|
continue;
|
|
}
|
|
for (connectionInfo of connections[sourceNode][type][inputIndex] ?? []) {
|
|
if (!returnConnection.hasOwnProperty(connectionInfo.node)) {
|
|
returnConnection[connectionInfo.node] = {};
|
|
}
|
|
if (!returnConnection[connectionInfo.node].hasOwnProperty(connectionInfo.type)) {
|
|
returnConnection[connectionInfo.node][connectionInfo.type] = [];
|
|
}
|
|
maxIndex = returnConnection[connectionInfo.node][connectionInfo.type].length - 1;
|
|
for (let j = maxIndex; j < connectionInfo.index; j++) {
|
|
returnConnection[connectionInfo.node][connectionInfo.type].push([]);
|
|
}
|
|
returnConnection[connectionInfo.node][connectionInfo.type][connectionInfo.index]?.push({
|
|
node: sourceNode,
|
|
type,
|
|
index: parseInt(inputIndex, 10),
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return returnConnection;
|
|
}
|
|
});
|
|
//# sourceMappingURL=map-connections-by-destination.js.map
|