Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/apendua/compare
https://github.com/apendua/compare
Last synced: 9 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/apendua/compare
- Owner: apendua
- Created: 2023-10-19T17:12:48.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-01-29T16:50:37.000Z (9 months ago)
- Last Synced: 2024-10-28T15:41:46.950Z (11 days ago)
- Language: JavaScript
- Size: 66.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Compare: a total order on all JSON values
This package provides an implementation of `compare(a, b)` function that establishes a total order on the set of all valid JSON values. This can be useful in scenarios where you need to compare JSON objects or values to determine their relative order.
## Installation
Please use the package manager of your choice, e.g.
```
npm install @apendua/compare
```## Usage
```javascript
import compare from '@apendua/compare';const json1 = { name: 'Alice', age: 30 };
const json2 = { name: 'Bob', age: 25 };const result = compare(json1, json2);
if (result === 0) {
console.log('json1 and json2 are equal.');
}if (result < 0) {
console.log('json1 comes before json2.');
}if (result > 0) {
console.log('json1 comes after json2.');
}
```## License
This package is released under the MIT License (LICENSE).