MCPcopy Create free account
hub / github.com/angular/dev-infra / compareCircularDependency

Function compareCircularDependency

ng-dev/ts-circular-dependencies/golden.ts:125–136  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

123 * cycle paths. The first nodes which don't match in both paths are decisive on the order.
124 */
125function 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected