Skip to content

An experimental tool for getting the difference between two object structures with as little metadata as possible.

License

Notifications You must be signed in to change notification settings

xaviervia/object-difference

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

object-difference

An experimental tool for getting the difference between two object structures with as little metadata as possible.

  • Array ordering diff is not supported right now. It needs a custom metadata object as a result to work, a third structure that contains ordering data for the whole structure.

Internal API

Note: For both Object and Array, the comparison is done in two steps:

  1. The difference function checks what properties are present and missing in the respective targets
  2. Whenever a property is present in both targets, the comparisonFunction is invoked, passing down the values of the property in both cases and the options object into it
  3. Reordering of the exact same properties in an Array will not be detected.

objectDifference

objectDifference(
  previousObject,
  nextObject,
  {
    comparisonFunction = objectDifference
  }
)

To be tested with a comparisonFunction that runs a simple reference comparison.

arrayDifference

arrayDifference(
  previousArray,
  nextArray,
  {
    comparisonFunction = objectDifference,
    keyProperty = 'key'
  }
)

Absence of key property will throw an Error. To be tested with a comparisonFunction that runs a simple reference comparison.

License

See License attached.

About

An experimental tool for getting the difference between two object structures with as little metadata as possible.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published