Skip to content

Commit cfe936d

Browse files
author
flitbit
committed
2 parents 7ca97e2 + b7d4698 commit cfe936d

File tree

7 files changed

+63
-4
lines changed

7 files changed

+63
-4
lines changed

Readme.md

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
npm install deep-diff
1515
```
1616

17+
For the browser, you can install with [bower](http://bower.io/):
18+
19+
```
20+
bower install deep-diff
21+
```
22+
1723
## Tests
1824

1925
Tests use [mocha](http://visionmedia.github.io/mocha/) and [expect.js](https://github.com/LearnBoost/expect.js/), so if you clone the [github repository](https://github.com/flitbit/json-ptr) you'll need to run:

bower.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "deep-diff",
3+
"main": "index.js",
4+
"version": "0.1.4",
5+
"homepage": "https://github.com/flitbit/diff",
6+
"authors": [
7+
"Phillip Clark <[email protected]>"
8+
],
9+
"description": "Javascript utility for calculating deep difference, capturing changes, and applying changes across objects; for nodejs and the browser.",
10+
"keywords": [
11+
"diff",
12+
"difference",
13+
"compare",
14+
"change-tracking"
15+
],
16+
"license": "MIT",
17+
"ignore": [
18+
"**/.*",
19+
"node_modules",
20+
"bower_components",
21+
"app/bower_components",
22+
"test",
23+
"tests"
24+
]
25+
}

index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@
8888
changes(new DiffDeleted(currentPath, lhs));
8989
} else if (ltype !== rtype) {
9090
changes(new DiffEdit(currentPath, lhs, rhs));
91-
} else if (ltype === 'object' && lhs != null) {
91+
} else if (lhs instanceof Date && rhs instanceof Date && ((lhs-rhs) != 0) ) {
92+
changes(new DiffEdit(currentPath, lhs, rhs));
93+
} else if (ltype === 'object' && lhs != null && rhs != null) {
9294
stack = stack || [];
9395
if (stack.indexOf(lhs) < 0) {
9496
stack.push(lhs);

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "deep-diff",
33
"description": "Javascript utility for calculating deep difference, capturing changes, and applying changes across objects; for nodejs and the browser.",
4-
"version": "0.1.3",
4+
"version": "0.1.4",
55
"keywords": [
66
"diff",
77
"difference",
@@ -10,7 +10,8 @@
1010
],
1111
"author": "Phillip Clark <[email protected]>",
1212
"contributors": [
13-
"SocalNick"
13+
"SocalNick",
14+
"sonstone"
1415
],
1516
"repository": { "type": "git", "url": "git://github.com/flitbit/diff.git" },
1617
"main": "./index.js",

releases/deep-diff-0.1.4.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/tests.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
DeepDiff = { Conflict: "here" };
1818
DeepDiffConflict = DeepDiff;
1919
</script>
20-
<script src="../releases/deep-diff-0.1.3.min.js"></script>
20+
<script src="../releases/deep-diff-0.1.4.min.js"></script>
2121
<!--script src="../index.js"></script-->
2222
<script>mocha.setup('bdd')</script>
2323
<script src="tests.js"></script>

test/tests.js

+24
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,32 @@ describe('deep-diff', function() {
9494
expect(diff[0].kind).to.be('E');
9595
});
9696

97+
it('shows that an object property is changed when it is set to null', function() {
98+
lhs.key = {nested: 'value'};
99+
var diff = deep.diff(lhs, { key: null });
100+
expect(diff).to.be.ok();
101+
expect(diff.length).to.be(1);
102+
expect(diff[0]).to.have.property('kind');
103+
expect(diff[0].kind).to.be('E');
104+
});
105+
97106
});
98107

108+
109+
describe('A target that has a date value', function() {
110+
var lhs = { key: new Date(555555555555) };
111+
112+
it('shows the property is changed with a new date value', function() {
113+
var diff = deep.diff(lhs, { key: new Date(777777777777) });
114+
expect(diff).to.be.ok();
115+
expect(diff.length).to.be(1);
116+
expect(diff[0]).to.have.property('kind');
117+
expect(diff[0].kind).to.be('E');
118+
});
119+
120+
});
121+
122+
99123
describe('When executing in a browser (otherwise these tests are benign)', function() {
100124

101125
it('#isConflict reports conflict in the global namespace for `DeepDiff`', function() {

0 commit comments

Comments
 (0)