Home / Function/ walk() — tailwindcss Function Reference

walk() — tailwindcss Function Reference

Architecture documentation for the walk() function in apply-config-to-theme.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  b92bc591_9881_2dfd_426d_e63f7f4fb8b8["walk()"]
  245c850a_c551_a2cf_854e_bba95b5a1339["apply-config-to-theme.ts"]
  b92bc591_9881_2dfd_426d_e63f7f4fb8b8 -->|defined in| 245c850a_c551_a2cf_854e_bba95b5a1339
  f0444c59_74bb_21c0_b8e1_c65ad667fa51["themeableValues()"]
  f0444c59_74bb_21c0_b8e1_c65ad667fa51 -->|calls| b92bc591_9881_2dfd_426d_e63f7f4fb8b8
  style b92bc591_9881_2dfd_426d_e63f7f4fb8b8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/compat/apply-config-to-theme.ts lines 278–303

function walk(
  obj: Record<string, unknown>,
  path: string[] = [],
  callback: (value: unknown, path: string[]) => WalkAction | void,
) {
  for (let key of Reflect.ownKeys(obj) as string[]) {
    let value = obj[key]

    if (value === undefined || value === null) {
      continue
    }

    let keyPath = [...path, key]

    let result = callback(value, keyPath) ?? WalkAction.Continue

    if (result === WalkAction.Skip) continue
    if (result === WalkAction.Stop) return WalkAction.Stop

    if (!Array.isArray(value) && typeof value !== 'object') continue

    if (walk(value as any, keyPath, callback) === WalkAction.Stop) {
      return WalkAction.Stop
    }
  }
}

Subdomains

Called By

Frequently Asked Questions

What does walk() do?
walk() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/compat/apply-config-to-theme.ts.
Where is walk() defined?
walk() is defined in packages/tailwindcss/src/compat/apply-config-to-theme.ts at line 278.
What calls walk()?
walk() is called by 1 function(s): themeableValues.

Analyze Your Own Codebase

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

Try Supermodel Free