mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-25 09:55:15 +00:00
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
"use strict";
|
|
|
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.isPlainObject = isPlainObject;
|
|
exports.default = deepmerge;
|
|
|
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
|
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
|
|
function isPlainObject(item) {
|
|
return item && (0, _typeof2.default)(item) === 'object' && item.constructor === Object;
|
|
}
|
|
|
|
function deepmerge(target, source) {
|
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
clone: true
|
|
};
|
|
var output = options.clone ? (0, _extends2.default)({}, 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;
|
|
} |