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
  0239eea1_54ce_d149_ab68_b39617f815f1["expandSequence()"]
  dc817c0a_ee3b_7666_cb9d_ef0ab5b72986["brace-expansion.ts"]
  0239eea1_54ce_d149_ab68_b39617f815f1 -->|defined in| dc817c0a_ee3b_7666_cb9d_ef0ab5b72986
  91a1286b_b296_e99a_4150_7ded5cd2aa4e["expand()"]
  91a1286b_b296_e99a_4150_7ded5cd2aa4e -->|calls| 0239eea1_54ce_d149_ab68_b39617f815f1
  style 0239eea1_54ce_d149_ab68_b39617f815f1 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