https://github.com/natlibfi/object-comparison
Check if two Javascript objects are equal enough
https://github.com/natlibfi/object-comparison
Last synced: about 1 year ago
JSON representation
Check if two Javascript objects are equal enough
- Host: GitHub
- URL: https://github.com/natlibfi/object-comparison
- Owner: NatLibFi
- License: gpl-3.0
- Created: 2015-09-04T07:56:20.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2021-03-17T11:30:31.000Z (over 5 years ago)
- Last Synced: 2025-03-14T22:22:00.832Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 76.2 KB
- Stars: 0
- Watchers: 8
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Object comparison [](https://travis-ci.org/NatLibFi/object-comparison) [](https://codeclimate.com/github/NatLibFi/object-comparison/coverage)
A function to check if two Javascript objects are equal enough. Returns a boolean indicating whether the objects are equal or not.
**ONLY SUPPORTS JSON-SERIALIZABLE OBJECTS. IN OTHER WORDS: FUNCTION PROPERTIES CANNOT BE COMPARED**
## Usage
### AMD
```javascript
define(['object-comparison'], function(objectCompare) {
if (objectCompare(o1, o2)) {
console.log('equal');
}
});
```
### Node.js
```javascript
var objectCompare = require('object-comparison');
if (objectCompare(o1, o2)) {
console.log('equal');
}
```
### Browser globals
```javascript
if (objectCompare(o1, o2)) {
console.log('equal');
}
```
## Configuration
The functions takes an object as a third argument which can have the following properties:
* **strict** (*boolean*): If true, primitive types are compared with strict equality operator (===) (**Default**: *true*)
* **order** (*boolean*): If true, array elements must be in same order (**Default**: *true*)
* **caseSensitive** (*boolean*): If true, string values (As such, as array values or as object values) are compared case-sensitive. (**Default**: *true*)
## License and copyright
Copyright (c) 2015-2016 **University Of Helsinki (The National Library Of Finland)**
This project's source code is licensed under the terms of **GNU General Public License Version 3**.