0.1.3 • Published 9 years ago

is-equal-shallow v0.1.3

Weekly downloads
3,025,415
License
MIT
Repository
github
Last release
9 years ago

is-equal-shallow NPM version Build Status

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'

Related projects

Other object utils:

  • clone-deep: Recursively (deep) clone JavaScript native types, like Object, Array, RegExp, Date as well as primitives.
  • for-in: Iterate over the own and inherited enumerable properties of an objecte, and return an object… more
  • for-own: Iterate over the own enumerable properties of an object, and return an object with properties… more
  • is-plain-object: Returns true if an object was created by the Object constructor.
  • isobject: Returns true if the value is an object and not an array or null.

Running 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 © 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on June 22, 2015.

regex-cachearchetype-libraryrn-send-sms@arisageha/react-lazyload@arisageha/react-lazyload-fixcloud-archive-s3@phil8795/pecuniarius-apireact-native-thanh-toast-library@thanhnguyen14797/react-native-thanh-toast-librarypanqibaouinz-notificationunblock-block-save-variables@infinitebrahmanuniverse/nolb-is-e@everything-registry/sub-chunk-1933test-carosello-campusteadanteawed_developersamc2samc3samc4samc5sam-carouselreact-websocketssearch-input-reactsearch-list-reactteste_cegidviskan-deku-reduxvcloudcam-playkit-js-hlsvideo-multi-uploadervue-dev-clone3.0.0miguelcostero-ng2-toastymini-vue-validatelierah-1lierah-2lierah-3lierah-4lierah-5lierah-6lierah-7lierah-8lierah-9ivanpantekmixtrack-clientkafirchain-tetrisgzup-react-image-file-resizerh5-templeteka-flow.jshendo-clihendo-cli-luozheaolrbceshimedia-capturaoutils-renoutesouteprebeneide-first-npm-packageprova-2-caroselloprova-cmpprova-cpm-2prova-cpm-3prova-cpm-4polen-web-components-reactplaykit-js-hls-sondqpostcss-responsive-valuesprimeng-customnionpatternxreact-angular-componentqyx-hmtldiffreact-native-brother-projectreact-oareact-redux-demo1react-native-version-managerreact-router-componentreact-popper-forknois-react-toastreact-native-handcheque-enginereact-native-ok-sdkreact-mapfilterreact-native-template-vifestart-starwars-libsolregex2uhuy-1uhuy-2uhuy-3typographic-orphantransferprojecttwine-libtwine-library@anonybit-modules/videoreconstruction@affilicon/bbcode-parser@axelhzf/react-apollo-hooks@bitfirer/vue-qriously@brentertz/react-popper@cdevine49/react-numeric-input@congtuan/custom-componentyashodhhhhhhhhhhhhhhyashodhhhhhhhhhhhhhh22zylvue-v3-yandex-metrika
0.1.3

9 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago