Make _.merge align with _.assign exit early snippet.

This commit is contained in:
John-David Dalton
2014-04-28 08:31:54 -07:00
parent 94832f3f81
commit 54a0de9b52

View File

@@ -6760,13 +6760,13 @@
* // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot] }
*/
function merge(object, source, guard) {
if (!object) {
return object;
}
var args = arguments,
length = args.length,
type = typeof guard;
if (!object || length < 2) {
return object;
}
// enables use as a callback for functions like `_.reduce`
if ((type == 'number' || type == 'string') && args[3] && args[3][guard] === source) {
length = 2;