https://github.com/i-e-b/node-samevaluesas
A very relaxed 'deep equals' that allows for any order in arrays, even if array values are objects.
https://github.com/i-e-b/node-samevaluesas
test-tools working
Last synced: 12 months ago
JSON representation
A very relaxed 'deep equals' that allows for any order in arrays, even if array values are objects.
- Host: GitHub
- URL: https://github.com/i-e-b/node-samevaluesas
- Owner: i-e-b
- License: bsd-3-clause
- Created: 2014-10-06T13:13:54.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-11-18T14:03:05.000Z (over 9 years ago)
- Last Synced: 2025-02-27T17:22:57.485Z (about 1 year ago)
- Topics: test-tools, working
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
node-sameValuesAs
=================
A very relaxed 'deep equals' that allows for any order in arrays, even if array values are objects.
This is a quick hack on https://www.npmjs.org/package/deep-equal and is probably full of bugs and strange
behaviours
Usage
-----
```javascript
var compare = require("same-values-as").compare;
compare(1, [1]); // throws an exception telling you what the first difference is
compare([1,2,3] , [3,2,1]); // returns true with no exception
```
Features
--------
* Considers `null` and `undefined` to be equal
* Compares the contents of arrays regardless of order (even if the children are objects)
* Throws an error if the objects don't match and tells you the first difference, with a path in the object.
* Tries to compare dates in a relaxed way (including where they are in strings or tick values)
* Considers a property with an empty array to equal a missing property
That last one should be explained:
```javascript
{
"one": [2,3,4],
"optional": []
}
```
is considered to be equal to
```javascript
{
"one": [2,3,4]
}
```
but **not** equal to
```javascript
{
"one": [2,3,4],
"optional": null
}
```