Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ngryman/compare-values
Get functions to compare two values given an operator.
https://github.com/ngryman/compare-values
Last synced: about 1 month ago
JSON representation
Get functions to compare two values given an operator.
- Host: GitHub
- URL: https://github.com/ngryman/compare-values
- Owner: ngryman
- License: mit
- Created: 2015-05-29T09:51:18.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-11T18:07:15.000Z (over 7 years ago)
- Last Synced: 2024-10-11T18:31:57.424Z (about 1 month ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# compare-values [![npm][npm-image]][npm-url] [![travis][travis-image]][travis-url]
[npm-image]: https://img.shields.io/npm/v/compare-values.svg?style=flat
[npm-url]: https://npmjs.org/package/compare-values
[travis-image]: https://img.shields.io/travis/ngryman/compare-values.svg?style=flat
[travis-url]: https://travis-ci.org/ngryman/compare-values> Get functions to compare two values given an operator.
## Install
```
$ npm install —-save compare-values
```## Usage
```js
var compareFactory = require(‘compare-values’);var equal = compareFactory(‘=‘);
equal(1, 1); //=> true
equal(1, 2); //=> falsevar greaterThan = compareFactory(‘>’);
greaterThan(2, 1); //=> true
greaterThan(1, 2); //=> false
```## Operators
| = | < | > | <= | >= | != | %= |
| --------- | ------- | ------- | -------- | -------- | -------- | ------------- |
| `a === b` | `a < b` | `a > b` | `a <= b` | `a >= b` | `a != b` | `a % b === 0` |## License
MIT © [Nicolas Gryman](http://ngryman.sh)