UNPKG

534 BJavaScriptView Raw
1const no = require('not-defined')
2
3/**
4 * Compute edges which does not refer to existing nodeIds
5 *
6 * @param {Object} edges
7 * @param {Object} nodes
8 * @returns {Array} orphanEdgeIds
9 */
10
11const getOrphanEdgeIds = (edges, nodes) => {
12 var orphanEdgeIds = []
13
14 const nodeIdsNotFound = (nodeId) => (no(nodes[nodeId]))
15
16 for (var edgeId in edges) {
17 var edge = edges[edgeId]
18
19 if (edge.filter(nodeIdsNotFound).length > 0) {
20 orphanEdgeIds.push(edgeId)
21 }
22 }
23
24 return orphanEdgeIds
25}
26
27module.exports = getOrphanEdgeIds