JSPM

deep-equals

0.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1310
  • Score
    100M100P100Q104296F
  • License ISC

Node.js module that compares objects

Package Exports

  • deep-equals

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 (deep-equals) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

deep-equals

Node.js module that compares objects

This does exactly what it says on the tin. It deep-compares objects, and returns what a javascript beginner would expect objectA === objectB to return

##INSTALL

In your repository, run:

    npm install --save deep-equals

##USE

In your code:

    const deepEquals = require ( 'deep-equals' );

    const objectA = {
        a: 'b',
        c: {
            d: 'e',
            f: {
                g: [ 1, 2, 3, 4, 5 ],
                h: new Date ( 0 ),
                i: 3
            }
        }
    };

    const objectB = {
        a: 'b',
        c: {
            d: 'e',
            f: {
                g: [ 1, 2, 3, 5, 4 ],
                h: new Date ( 0 ),
                i: 3
            }
        }
    };

    if ( deepEquals ( objectA, objectB ) ) {
        console.log ( 'They are the same' );
    } else {
        console.log ( 'They are not the same' );
    }

Do note that deep-equals treats array order as insignificant, as demonstrated in the example above.