Home / Function/ toKeyPath() — tailwindcss Function Reference

toKeyPath() — tailwindcss Function Reference

Architecture documentation for the toKeyPath() function in to-key-path.ts from the tailwindcss codebase.

Function typescript Oxide Extractor calls 1 called by 5

Entity Profile

Dependency Diagram

graph TD
  05d44181_6631_c1fa_4a63_96653e28f99c["toKeyPath()"]
  1f643124_89df_1d95_f8fd_e4036c7301de["to-key-path.ts"]
  05d44181_6631_c1fa_4a63_96653e28f99c -->|defined in| 1f643124_89df_1d95_f8fd_e4036c7301de
  0838eb2e_5580_246c_b5a8_b68fb91edccc["migratePreflight()"]
  0838eb2e_5580_246c_b5a8_b68fb91edccc -->|calls| 05d44181_6631_c1fa_4a63_96653e28f99c
  f1c7fb37_4a69_f6f5_b7f4_9f3d8b534c40["createConverter()"]
  f1c7fb37_4a69_f6f5_b7f4_9f3d8b534c40 -->|calls| 05d44181_6631_c1fa_4a63_96653e28f99c
  7f0ac26e_d200_2f14_4236_46ff9eed21ef["createConverterCache()"]
  7f0ac26e_d200_2f14_4236_46ff9eed21ef -->|calls| 05d44181_6631_c1fa_4a63_96653e28f99c
  31653e23_464a_3652_4a48_0c82332a92c4["buildPluginApi()"]
  31653e23_464a_3652_4a48_0c82332a92c4 -->|calls| 05d44181_6631_c1fa_4a63_96653e28f99c
  dabb13bc_6018_934b_19c4_595b7bea686d["createThemeFn()"]
  dabb13bc_6018_934b_19c4_595b7bea686d -->|calls| 05d44181_6631_c1fa_4a63_96653e28f99c
  c58cbb33_f3cc_0b4f_844a_15bf66a1dc61["segment()"]
  05d44181_6631_c1fa_4a63_96653e28f99c -->|calls| c58cbb33_f3cc_0b4f_844a_15bf66a1dc61
  style 05d44181_6631_c1fa_4a63_96653e28f99c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/utils/to-key-path.ts lines 18–54

export function toKeyPath(path: string) {
  let keypath: string[] = []

  for (let part of segment(path, '.')) {
    if (!part.includes('[')) {
      keypath.push(part)
      continue
    }

    let currentIndex = 0

    while (true) {
      let bracketL = part.indexOf('[', currentIndex)
      let bracketR = part.indexOf(']', bracketL)

      if (bracketL === -1 || bracketR === -1) {
        break
      }

      // Add the part before the bracket as a key
      if (bracketL > currentIndex) {
        keypath.push(part.slice(currentIndex, bracketL))
      }

      // Add the part inside the bracket as a key
      keypath.push(part.slice(bracketL + 1, bracketR))
      currentIndex = bracketR + 1
    }

    // Add the part after the last bracket as a key
    if (currentIndex <= part.length - 1) {
      keypath.push(part.slice(currentIndex))
    }
  }

  return keypath
}

Domain

Subdomains

Calls

Frequently Asked Questions

What does toKeyPath() do?
toKeyPath() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/utils/to-key-path.ts.
Where is toKeyPath() defined?
toKeyPath() is defined in packages/tailwindcss/src/utils/to-key-path.ts at line 18.
What does toKeyPath() call?
toKeyPath() calls 1 function(s): segment.
What calls toKeyPath()?
toKeyPath() is called by 5 function(s): buildPluginApi, createConverter, createConverterCache, createThemeFn, migratePreflight.

Analyze Your Own Codebase

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

Try Supermodel Free