approximately-equal
Advanced tools
Comparing version
@@ -17,1 +17,3 @@ 'use strict'; | ||
}; | ||
module.exports = exports['default']; |
{ | ||
"name": "approximately-equal", | ||
"description": "Check if two numbers are approximately equal", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"keywords": [ | ||
@@ -15,4 +15,5 @@ "number", | ||
"devDependencies": { | ||
"ava": "^0.7.0", | ||
"babel-cli": "^6.3.15", | ||
"ava": "^0.10.0", | ||
"babel-cli": "^6.4.0", | ||
"babel-plugin-add-module-exports": "^0.1.2", | ||
"babel-preset-es2015": "^6.3.13" | ||
@@ -24,3 +25,3 @@ }, | ||
"test": "ava", | ||
"prepublish": "babel --presets es2015 index.js --out-file index.es5.js", | ||
"prepublish": "babel index.js --out-file index.es5.js", | ||
"postpublish": "rm -rf *.es5.js && git push --follow-tags" | ||
@@ -27,0 +28,0 @@ }, |
@@ -15,2 +15,3 @@ # approximately-equal [![Build Status][travis-image]][travis-url] | ||
import approximatelyEqual from 'approximately-equal'; | ||
approximatelyEqual(100.5, 101, 0.1); // false | ||
@@ -22,6 +23,23 @@ approximatelyEqual(100.5, 100.6, 0.1); // true | ||
### approximatelyEqual(a, b, error) | ||
### approximatelyEqual(actual, expected[, error]) | ||
Check if `a` equal to `b` with approximation `error` | ||
#### actual | ||
Type: `number` | ||
Actual value. | ||
#### expected | ||
Type: `number` | ||
Expected value. | ||
#### error | ||
Type: `number` | ||
Default: `0` | ||
Approximation error. | ||
## License | ||
@@ -28,0 +46,0 @@ |
import test from 'ava'; | ||
import approximatelyEqual from './index.es5'; | ||
test('should be approximately equal', t => { | ||
test('approximately equal', t => { | ||
t.true(approximatelyEqual(100.5, 100.4, 0.1)); | ||
@@ -10,5 +10,5 @@ t.true(approximatelyEqual(100.5, 100.5, 0.1)); | ||
test('should be not equal', t => { | ||
test('not equal', t => { | ||
t.false(approximatelyEqual(100.5, 100.7, 0.1)); | ||
t.false(approximatelyEqual(100.5, 100.3, 0.1)); | ||
}); |
Sorry, the diff of this file is not supported yet
2887
10.44%9
12.5%25
4.17%49
58.06%4
33.33%