MultiLoader-Template/node_modules/es-toolkit/dist/object/toMerged.js
3944Realms 768f38fc97 feat: 可使用的构建模板
修改了脚本,使其可以推给Maven仓库
2026-05-03 13:02:19 +08:00

31 lines
1.1 KiB
JavaScript

'use strict';
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const clone = require('./clone.js');
const mergeWith = require('./mergeWith.js');
const isPlainObject = require('../predicate/isPlainObject.js');
function toMerged(target, source) {
return mergeWith.mergeWith(clone.clone(target), source, function mergeRecursively(targetValue, sourceValue) {
if (Array.isArray(sourceValue)) {
if (Array.isArray(targetValue)) {
return mergeWith.mergeWith(clone.clone(targetValue), sourceValue, mergeRecursively);
}
else {
return mergeWith.mergeWith([], sourceValue, mergeRecursively);
}
}
else if (isPlainObject.isPlainObject(sourceValue)) {
if (isPlainObject.isPlainObject(targetValue)) {
return mergeWith.mergeWith(clone.clone(targetValue), sourceValue, mergeRecursively);
}
else {
return mergeWith.mergeWith({}, sourceValue, mergeRecursively);
}
}
});
}
exports.toMerged = toMerged;