Home / File/ topological-sort.ts — tailwindcss Source File

topological-sort.ts — tailwindcss Source File

Architecture documentation for topological-sort.ts, a typescript file in the tailwindcss codebase. 0 imports, 1 dependents.

File typescript OxideEngine Extractor 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  b8e9dc9f_cc19_ec86_786c_4c998853381e["topological-sort.ts"]
  5af9cd3c_2cf4_9dee_376e_fc39122d865a["index.ts"]
  5af9cd3c_2cf4_9dee_376e_fc39122d865a --> b8e9dc9f_cc19_ec86_786c_4c998853381e
  style b8e9dc9f_cc19_ec86_786c_4c998853381e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

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

Functions

Frequently Asked Questions

What does topological-sort.ts do?
topological-sort.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the OxideEngine domain, Extractor subdomain.
What functions are defined in topological-sort.ts?
topological-sort.ts defines 1 function(s): topologicalSort.
What files import topological-sort.ts?
topological-sort.ts is imported by 1 file(s): index.ts.
Where is topological-sort.ts in the architecture?
topological-sort.ts is located at packages/tailwindcss/src/utils/topological-sort.ts (domain: OxideEngine, subdomain: Extractor, directory: packages/tailwindcss/src/utils).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free