Home / File/ deep-merge.ts — tailwindcss Source File

deep-merge.ts — tailwindcss Source File

Architecture documentation for deep-merge.ts, a typescript file in the tailwindcss codebase. 0 imports, 2 dependents.

File typescript Oxide PreProcessors 2 dependents 2 functions

Entity Profile

Dependency Diagram

graph LR
  9da6bb9c_f434_9ac9_382e_363699a20d0f["deep-merge.ts"]
  cad44155_17aa_e1d6_081a_8f3b4f06bcde["resolve-config.ts"]
  cad44155_17aa_e1d6_081a_8f3b4f06bcde --> 9da6bb9c_f434_9ac9_382e_363699a20d0f
  3d2f062b_d3ec_6b3a_dc32_9d2e4732e20e["plugin-functions.ts"]
  3d2f062b_d3ec_6b3a_dc32_9d2e4732e20e --> 9da6bb9c_f434_9ac9_382e_363699a20d0f
  style 9da6bb9c_f434_9ac9_382e_363699a20d0f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

export function isPlainObject<T>(value: T): value is T & Record<keyof T, unknown> {
  if (Object.prototype.toString.call(value) !== '[object Object]') {
    return false
  }

  const prototype = Object.getPrototypeOf(value)
  return prototype === null || Object.getPrototypeOf(prototype) === null
}

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

Types

Frequently Asked Questions

What does deep-merge.ts do?
deep-merge.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the Oxide domain, PreProcessors subdomain.
What functions are defined in deep-merge.ts?
deep-merge.ts defines 2 function(s): deepMerge, isPlainObject.
What files import deep-merge.ts?
deep-merge.ts is imported by 2 file(s): plugin-functions.ts, resolve-config.ts.
Where is deep-merge.ts in the architecture?
deep-merge.ts is located at packages/tailwindcss/src/compat/config/deep-merge.ts (domain: Oxide, subdomain: PreProcessors, directory: packages/tailwindcss/src/compat/config).

Analyze Your Own Codebase

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

Try Supermodel Free