Comparing version 1.0.6 to 1.0.7
16
index.js
@@ -692,2 +692,18 @@ /** | ||
/** | ||
* Test if 'value' is within 'precision' decimal places from 'comparitor'. | ||
* Alias: closish, near. | ||
* @param {Number} value value to test | ||
* @param {Number} comparitor value to test 'value' against | ||
* @param {Number} precision number of decimals to compare floating points, defaults to 2 | ||
* @return {Boolean} true if 'value' is within 'precision' decimal places from 'comparitor', false otherwise. | ||
*/ | ||
is.prettyClose = function(value, comparitor, precision) { | ||
if (!is.number(value) || !is.number(comparitor)) return false; | ||
if (is.defined(precision) && !is.posInt(precision)) return false; | ||
if (is.undefined(precision)) precision = 2; | ||
return value.toFixed(precision) === comparitor.toFixed(precision); | ||
}; | ||
is.closish = is.near = is.prettyClose; | ||
//////////////////////////////////////////////////////////////////////////////// | ||
@@ -694,0 +710,0 @@ // Networking |
{ | ||
"name": "is2", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "A type checking library where each exported function returns either true or false and does not throw. Also added tests.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -101,2 +101,3 @@ is2 | ||
* is.withIn(val, start, finish) - is.within | ||
* is.prettyClose(val, comp, precision) - is.closish, is.near | ||
@@ -103,0 +104,0 @@ Networking: |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
118681
2512
165