(unit: UnitModule)
| 980 | const ordered: UnitModule[] = [] |
| 981 | const state = new Map<string, "visiting" | "done">() |
| 982 | const visit = (unit: UnitModule): boolean => { |
| 983 | if (state.get(unit.specifier) === "done") return true |
| 984 | if (state.get(unit.specifier) === "visiting") return false |
| 985 | state.set(unit.specifier, "visiting") |
| 986 | for (const source of importsOf(unit.module)) { |
| 987 | const read = units.get(source) |
| 988 | if (read && !visit(read)) return false |
| 989 | } |
| 990 | state.set(unit.specifier, "done") |
| 991 | ordered.push(unit) |
| 992 | return true |
| 993 | } |
| 994 | for (const unit of units.values()) if (!visit(unit)) return |
| 995 | // two modules declaring a name would declare it twice in one function |
| 996 | const declared = new Set<string>() |
no test coverage detected