Comparing version 0.5.2 to 0.5.3
@@ -300,4 +300,6 @@ /** | ||
if (obj === Infinity) return obj; | ||
var clone = {}; | ||
var clone = (Object.prototype.toString.call(obj) === '[object Array]') ? [] : {}; | ||
for (var i in obj) { | ||
@@ -416,3 +418,8 @@ var value; | ||
if ('object' !== typeof clone[i]) { | ||
clone[i] = {}; | ||
if (Object.prototype.toString.call(obj2[i]) === '[object Array]') { | ||
clone[i] = []; | ||
} | ||
else { | ||
clone[i] = {}; | ||
} | ||
} | ||
@@ -419,0 +426,0 @@ clone[i] = OBJ.merge(clone[i], obj2[i]); |
{ | ||
"name": "JSUS", | ||
"description": "JavaScript UtilS. Collection of general purpose functions. JSUS helps!", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"keywords": [ "util", "general", "array", "eval", "time", "date", "object", "nodeGame"], | ||
@@ -6,0 +6,0 @@ "author": "Stefano Balietti <futur.dorko@gmail.com>", |
@@ -19,2 +19,8 @@ var util = require('util'); | ||
var obj_with_array = { | ||
a: 1, | ||
b: [1, 2], | ||
c: 3, | ||
}; | ||
var obj_with_null = { | ||
@@ -179,2 +185,17 @@ a: 1, | ||
describe('#merge() obj with array in SIMPLE', function() { | ||
var simple_array = JSUS.merge(obj_simple, obj_with_array); | ||
// Merge null in simple | ||
it('should merge the second in the first object', function(){ | ||
simple_array.should.eql(obj_with_array); | ||
}); | ||
it('modification to the merged object should affect any of the merging ones', function(){ | ||
checkClone(simple_array, obj_simple, obj_with_array); | ||
}); | ||
}); | ||
describe('#merge() obj with FALSY values in SIMPLE', function() { | ||
@@ -181,0 +202,0 @@ |
106576
3428