JSPM

objectcompare

0.2.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 21
  • Score
    100M100P100Q55446F
  • License MIT

Node.js library for comparing objects.

Package Exports

  • objectcompare

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (objectcompare) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

object compare

Node.js library for comparing objects.

###Sample

var firstActor = {
    name : {
        first : "Ryan",
        second: "Gossling"
    },
    age: 31,
}

var secondActor = {
    name : {
        first : "Brian",
        second: "Blessed"
    },
    age: 76,
}

var result = objectComparison(firstActor, secondActor)

The result object will look like this:

{ 
    equal: false,
    differences: { 
        'name.first': { reason: 'differentValues',
                        firstValue: 'Ryan',
                        secondValue: 'Brian' },
        'name.second': { reason: 'differentValues',
                         firstValue: 'Gossling',
                         secondValue: 'Blessed' },
         age: { reason: 'differentValues', firstValue: 31, secondValue: 76 } 
     } 
}

###Tests First install mocha:

npm install mocha -g

Run the tests:

mocha -R spec spec/testFixture spec/ -w -G --recursive

###Examples To run the examples

node examples/simpleComparison