Comparing version 1.0.0 to 1.0.1
@@ -1,4 +0,4 @@ | ||
Number.prototype.btwn = function(min, max, closed = true) { | ||
Number.prototype.btwn = function(min, max, inclusive = true) { | ||
var n = this.valueOf(); | ||
if (closed) { | ||
if (inclusive) { | ||
return n >= min && n <= max; | ||
@@ -5,0 +5,0 @@ } else { |
{ | ||
"name": "btwn", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Check if a number is in your min-max bounds.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,3 @@ | ||
# btwn | ||
# btwn []() []() [](https://travis-ci.org/moriczgergo/btwn) | ||
Check if a number is in your min-max bounds. | ||
@@ -20,3 +21,3 @@ | ||
``` | ||
```js | ||
require('btwn'); | ||
@@ -35,10 +36,14 @@ | ||
### Number.btwn(min, max, [closed]) | ||
### Number.btwn(min, max, [inclusive]) | ||
* min - Minimum value. | ||
* max - Maximum value. | ||
* closed - Are the bounds closed or not. If this is true, min and max are inclusive. (Default: true) | ||
* inclusive - Are min and max inclusive. (Default: true) | ||
## To-do | ||
* [ ] Integrate into dates | ||
## Tests | ||
Run `mocha`. |
@@ -5,11 +5,11 @@ var assert = require('assert'); | ||
var i = 17; | ||
it("checks the number with closed bounds", function() { | ||
it("checks the number with inclusive bounds", function() { | ||
var x = i.btwn(1, 17); | ||
assert.equal(x, true, 'i.btwn(1,17) is true (i=17)'); | ||
}); | ||
it("checks the number with open bounds", function() { | ||
it("checks the number with exclusive bounds", function() { | ||
var x = i.btwn(1, 17, false); | ||
assert.equal(x, false, 'i.btwn(1,17, false) is false (i=17)'); | ||
}); | ||
it("throws error if min and max are the same and using open bounds", function() { | ||
it("throws error if min and max are the same and using exclusive bounds", function() { | ||
assert.throws(function() { | ||
@@ -16,0 +16,0 @@ var x = i.btwn(17,17,false); |
38648
48