I should have given an example. Normally I am using the following pattern, for default nested options:
const options = { b: 2, c: 3, nested: { e: 5, f: 6, }, }; const defaultOptions = { a: 1, b: "two", nested: { d: 4, e: "five", }, }; // this mutates `defaultOptions`: const composedOptions = _.merge(defaultOptions, options); // this preserves `defaultOptions`: // const composedOptions = _.merge({}, defaultOptions, options); console.log(composedOptions); // => { a: 1, b: 2, c: 3, nested: { d: 4, e: 5, f: 6 }}
If you want to tweak the behaviour of value replacement differently for some values, you can use mergeWith. It's quite similar what the library is accomblishing.
mergeWith
We're a place where coders share, stay up-to-date and grow their careers.
I should have given an example. Normally I am using the following pattern, for default nested options:
If you want to tweak the behaviour of value replacement differently for some values, you can use
mergeWith. It's quite similar what the library is accomblishing.