diff --git a/index.js b/index.js index ce55325..092daf7 100644 --- a/index.js +++ b/index.js @@ -22,7 +22,7 @@ var comparing = []; function compare(path, old, new_) { var changes = []; if (old !== null && new_ !== null && - typeof old === 'object' && + typeof old === 'object' && typeof new_ === 'object' && !_.contains(comparing, old)) { comparing.push(old); diff --git a/test/index.js b/test/index.js index df6dc9e..3ff0ef2 100644 --- a/test/index.js +++ b/test/index.js @@ -243,4 +243,12 @@ describe('changeset', function () { ]); done(); }); + + it('should be able to diff from an object to a basic type', function() { + var a = {hello: {nested: 2}}; + var b = {hello: 3}; + var changeset = diff(a, b); + var b_ = diff.apply(changeset, a); + expect(b).to.deep.equals(b_); + }); });