blob: eca9a72b6a1056e95c9ea86e80d864084c0d7f46 [file] [log] [blame]
import isPlainObject from "is-plain-object";
export function mergeDeep(defaults, options) {
const result = Object.assign({}, defaults);
Object.keys(options).forEach((key) => {
if (isPlainObject(options[key])) {
if (!(key in defaults))
Object.assign(result, { [key]: options[key] });
else
result[key] = mergeDeep(defaults[key], options[key]);
}
else {
Object.assign(result, { [key]: options[key] });
}
});
return result;
}