Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/derhuerst/is-roughly-equal
❓ Check if a number is within a certain fault tolerance to another.
https://github.com/derhuerst/is-roughly-equal
assert test
Last synced: 6 days ago
JSON representation
❓ Check if a number is within a certain fault tolerance to another.
- Host: GitHub
- URL: https://github.com/derhuerst/is-roughly-equal
- Owner: derhuerst
- License: isc
- Created: 2016-03-22T18:44:41.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-05-12T01:13:36.000Z (over 4 years ago)
- Last Synced: 2024-11-07T15:07:02.553Z (7 days ago)
- Topics: assert, test
- Language: JavaScript
- Homepage: https://github.com/derhuerst/is-roughly-equal
- Size: 15.6 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# is-roughly-equal ❓
**Check if a number is within a certain epsilon to another.** [Supports currying](#api). Similar to [`almost-equal`](https://github.com/scijs/almost-equal).
[![npm version](https://img.shields.io/npm/v/is-roughly-equal.svg)](https://www.npmjs.com/package/is-roughly-equal)
[![build status](https://img.shields.io/travis/derhuerst/is-roughly-equal.svg)](https://travis-ci.org/derhuerst/is-roughly-equal)
[![dependency status](https://img.shields.io/david/derhuerst/is-roughly-equal.svg)](https://david-dm.org/derhuerst/is-roughly-equal#info=dependencies)
[![dev dependency status](https://img.shields.io/david/dev/derhuerst/is-roughly-equal.svg)](https://david-dm.org/derhuerst/is-roughly-equal#info=devDependencies)
![ISC-licensed](https://img.shields.io/github/license/derhuerst/is-roughly-equal.svg)
[![chat on gitter](https://badges.gitter.im/derhuerst.svg)](https://gitter.im/derhuerst)*is-roughly-equal* is [well-tested](test.js).
## Installing
```
npm install is-roughly-equal
```## Usage
```js
const isRoughlyEqual = require 'is-roughly-equal'// without currying
isRoughlyEqual(11.1) // false
isRoughlyEqual(11) // true
isRoughlyEqual(10) // true
isRoughlyEqual(9) // true
isRoughlyEqual(8.9) // falseconst check = isRoughlyEqual(1, 10) // equal to 10 with epsilon of 1
check(11.1) // false
check(11) // true
check(10) // true
check(9) // true
check(8.9) // false
```## API
### `isRoughlyEqual([epsilon], [a], [b])`
- Called **without arguments**, returns `isRoughlyEqual.unary(1)`.
- Called **with 1 arguments** `epsilon`, returns `isRoughlyEqual.unary(epsilon)`
- Called **with 2 arguments** `epsilon` and `a`, returns `isRoughlyEqual.binary(epsilon, a)`.
- Called **with 3 arguments** `epsilon`, `a` and `b`, returns `isRoughlyEqual.ternary(epsilon, a, b)`.### `isRoughlyEqual.unary(epsilon)`
Returns a function `(a, b) => isRoughlyEqual.ternary(epsilon, a, b)`.
### `isRoughlyEqual.binary(epsilon, a)`
Returns a function `(b) => isRoughlyEqual.ternary(epsilon, a, b)`.
### `isRoughlyEqual.ternary(epsilon, a, b)`
Returns `true` of `false`. **Checks if `a` is within a distance of `epsilon` to `b`.**
## Contributing
If you **have a question**, **found a bug** or want to **propose a feature**, have a look at [the issues page](https://github.com/derhuerst/is-roughly-equal/issues).