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
  d2ce75c7_eb19_6cb1_229b_297218cbe158["walk()"]
  303b7e7d_33cb_6a63_7591_f61feb3c4e3d["themeableValues()"]
  303b7e7d_33cb_6a63_7591_f61feb3c4e3d -->|calls| d2ce75c7_eb19_6cb1_229b_297218cbe158
  3a7318a6_ec18_9d9c_0667_804b7d2f542d["createConverterCache()"]
  3a7318a6_ec18_9d9c_0667_804b7d2f542d -->|calls| d2ce75c7_eb19_6cb1_229b_297218cbe158
  1e85b11a_69b5_68fc_237d_f0167751c10b["substituteFunctionsInValue()"]
  1e85b11a_69b5_68fc_237d_f0167751c10b -->|calls| d2ce75c7_eb19_6cb1_229b_297218cbe158
  025cd786_c6cd_4dc8_21b2_25bd225f52f3["allVariablesAreUsed()"]
  025cd786_c6cd_4dc8_21b2_25bd225f52f3 -->|calls| d2ce75c7_eb19_6cb1_229b_297218cbe158
  cb063cf6_f495_bb4b_84d1_f1d23fb0dae1["createVariantSignatureCache()"]
  cb063cf6_f495_bb4b_84d1_f1d23fb0dae1 -->|calls| d2ce75c7_eb19_6cb1_229b_297218cbe158
  style d2ce75c7_eb19_6cb1_229b_297218cbe158 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

Frequently Asked Questions

What does walk() do?
walk() is a function in the tailwindcss codebase.
What calls walk()?
walk() is called by 5 function(s): allVariablesAreUsed, createConverterCache, createVariantSignatureCache, substituteFunctionsInValue, themeableValues.

Analyze Your Own Codebase

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

Try Supermodel Free