UNPKG

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