Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "rangerjs", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A lightweight JS library for defining an array of ranges.", | ||
@@ -5,0 +5,0 @@ "main": "ranger.js", |
@@ -6,4 +6,12 @@ | ||
var endBeforeStart = function(start, end) { | ||
if (start - end > 0) | ||
return true; | ||
return false; | ||
} | ||
ranger.prototype = { | ||
addRange: function(start, end) { | ||
if (endBeforeStart(start, end)) | ||
return new Error('Start must be before end for range'); | ||
var index = null, | ||
@@ -56,3 +64,16 @@ count = 0; | ||
checkRange: function(start, end) { | ||
if (endBeforeStart(start, end)) | ||
return new Error('Start must be before end for range'); | ||
for (var i=0; i < this.ranges.length; i+=2) { | ||
if (this.ranges[i] <= start && | ||
this.ranges[i+1] >= end) | ||
return true; | ||
} | ||
return false; | ||
}, | ||
removeRange: function(start, end) { | ||
if (endBeforeStart(start, end)) | ||
return new Error('Start must be before end for range'); | ||
for (var i=0; i < this.ranges.length; i+=2) { | ||
@@ -59,0 +80,0 @@ if (this.ranges[i+1] >= start) { |
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
5602
138