topologicalSort() — tailwindcss Function Reference
Architecture documentation for the topologicalSort() function in topological-sort.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 22bd78ac_fe2e_139d_1f4a_02ee7bb245b7["topologicalSort()"] b8e9dc9f_cc19_ec86_786c_4c998853381e["topological-sort.ts"] 22bd78ac_fe2e_139d_1f4a_02ee7bb245b7 -->|defined in| b8e9dc9f_cc19_ec86_786c_4c998853381e 3970218d_3d6c_e455_87cc_45b4a094f0e9["parseCss()"] 3970218d_3d6c_e455_87cc_45b4a094f0e9 -->|calls| 22bd78ac_fe2e_139d_1f4a_02ee7bb245b7 style 22bd78ac_fe2e_139d_1f4a_02ee7bb245b7 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, defined in packages/tailwindcss/src/utils/topological-sort.ts.
Where is topologicalSort() defined?
topologicalSort() is defined in packages/tailwindcss/src/utils/topological-sort.ts at line 1.
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