topologicalSort() — tailwindcss Function Reference
Architecture documentation for the topologicalSort() function in topological-sort.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 3900262f_3007_4fa3_eb99_331945caa19e["topologicalSort()"] 26086ff1_0d4f_fdb2_3fc4_d0c999f90a8c["parseCss()"] 26086ff1_0d4f_fdb2_3fc4_d0c999f90a8c -->|calls| 3900262f_3007_4fa3_eb99_331945caa19e style 3900262f_3007_4fa3_eb99_331945caa19e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/tailwindcss/src/utils/topological-sort.ts lines 1–36
export function topologicalSort<Key>(
graph: Map<Key, Set<Key>>,
options: { onCircularDependency: (path: Key[], start: Key) => void },
): Key[] {
let seen = new Set<Key>()
let wip = new Set<Key>()
let sorted: Key[] = []
function visit(node: Key, path: Key[] = []) {
if (!graph.has(node)) return
if (seen.has(node)) return
// Circular dependency detected
if (wip.has(node)) options.onCircularDependency?.(path, node)
wip.add(node)
for (let dependency of graph.get(node) ?? []) {
path.push(node)
visit(dependency, path)
path.pop()
}
seen.add(node)
wip.delete(node)
sorted.push(node)
}
for (let node of graph.keys()) {
visit(node)
}
return sorted
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does topologicalSort() do?
topologicalSort() is a function in the tailwindcss codebase.
What calls topologicalSort()?
topologicalSort() is called by 1 function(s): parseCss.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free