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
  3e2b05f6_b887_fa06_29bc_00b8e9a37e3e["isMiddleOfString()"]
  0e3e8c5a_e3ef_6c0d_8a31_e358e2206f79["is-safe-migration.ts"]
  3e2b05f6_b887_fa06_29bc_00b8e9a37e3e -->|defined in| 0e3e8c5a_e3ef_6c0d_8a31_e358e2206f79
  aa2e93eb_f211_d616_3736_f2a6e60dfa72["isSafeMigration()"]
  aa2e93eb_f211_d616_3736_f2a6e60dfa72 -->|calls| 3e2b05f6_b887_fa06_29bc_00b8e9a37e3e
  style 3e2b05f6_b887_fa06_29bc_00b8e9a37e3e 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