Home / Function/ expandSequence() — tailwindcss Function Reference

expandSequence() — tailwindcss Function Reference

Architecture documentation for the expandSequence() function in brace-expansion.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  4737ac97_5889_1afc_badb_944e15af3828["expandSequence()"]
  5df5aa0d_5ac4_161a_e624_dc3b15de4a28["brace-expansion.ts"]
  4737ac97_5889_1afc_badb_944e15af3828 -->|defined in| 5df5aa0d_5ac4_161a_e624_dc3b15de4a28
  4e82d568_7e90_60c3_1671_8ea6ca89c260["expand()"]
  4e82d568_7e90_60c3_1671_8ea6ca89c260 -->|calls| 4737ac97_5889_1afc_badb_944e15af3828
  style 4737ac97_5889_1afc_badb_944e15af3828 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/utils/brace-expansion.ts lines 62–91

function expandSequence(seq: string): string[] {
  let seqMatch = seq.match(NUMERICAL_RANGE)
  if (!seqMatch) {
    return [seq]
  }
  let [, start, end, stepStr] = seqMatch
  let step = stepStr ? parseInt(stepStr, 10) : undefined
  let result: string[] = []

  if (/^-?\d+$/.test(start) && /^-?\d+$/.test(end)) {
    let startNum = parseInt(start, 10)
    let endNum = parseInt(end, 10)

    if (step === undefined) {
      step = startNum <= endNum ? 1 : -1
    }
    if (step === 0) {
      throw new Error('Step cannot be zero in sequence expansion.')
    }

    let increasing = startNum < endNum
    if (increasing && step < 0) step = -step
    if (!increasing && step > 0) step = -step

    for (let i = startNum; increasing ? i <= endNum : i >= endNum; i += step) {
      result.push(i.toString())
    }
  }
  return result
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does expandSequence() do?
expandSequence() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/utils/brace-expansion.ts.
Where is expandSequence() defined?
expandSequence() is defined in packages/tailwindcss/src/utils/brace-expansion.ts at line 62.
What calls expandSequence()?
expandSequence() is called by 1 function(s): expand.

Analyze Your Own Codebase

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

Try Supermodel Free