Skip to content

Commit

Permalink
Use for numeric changes instead of
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed Jan 15, 2014
1 parent 9aec839 commit c2787d8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/utils/diff.js
Expand Up @@ -24,7 +24,7 @@ Omnom.prototype.onObject = function(original, modified, changePath) {
return (original !== modified) && this.set(changePath, modified);

if(typeof original == 'number' && typeof modified == 'number' && original !== modified)
return this.inc(changePath, modified - original);
return this.set(changePath, modified);

if(Array.isArray(original) && Array.isArray(modified))
return this.onArray(original, modified, changePath);
Expand Down
6 changes: 2 additions & 4 deletions test/diff.js
Expand Up @@ -19,8 +19,7 @@ describe('diff', function() {
};

var expected = {
$inc: { a: 2 },
$set: { b: 'tested', f: 'new' },
$set: { a: 3, b: 'tested', f: 'new' },
$unset: { e: 1 }
};

Expand All @@ -45,8 +44,7 @@ describe('diff', function() {
};

var expected = {
$inc: { 'a.value': 2, 'b.value2': 1 },
$set: { 'b.value1': 'tested', 'e.value2': false },
$set: { 'a.value': 3, 'b.value1': 'tested', 'b.value2': 2, 'e.value2': false },
$unset: { 'e.value': 1 }
};

Expand Down

0 comments on commit c2787d8

Please sign in to comment.