From https://stackoverflow.com/questions/27936772/how-to-deep-merge-instead-of-shallow-merge/34749873
export function isObject(item) {
return (item && typeof item === 'object' && !Array.isArray(item) && item !== null);
}
export default function mergeDeep(target, source) {
let output = Object.assign({}, target);
if (isObject(target) && isObject(source)) {
Object.keys(source).forEach(key => {
if (isObject(source[key])) {
if (!(key in target))
Object.assign(output, { [key]: source[key] });
else
output[key] = mergeDeep(target[key], source[key]);
} else {
Object.assign(output, { [key]: source[key] });
}
});
}
return output;
}