Home / Function/ deepMerge() — tailwindcss Function Reference

deepMerge() — tailwindcss Function Reference

Architecture documentation for the deepMerge() function in deep-merge.ts from the tailwindcss codebase.

Function typescript OxideEngine Scanner calls 1 called by 2

Entity Profile

Dependency Diagram

graph TD
  a21213f9_9467_d282_d4f1_fcb2cf2ae2fc["deepMerge()"]
  4c30b1b3_1514_10e0_6b6c_251cab3f6b7b["deep-merge.ts"]
  a21213f9_9467_d282_d4f1_fcb2cf2ae2fc -->|defined in| 4c30b1b3_1514_10e0_6b6c_251cab3f6b7b
  63f5d3ac_b848_6ab0_af8e_5d1ec324c0d5["mergeTheme()"]
  63f5d3ac_b848_6ab0_af8e_5d1ec324c0d5 -->|calls| a21213f9_9467_d282_d4f1_fcb2cf2ae2fc
  d30151e4_eee8_a868_f516_c653088f4a03["createThemeFn()"]
  d30151e4_eee8_a868_f516_c653088f4a03 -->|calls| a21213f9_9467_d282_d4f1_fcb2cf2ae2fc
  2dacf643_3af3_ced5_8784_dc1356541f05["isPlainObject()"]
  a21213f9_9467_d282_d4f1_fcb2cf2ae2fc -->|calls| 2dacf643_3af3_ced5_8784_dc1356541f05
  style a21213f9_9467_d282_d4f1_fcb2cf2ae2fc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/compat/config/deep-merge.ts lines 10–40

export function deepMerge<T extends object>(
  target: T,
  sources: (Partial<T> | null | undefined)[],
  customizer: (a: any, b: any, keypath: (keyof T)[]) => any,
  path: (keyof T)[] = [],
) {
  type Key = keyof T
  type Value = T[Key]

  for (let source of sources) {
    if (source === null || source === undefined) {
      continue
    }

    for (let k of Reflect.ownKeys(source) as Key[]) {
      path.push(k)
      let merged = customizer(target[k], source[k], path)

      if (merged !== undefined) {
        target[k] = merged
      } else if (!isPlainObject(target[k]) || !isPlainObject(source[k])) {
        target[k] = source[k] as Value
      } else {
        target[k] = deepMerge({}, [target[k], source[k]], customizer, path as any) as Value
      }
      path.pop()
    }
  }

  return target
}

Domain

Subdomains

Frequently Asked Questions

What does deepMerge() do?
deepMerge() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/compat/config/deep-merge.ts.
Where is deepMerge() defined?
deepMerge() is defined in packages/tailwindcss/src/compat/config/deep-merge.ts at line 10.
What does deepMerge() call?
deepMerge() calls 1 function(s): isPlainObject.
What calls deepMerge()?
deepMerge() is called by 2 function(s): createThemeFn, mergeTheme.

Analyze Your Own Codebase

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

Try Supermodel Free