(id: string)
| 2212 | const temp = new Set<string>(); |
| 2213 | const perm = new Set<string>(); |
| 2214 | const visit = (id: string) => { |
| 2215 | if (perm.has(id)) return; |
| 2216 | if (temp.has(id)) { |
| 2217 | perm.add(id); |
| 2218 | return; |
| 2219 | } // cycle: bail out |
| 2220 | temp.add(id); |
| 2221 | const m = graph.get(id); |
| 2222 | if (m) { |
| 2223 | for (const d of m.deps) { |
| 2224 | if (toVisit.has(d)) visit(d); |
| 2225 | } |
| 2226 | } |
| 2227 | temp.delete(id); |
| 2228 | perm.add(id); |
| 2229 | ordered.push(id); |
| 2230 | }; |
| 2231 | for (const id of toVisit) visit(id); |
| 2232 | // Ensure we only include those that were part of closure (already ensured) and preserve an order where deps appear before dependents |
| 2233 | return ordered; |
no test coverage detected