You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.2 KiB

4 years ago
  1. # deep-equal
  2. Node's `assert.deepEqual() algorithm` as a standalone module.
  3. This module is around [5 times faster](https://gist.github.com/2790507)
  4. than wrapping `assert.deepEqual()` in a `try/catch`.
  5. [![browser support](https://ci.testling.com/substack/node-deep-equal.png)](https://ci.testling.com/substack/node-deep-equal)
  6. [![build status](https://secure.travis-ci.org/substack/node-deep-equal.png)](https://travis-ci.org/substack/node-deep-equal)
  7. # example
  8. ``` js
  9. var equal = require('deep-equal');
  10. console.dir([
  11. equal(
  12. { a : [ 2, 3 ], b : [ 4 ] },
  13. { a : [ 2, 3 ], b : [ 4 ] }
  14. ),
  15. equal(
  16. { x : 5, y : [6] },
  17. { x : 5, y : 6 }
  18. )
  19. ]);
  20. ```
  21. # methods
  22. ``` js
  23. var deepEqual = require('deep-equal')
  24. ```
  25. ## deepEqual(a, b, opts)
  26. Compare objects `a` and `b`, returning whether they are equal according to a
  27. recursive equality algorithm.
  28. If `opts.strict` is `true`, use strict equality (`===`) to compare leaf nodes.
  29. The default is to use coercive equality (`==`) because that's how
  30. `assert.deepEqual()` works by default.
  31. # install
  32. With [npm](http://npmjs.org) do:
  33. ```
  34. npm install deep-equal
  35. ```
  36. # test
  37. With [npm](http://npmjs.org) do:
  38. ```
  39. npm test
  40. ```