topologicalSort() — tailwindcss Function Reference
Architecture documentation for the topologicalSort() function in topological-sort.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 10218540_c5dc_8c2a_f2e5_20d29bc2fa35["topologicalSort()"] 3d25ffeb_f949_61a8_6bd6_cd18a2dd835a["topological-sort.ts"] 10218540_c5dc_8c2a_f2e5_20d29bc2fa35 -->|defined in| 3d25ffeb_f949_61a8_6bd6_cd18a2dd835a f7f9b3da_5977_1aa6_3bcb_bfc607af4e8f["parseCss()"] f7f9b3da_5977_1aa6_3bcb_bfc607af4e8f -->|calls| 10218540_c5dc_8c2a_f2e5_20d29bc2fa35 style 10218540_c5dc_8c2a_f2e5_20d29bc2fa35 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