UNPKG

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