don't merge arrays in deepMerge by default

This commit is contained in:
tophf 2022-01-23 23:46:10 +03:00
parent 155de766e9
commit da0918f49a

View File

@ -333,13 +333,13 @@ Object.assign(debounce, {
}, },
}); });
function deepMerge(src, dst) { function deepMerge(src, dst, mergeArrays) {
if (!src || typeof src !== 'object') { if (!src || typeof src !== 'object') {
return src; return src;
} }
if (Array.isArray(src)) { if (Array.isArray(src)) {
// using `Array` that belongs to this `window`; not using Array.from as it's slower // using `Array` that belongs to this `window`; not using Array.from as it's slower
if (!dst) dst = Array.prototype.map.call(src, deepCopy); if (!dst || !mergeArrays) dst = Array.prototype.map.call(src, deepCopy);
else for (const v of src) dst.push(deepMerge(v)); else for (const v of src) dst.push(deepMerge(v));
} else { } else {
// using an explicit {} that belongs to this `window` // using an explicit {} that belongs to this `window`