Home / Function/ isMiddleOfString() — tailwindcss Function Reference

isMiddleOfString() — tailwindcss Function Reference

Architecture documentation for the isMiddleOfString() function in is-safe-migration.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  32d8a2fe_b5eb_6874_f67a_0d3663faaf89["isMiddleOfString()"]
  15780a15_d07b_4940_2fae_2b625b686371["isSafeMigration()"]
  15780a15_d07b_4940_2fae_2b625b686371 -->|calls| 32d8a2fe_b5eb_6874_f67a_0d3663faaf89
  style 32d8a2fe_b5eb_6874_f67a_0d3663faaf89 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.ts lines 222–250

function isMiddleOfString(line: string): boolean {
  let currentQuote: number | null = null

  for (let i = 0; i < line.length; i++) {
    let char = line.charCodeAt(i)
    switch (char) {
      // Escaped character, skip the next character
      case BACKSLASH:
        i++
        break

      case SINGLE_QUOTE:
      case DOUBLE_QUOTE:
      case BACKTICK:
        // Found matching quote, we are outside of a string
        if (currentQuote === char) {
          currentQuote = null
        }

        // Found a quote, we are inside a string
        else if (currentQuote === null) {
          currentQuote = char
        }
        break
    }
  }

  return currentQuote !== null
}

Subdomains

Called By

Frequently Asked Questions

What does isMiddleOfString() do?
isMiddleOfString() is a function in the tailwindcss codebase.
What calls isMiddleOfString()?
isMiddleOfString() is called by 1 function(s): isSafeMigration.

Analyze Your Own Codebase

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

Try Supermodel Free