
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
js-deep-diff
Advanced tools
An lightly library for comparing two javascript object structure, 1kb after gziped.
$ npm install js-deep-diff
$ yarn add js-deep-diff
Something you should know before using:
new String('string') is NOT equivalent to 'string'new Number(1) is NOT equivalent to 1new Boolean(false) is NOT equivalent to false{0: 1} is NOT equivalent to [1]new RegExp('\\s') is EQUIVALENT to /\s/new Date("1970-01-01T00:00:00.000Z") is EQUIVALENT to new Date("Thu, 01 Jan 1970 00:00:00 GMT")It's different with deep-object-diff and some library else. (deep-object-diff regard {0: 1} as [1]).
const diff = require('js-deep-diff')
const lhs = {
name: 'my object',
description: 'it\'s an object!',
details: {
it: 'has',
an: 'array',
with: ['a', 'few', 'elements']
},
others: {
distance: 0,
hight: 1
}
}
const rhs = {
name: 'updated object',
description: 'it\'s an object!',
details: {
it: 'has',
an: 'array',
with: ['a', 'few', 'more', 'elements', {
than: 'before'
}]
},
others: {
distance: 0
}
}
diff(lhs, rhs)
Then got the differences:
[
{
"type": "EDIT",
"path": [
"name"
],
"lhs": "my object",
"rhs": "updated object"
},
{
"type": "EDIT",
"path": [
"details",
"with",
2
],
"lhs": "elements",
"rhs": "more"
},
{
"type": "ADD",
"path": [
"details",
"with",
3
],
"rhs": "elements"
},
{
"type": "ADD",
"path": [
"details",
"with",
4
],
"rhs": {
"than": "before"
}
},
{
"type": "EDIT",
"path": [
"others"
],
"lhs": {
"distance": 0,
"hight": 1
},
"rhs": {
"distance": 0
}
}
]
default: false[
{
"type": "EDIT",
"path": [
"name"
],
"lhs": "my object",
"rhs": "updated object"
},
{
"type": "EDIT",
"path": [
"details",
"with",
2
],
"lhs": "elements",
"rhs": "more"
},
{
"type": "ADD",
"path": [
"details",
"with",
3
],
"rhs": "elements"
},
{
"type": "ADD",
"path": [
"details",
"with",
4
],
"rhs": {
"than": "before"
}
},
{
"type": "EDIT",
"path": [
"others"
],
"lhs": {
"distance": 0,
"hight": 1
},
"rhs": {
"distance": 0
}
},
+ {
+ "type": "DEL",
+ "path": [
+ "others",
+ "hight"
+ ],
+ "lhs": 1
+ }
]
$ npm run test
diff ✓ Same value ✓ Empty value: null ✓ Empty value: undefind ✓ Date ✓ Boolean ✓ Number ✓ String ✓ RegExp ✓ Pirmitive value ✓ Add action in array ✓ Edit action in array ✓ Delete action in array ✓ Add action in object ✓ Delete action in object ✓ Edit action in object ✓ Nested object ✓ enableDeleteAction: Array ✓ enableDeleteAction: Object
18 passing (26ms)
$ npm run test:coverage
Statements : 100% ( 56/56 )
Branches : 58.7% ( 27/46 )
Functions : 100% ( 16/16 )
Lines : 100% ( 56/56 )
| js-deep-diff | deep-diff | deep-object-diff |
|---|---|---|
| 5.36937ms | 5.87379ms | 3.06766ms |
FAQs
Javascript object deep diff.
We found that js-deep-diff demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.