Skip to content

michaelreflective/deep-object-diff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deep Object Diff

Build Status Coverage Status

A small library that will deep diff two JavaScript Objects, including nested structures of arrays and objects, and return the difference.

Useage:

const lhs = { foo: { bar: { a: [1, 2], b: 2, c: ['x', 'y'], e: 100 // deleted } }, buzz: 'world' }; const rhs = { foo: { bar: { a: [1], // updated (value deleted) b: 2, // unchanged c: ['x', 'y', 'z'], // updated (value added) d: 'Hello, world!' // added } }, buzz: 'fizz' // updated }; console.log(diff(lhs, rhs)); /* logs: {  foo: {  bar: {  a: {  '1': undefined  },  c: {  '2': 'z'  },  d: 'Hello, world!',  e: undefined  }  },  buzz: 'fizz' } */

About

Deep diffs two objects, including nested structures of arrays and objects, and returns the difference.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%