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 OxideEngine Scanner 2 dependents 2 functions

Entity Profile

Dependency Diagram

graph LR
  4c30b1b3_1514_10e0_6b6c_251cab3f6b7b["deep-merge.ts"]
  9b5d2e3d_392e_c654_c350_1352ed70f5e8["resolve-config.ts"]
  9b5d2e3d_392e_c654_c350_1352ed70f5e8 --> 4c30b1b3_1514_10e0_6b6c_251cab3f6b7b
  20b59de8_11c6_2432_2a83_24f6f6e741a7["plugin-functions.ts"]
  20b59de8_11c6_2432_2a83_24f6f6e741a7 --> 4c30b1b3_1514_10e0_6b6c_251cab3f6b7b
  style 4c30b1b3_1514_10e0_6b6c_251cab3f6b7b 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 OxideEngine domain, Scanner 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: OxideEngine, subdomain: Scanner, 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