deep-extend
Advanced tools
Comparing version 0.2.6 to 0.2.7
39
index.js
/*! | ||
* Node.JS module "Deep Extend" | ||
* @description Recursive object extending. | ||
* @version 0.2.6 | ||
* @author Viacheslav Lotsmanov (unclechu) <lotsmanov89@gmail.com> | ||
@@ -54,27 +53,27 @@ * @license MIT | ||
for (key in obj) { | ||
if (obj[key] !== void 0) { | ||
src = target[key]; | ||
val = obj[key]; | ||
if ( ! (key in obj)) continue; | ||
if (val === target) continue; | ||
src = target[key]; | ||
val = obj[key]; | ||
if (typeof val !== 'object' || val === null) { | ||
target[key] = val; | ||
continue; | ||
} | ||
if (val === target) continue; | ||
if (typeof src !== 'object') { | ||
clone = (Array.isArray(val)) ? [] : {}; | ||
target[key] = deepExtend(clone, val); | ||
continue; | ||
} | ||
if (typeof val !== 'object' || val === null) { | ||
target[key] = val; | ||
continue; | ||
} | ||
if (Array.isArray(val)) { | ||
clone = (Array.isArray(src)) ? src : []; | ||
} else { | ||
clone = (!Array.isArray(src)) ? src : {}; | ||
} | ||
if (typeof src !== 'object') { | ||
clone = (Array.isArray(val)) ? [] : {}; | ||
target[key] = deepExtend(clone, val); | ||
continue; | ||
} | ||
if (Array.isArray(val)) { | ||
clone = (Array.isArray(src)) ? src : []; | ||
} else { | ||
clone = (!Array.isArray(src)) ? src : {}; | ||
} | ||
target[key] = deepExtend(clone, val); | ||
} | ||
@@ -81,0 +80,0 @@ }); |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"homepage": "https://github.com/unclechu/node-deep-extend", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -23,3 +23,4 @@ Node.JS module “Deep Extend” | ||
}, | ||
f: 5 | ||
f: 5, | ||
g: 123 | ||
}; | ||
@@ -34,3 +35,4 @@ var obj2 = { | ||
e: { one: 1, two: 2 }, | ||
f: [] | ||
f: [], | ||
g: (void 0) | ||
}; | ||
@@ -50,3 +52,4 @@ | ||
c: 5, | ||
e: { one: 1, two: 2 } } | ||
e: { one: 1, two: 2 }, | ||
g: undefined } | ||
*/ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53
5333
68