#46 $.extend change to pure javascript

This commit is contained in:
Agriya Dev5
2021-02-16 13:30:25 +05:30
parent ad33f4575b
commit d73a0de6be
2 changed files with 28 additions and 5 deletions

View File

@@ -13,4 +13,25 @@ export function findPos (obj) {
return {left: curleft, top: curtop};
}
return {left: curleft, top: curtop};
}
export function isObject(item) {
return (item && typeof item === 'object' && !Array.isArray(item));
}
export function mergeDeep(target, source) {
let output = Object.assign({}, target);
if (isObject(target) && isObject(source)) {
Object.keys(source).forEach(key => {
if (isObject(source[key])) {
if (!(key in target))
Object.assign(output, { [key]: source[key] });
else
output[key] = mergeDeep(target[key], source[key]);
} else {
Object.assign(output, { [key]: source[key] });
}
});
}
return output;
}