Home / Function/ sortFractionsLast() — tailwindcss Function Reference

sortFractionsLast() — tailwindcss Function Reference

Architecture documentation for the sortFractionsLast() function in intellisense.ts from the tailwindcss codebase.

Function typescript Oxide Scanner calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  7707f914_7814_3866_beb4_b453be6fb367["sortFractionsLast()"]
  aed99406_85bd_0230_7820_e5b6fa3efe70["intellisense.ts"]
  7707f914_7814_3866_beb4_b453be6fb367 -->|defined in| aed99406_85bd_0230_7820_e5b6fa3efe70
  d4f33cd8_f991_3b2a_eeaa_4435de84f79d["getClassList()"]
  d4f33cd8_f991_3b2a_eeaa_4435de84f79d -->|calls| 7707f914_7814_3866_beb4_b453be6fb367
  2820372c_b982_9e06_fc23_f8f4ac308d00["get()"]
  7707f914_7814_3866_beb4_b453be6fb367 -->|calls| 2820372c_b982_9e06_fc23_f8f4ac308d00
  style 7707f914_7814_3866_beb4_b453be6fb367 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/intellisense.ts lines 81–141

function sortFractionsLast(list: ClassItem[]) {
  type Bucket = {
    utility: string
    items: ClassItem[]
  }

  // 1. Create "buckets" for each utility group
  let buckets: Bucket[] = []
  let current: Bucket | null = null

  // 2. Determine the last bucket for each utility group
  let lastUtilityBucket = new Map<string, Bucket>()

  // 3. Collect all fractions in a given utility group
  let fractions = new DefaultMap<string, ClassItem[]>(() => [])

  for (let item of list) {
    let { utility, fraction } = item

    if (!current) {
      current = { utility, items: [] }
      lastUtilityBucket.set(utility, current)
    }

    if (utility !== current.utility) {
      buckets.push(current)

      current = { utility, items: [] }
      lastUtilityBucket.set(utility, current)
    }

    if (fraction) {
      fractions.get(utility).push(item)
    } else {
      current.items.push(item)
    }
  }

  if (current && buckets[buckets.length - 1] !== current) {
    buckets.push(current)
  }

  // 4. Add fractions to their respective last utility buckets
  for (let [utility, items] of fractions) {
    let bucket = lastUtilityBucket.get(utility)
    if (!bucket) continue

    bucket.items.push(...items)
  }

  // 5. Flatten the buckets into a single list
  let entries: ClassEntry[] = []

  for (let bucket of buckets) {
    for (let entry of bucket.items) {
      entries.push([entry.name, { modifiers: entry.modifiers }])
    }
  }

  return entries
}

Domain

Subdomains

Calls

Called By

Frequently Asked Questions

What does sortFractionsLast() do?
sortFractionsLast() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/intellisense.ts.
Where is sortFractionsLast() defined?
sortFractionsLast() is defined in packages/tailwindcss/src/intellisense.ts at line 81.
What does sortFractionsLast() call?
sortFractionsLast() calls 1 function(s): get.
What calls sortFractionsLast()?
sortFractionsLast() is called by 1 function(s): getClassList.

Analyze Your Own Codebase

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

Try Supermodel Free