refactor: removed unnecessary else blocks in orderPhases
This commit is contained in:
committed by
2584433
parent
e5fee333fb
commit
2f7a48415b
@@ -174,25 +174,22 @@ export function orderPhases(nodes: AppNode[],edges: Edge[]) : OrderedPhases {
|
|||||||
if (nextPhaseNodes.length === 1 && nextNodes.length === 1) {
|
if (nextPhaseNodes.length === 1 && nextNodes.length === 1) {
|
||||||
connections.set(currentPhase.id, nextPhaseNodes[0].id);
|
connections.set(currentPhase.id, nextPhaseNodes[0].id);
|
||||||
return nextPhase(phases.push(nextPhaseNodes[0] as PhaseNode) - 1, {phaseNodes: phases, connections: connections});
|
return nextPhase(phases.push(nextPhaseNodes[0] as PhaseNode) - 1, {phaseNodes: phases, connections: connections});
|
||||||
} else {
|
}
|
||||||
// handle erroneous states
|
// handle erroneous states
|
||||||
if (nextNodes.length === 0) {
|
if (nextNodes.length === 0) {
|
||||||
throw new Error(`| INVALID PROGRAM | the source handle of "${currentPhase.id}" doesn't have any outgoing connections`);
|
throw new Error(`| INVALID PROGRAM | the source handle of "${currentPhase.id}" doesn't have any outgoing connections`);
|
||||||
} else {
|
}
|
||||||
if (nextNodes.length > 1) {
|
if (nextNodes.length > 1) {
|
||||||
throw new Error(`| INVALID PROGRAM | the source handle of "${currentPhase.id}" connects to too many targets`);
|
throw new Error(`| INVALID PROGRAM | the source handle of "${currentPhase.id}" connects to too many targets`);
|
||||||
} else {
|
}
|
||||||
if (nextNodes[0].type === "end") {
|
if (nextNodes[0].type === "end") {
|
||||||
connections.set(currentPhase.id, "end");
|
connections.set(currentPhase.id, "end");
|
||||||
// returns the final output of the function
|
// returns the final output of the function
|
||||||
return {phaseNodes: phases, connections: connections};
|
return {phaseNodes: phases, connections: connections};
|
||||||
} else {
|
}
|
||||||
throw new Error(`| INVALID PROGRAM | the node "${nextNodes[0].id}" that "${currentPhase.id}" connects to is not a phase or end node`);
|
throw new Error(`| INVALID PROGRAM | the node "${nextNodes[0].id}" that "${currentPhase.id}" connects to is not a phase or end node`);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// initializes the Map describing the connections between phase nodes
|
// initializes the Map describing the connections between phase nodes
|
||||||
// we need this Map to make sure we preserve this information,
|
// we need this Map to make sure we preserve this information,
|
||||||
// so we don't need to do checks on the entire set of edges in further stages of the reduction algorithm
|
// so we don't need to do checks on the entire set of edges in further stages of the reduction algorithm
|
||||||
|
|||||||
Reference in New Issue
Block a user