Home / Function/ getClassOrder() — tailwindcss Function Reference

getClassOrder() — tailwindcss Function Reference

Architecture documentation for the getClassOrder() function in sort.ts from the tailwindcss codebase.

Function typescript OxideEngine Scanner calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  58b955a9_8496_3780_d1da_e267f826d91a["getClassOrder()"]
  bf0678b8_90e6_000a_31a6_275ff72b1b2b["sort.ts"]
  58b955a9_8496_3780_d1da_e267f826d91a -->|defined in| bf0678b8_90e6_000a_31a6_275ff72b1b2b
  9b965fd7_d8e9_0b43_cd5d_c9294ab598ed["buildDesignSystem()"]
  9b965fd7_d8e9_0b43_cd5d_c9294ab598ed -->|calls| 58b955a9_8496_3780_d1da_e267f826d91a
  f611bd99_74d3_1161_f7f5_4c1d73c377e5["compileCandidates()"]
  58b955a9_8496_3780_d1da_e267f826d91a -->|calls| f611bd99_74d3_1161_f7f5_4c1d73c377e5
  style 58b955a9_8496_3780_d1da_e267f826d91a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/sort.ts lines 4–30

export function getClassOrder(design: DesignSystem, classes: string[]): [string, bigint | null][] {
  // Generate a sorted AST
  let { astNodes, nodeSorting } = compileCandidates(Array.from(classes), design)

  // Map class names to their order in the AST
  // `null` indicates a non-Tailwind class
  let sorted = new Map<string, bigint | null>(classes.map((className) => [className, null]))

  // Assign each class a unique, sorted number
  let idx = 0n

  for (let node of astNodes) {
    let candidate = nodeSorting.get(node)?.candidate
    if (!candidate) continue

    // When multiple rules match a candidate
    // always take the position of the first one
    sorted.set(candidate, sorted.get(candidate) ?? idx++)
  }

  // Pair classes with their assigned sorting number
  return classes.map((className) => [
    //
    className,
    sorted.get(className) ?? null,
  ])
}

Domain

Subdomains

Frequently Asked Questions

What does getClassOrder() do?
getClassOrder() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/sort.ts.
Where is getClassOrder() defined?
getClassOrder() is defined in packages/tailwindcss/src/sort.ts at line 4.
What does getClassOrder() call?
getClassOrder() calls 1 function(s): compileCandidates.
What calls getClassOrder()?
getClassOrder() is called by 1 function(s): buildDesignSystem.

Analyze Your Own Codebase

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

Try Supermodel Free