mergeDeep

Commons
stable

Recursively merge two plain objects into a new object. Nested objects are merged deeply; arrays are combined via an optional resolver, otherwise the target wins.

API

Signature

Signature TypeScript complète, extraite du fichier util.

typescript

API

Paramètres

Paramètres d'entrée acceptés par cet util.

source
Record<string, unknown>
{}
The base object. Its keys are copied first and act as defaults.
target
Record<string, unknown>
{}
The overriding object. Its values win over the source unless both sides are mergeable objects.
arrayFn
(a: Array<unknown>, b: Array<unknown>) => Array<unknown>
Optional resolver invoked when both properties are arrays. When omitted, the target array replaces the source array.

API

Valeur de retour

La valeur retournée par cet util.

A new object combining source and target. Neither input is mutated.

Usage

Exemples

Extraits de code prêts à coller.

Deep merge with nested objects

typescript