mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 17:35:16 +00:00
28 lines
866 B
JavaScript
28 lines
866 B
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
export function isPlainObject(item) {
|
|
return item && _typeof(item) === 'object' && item.constructor === Object;
|
|
}
|
|
export default function deepmerge(target, source) {
|
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
clone: true
|
|
};
|
|
var output = options.clone ? _extends({}, target) : target;
|
|
|
|
if (isPlainObject(target) && isPlainObject(source)) {
|
|
Object.keys(source).forEach(function (key) {
|
|
// Avoid prototype pollution
|
|
if (key === '__proto__') {
|
|
return;
|
|
}
|
|
|
|
if (isPlainObject(source[key]) && key in target) {
|
|
output[key] = deepmerge(target[key], source[key], options);
|
|
} else {
|
|
output[key] = source[key];
|
|
}
|
|
});
|
|
}
|
|
|
|
return output;
|
|
} |