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
  d1610c40_828a_2a82_2129_746c9cd742ea["isMiddleOfString()"]
  d5e14c3d_f7c4_162e_96e8_83915119d547["is-safe-migration.ts"]
  d1610c40_828a_2a82_2129_746c9cd742ea -->|defined in| d5e14c3d_f7c4_162e_96e8_83915119d547
  b779d35b_89d6_7939_9231_39f9aa250ab3["isSafeMigration()"]
  b779d35b_89d6_7939_9231_39f9aa250ab3 -->|calls| d1610c40_828a_2a82_2129_746c9cd742ea
  style d1610c40_828a_2a82_2129_746c9cd742ea 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, defined in packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.ts.
Where is isMiddleOfString() defined?
isMiddleOfString() is defined in packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.ts at line 222.
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