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
  86796617_8567_a2d8_d154_f31f20830948["expandSequence()"]
  1f29c0ee_be09_f644_3fb8_8d80057c5d97["expand()"]
  1f29c0ee_be09_f644_3fb8_8d80057c5d97 -->|calls| 86796617_8567_a2d8_d154_f31f20830948
  style 86796617_8567_a2d8_d154_f31f20830948 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
}

Subdomains

Called By

Frequently Asked Questions

What does expandSequence() do?
expandSequence() is a function in the tailwindcss codebase.
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