* Compares two circular dependencies by respecting the alphabetic order of nodes in the * cycle paths. The first nodes which don't match in both paths are decisive on the order.
(a: CircularDependency, b: CircularDependency)
| 123 | * cycle paths. The first nodes which don't match in both paths are decisive on the order. |
| 124 | */ |
| 125 | function compareCircularDependency(a: CircularDependency, b: CircularDependency): number { |
| 126 | // Go through nodes in both cycle paths and determine whether `a` should be ordered |
| 127 | // before `b`. The first nodes which don't match decide on the order. |
| 128 | for (let i = 0; i < Math.min(a.length, b.length); i++) { |
| 129 | const compareValue = a[i].localeCompare(b[i], 'en'); |
| 130 | if (compareValue !== 0) { |
| 131 | return compareValue; |
| 132 | } |
| 133 | } |
| 134 | // If all nodes are equal in the cycles, the order is based on the length of both cycles. |
| 135 | return a.length - b.length; |
| 136 | } |
nothing calls this directly
no outgoing calls
no test coverage detected