JSPM

is-equal-shallow

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3660308
  • Score
    100M100P100Q210356F
  • License

Does a shallow comparison of two objects, returning false if the keys or values differ.

Package Exports

  • is-equal-shallow

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

Readme

is-equal-shallow NPM version

Does a shallow comparison of two objects, returning false if the keys or values differ.

The purpose of this lib is to do the fastest comparison possible of two objects when the values will predictably be primitives.

  • only compares objects.
  • only compares the first level of each object
  • values must be primitives. If a value is not a primitive, even if the values are the same, false is returned.

Install with npm

npm i is-equal-shallow --save

Usage

var equals = require('is-equal-shallow');
equals(object_a, object_b);

Examples

equals({a: true, b: true}, {a: true, b: true});
//=> 'true'

equals({a: true, b: false}, {c: false, b: false});
//=> 'false'

equals({a: true, b: false}, {a: false, b: false});
//=> 'false'

Strict comparison for equality:

equals({a: true, b: true}, {a: true, b: 'true'});
//=> 'false'

When values are not primitives, false is always returned:

equals({ b: {}}, { b: {}});
//=> 'false'

equals({ b: []}, { b: []});
//=> 'false'

Run tests

Install dev dependencies:

npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright (c) 2015 Jon Schlinkert
Released under the MIT license


This file was generated by verb on February 17, 2015.