d1d37d94feb23ed211287e592fec14b1be9e942f38a5666fcf8c05cfe26dfa0b5ba8536b8baa52fad62c769425ac353ea2186d33c8d498e6e7a63eed5738a5 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # deep-equal <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
  2. Node's `assert.deepEqual() algorithm` as a standalone module, that also works in browser environments.
  3. It mirrors the robustness of node's own `assert.deepEqual` and is robust against later builtin modification.
  4. [![github actions][actions-image]][actions-url]
  5. [![coverage][codecov-image]][codecov-url]
  6. [![License][license-image]][license-url]
  7. [![Downloads][downloads-image]][downloads-url]
  8. [![npm badge][npm-badge-png]][package-url]
  9. # example
  10. ``` js
  11. var equal = require('deep-equal');
  12. console.dir([
  13. equal(
  14. { a : [ 2, 3 ], b : [ 4 ] },
  15. { a : [ 2, 3 ], b : [ 4 ] }
  16. ),
  17. equal(
  18. { x : 5, y : [6] },
  19. { x : 5, y : 6 }
  20. )
  21. ]);
  22. ```
  23. # methods
  24. ``` js
  25. var deepEqual = require('deep-equal')
  26. ```
  27. ## deepEqual(a, b, opts)
  28. Compare objects `a` and `b`, returning whether they are equal according to a recursive equality algorithm.
  29. If `opts.strict` is `true`, use strict equality (`===`) to compare leaf nodes.
  30. The default is to use coercive equality (`==`) because that's how `assert.deepEqual()` works by default.
  31. # install
  32. With [npm](https://npmjs.org) do:
  33. ```
  34. npm install deep-equal
  35. ```
  36. # test
  37. With [npm](https://npmjs.org) do:
  38. ```
  39. npm test
  40. ```
  41. [package-url]: https://npmjs.org/package/deep-equal
  42. [npm-version-svg]: https://versionbadg.es/inspect-js/deep-equal.svg
  43. [deps-svg]: https://david-dm.org/inspect-js/node-deep-equal.svg
  44. [deps-url]: https://david-dm.org/inspect-js/node-deep-equal
  45. [dev-deps-svg]: https://david-dm.org/inspect-js/node-deep-equal/dev-status.svg
  46. [dev-deps-url]: https://david-dm.org/inspect-js/node-deep-equal#info=devDependencies
  47. [npm-badge-png]: https://nodei.co/npm/deep-equal.png?downloads=true&stars=true
  48. [license-image]: https://img.shields.io/npm/l/deep-equal.svg
  49. [license-url]: LICENSE
  50. [downloads-image]: https://img.shields.io/npm/dm/deep-equal.svg
  51. [downloads-url]: https://npm-stat.com/charts.html?package=deep-equal
  52. [codecov-image]: https://codecov.io/gh/inspect-js/node-deep-equal/branch/main/graphs/badge.svg
  53. [codecov-url]: https://app.codecov.io/gh/inspect-js/node-deep-equal/
  54. [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/node-deep-equal
  55. [actions-url]: https://github.com/inspect-js/node-deep-equal/actions