@workday/canvas-kit-react
Version:
The parent module that contains all Workday Canvas Kit React components
25 lines (24 loc) • 826 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.deepMerge = void 0;
const isObject = (obj) => obj && typeof obj === 'object';
function deepMerge(target, source) {
if (!isObject(target) || !isObject(source)) {
return source;
}
Object.keys(source).forEach(key => {
const targetValue = target[key];
const sourceValue = source[key];
if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
target[key] = targetValue.concat(sourceValue);
}
else if (isObject(targetValue) && isObject(sourceValue)) {
target[key] = deepMerge(Object.assign({}, targetValue), sourceValue);
}
else {
target[key] = sourceValue;
}
});
return target;
}
exports.deepMerge = deepMerge;
;