underscore-deep-extend
Advanced tools
Comparing version 1.0.4 to 1.1.4
{ | ||
"name": "underscore-deep-extend", | ||
"version": "1.0.4", | ||
"version": "1.1.4", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "repository": { |
{ | ||
"name": "underscore-deep-extend", | ||
"version": "1.0.4", | ||
"version": "1.1.4", | ||
"repo": "kurtmilam/underscoreDeepExtend", | ||
@@ -5,0 +5,0 @@ "description": "A deepExtend implementation for underscore, lodash and friends.", |
16
index.js
@@ -17,9 +17,8 @@ /* implementation: Copyright (C) 2012-2013 Kurt Milam - http://xioup.com | Source: https://gist.github.com/1868955 | ||
return function underscoreDeepExtend(obj) { | ||
var parentRE = /#{\s*?_\s*?}/, | ||
slice = Array.prototype.slice; | ||
var parentRE = /#{\s*?_\s*?}/; | ||
_.each(slice.call(arguments, 1), function(source) { | ||
var extendProperty = function(source) { | ||
for (var prop in source) { | ||
if (_.isUndefined(obj[prop]) || _.isFunction(obj[prop]) || _.isNull(source[prop]) || _.isDate(source[prop])) { | ||
obj[prop] = source[prop]; | ||
if (_.isUndefined(obj[prop]) || _.isNull(obj[prop]) ||_.isFunction(obj[prop]) || _.isNull(source[prop]) || _.isDate(source[prop])) { | ||
obj[prop] = _.clone(source[prop]); | ||
} | ||
@@ -35,3 +34,3 @@ else if (_.isString(source[prop]) && parentRE.test(source[prop])) { | ||
} else { | ||
obj[prop] = _.reject(_.deepExtend(_.clone(obj[prop]), source[prop]), function (item) { return _.isNull(item);}); | ||
obj[prop] = _.reject(_.deepExtend(_.clone(obj[prop]), source[prop]), _.isNull); | ||
} | ||
@@ -49,3 +48,6 @@ } | ||
} | ||
}); | ||
}; | ||
_.each(Array.prototype.slice.call(arguments, 1), extendProperty); | ||
return obj; | ||
@@ -52,0 +54,0 @@ }; |
@@ -28,3 +28,3 @@ { | ||
"license": "MIT", | ||
"version": "1.0.4", | ||
"version": "1.1.4", | ||
"repository": { | ||
@@ -31,0 +31,0 @@ "type": "git", |
8920