https://github.com/farefirst/lite-deep-equal
A simple lightweight alternative for npm deep-equal library
https://github.com/farefirst/lite-deep-equal
Last synced: over 1 year ago
JSON representation
A simple lightweight alternative for npm deep-equal library
- Host: GitHub
- URL: https://github.com/farefirst/lite-deep-equal
- Owner: FareFirst
- License: gpl-3.0
- Created: 2019-12-09T08:14:41.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T04:26:53.000Z (over 3 years ago)
- Last Synced: 2023-11-03T18:46:49.396Z (over 2 years ago)
- Language: JavaScript
- Size: 511 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lite-deep-equal
[](https://github.com/FareFirst/lite-deep-equal/actions?query=workflow%3A%22build%22+branch%3Amaster)
A simple lightweight alternative for [deep-equal](https://www.npmjs.com/package/deep-equal)
This package is based on https://stackoverflow.com/a/32922084/1866804
Compatible with Node and Browser
This package support all basic types in Javascript: Object, Array, Number, String, null & undefined
## Install
```bash
npm install lite-deep-equal
```
## Usage
```js
const deepEqual = require('lite-deep-equal');
console.dir(
deepEqual(
{ a: [2, 3], b: [4] },
{ a: [2, 3], b: [4] },
),
);
// => true
console.dir(
deepEqual(
{ x: 5, y: [6] },
{ x: 5, y: 6 },
),
);
// => false
console.dir(
deepEqual(
{
a: [2, 3],
c: {
e: ['hello', 2],
},
b: [4],
d: null,
},
{
a: [2, 3],
b: [4],
c: {
e: ['hello', 2],
},
d: null,
},
),
);
// => true
```
## Methods
### deepEqual(a, b, opts)
```js
const deepEqual = require('lite-deep-equal');
```
Compare objects a and b, returning whether they are equal according to a recursive equality algorithm.
## Contributing
PR's are welcome!
Thanks to all [the contributors](https://github.com/FareFirst/lite-deep-equal/graphs/contributors)!