defaultsDeep
defaultsDeep(
params):DefaultsDeepResult
Defined in: objects/defaults-deep/index.ts:37
Recursively assigns default values from source to target. For each
property, if the target’s value is undefined (or the key is missing), the
source’s value is used. When both target and source have plain objects at
the same key, they are merged recursively. Existing null, 0, "",
false, and array values in the target are preserved.
Parameters
Section titled “Parameters”params
Section titled “params”DefaultsDeepParams
The parameters object
Returns
Section titled “Returns”DefaultsDeepResult
A new object (inputs are not mutated)
Example
Section titled “Example”defaultsDeep({ target: { db: { port: 5432 } }, source: { db: { port: 3306, host: "localhost" }, debug: false },});// => { db: { port: 5432, host: "localhost" }, debug: false }Keywords
Section titled “Keywords”deep defaults, nested defaults, fill undefined recursive, fallback object deep
lodash/defaultsDeep — semantic reference (https://lodash.com/docs/#defaultsDeep)
Throws
Section titled “Throws”Error if target is not a plain object
Throws
Section titled “Throws”Error if source is not a plain object